Skip to content

How to install drupal to root directory, not /web? #258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
superfedya opened this issue Mar 27, 2017 · 7 comments
Closed

How to install drupal to root directory, not /web? #258

superfedya opened this issue Mar 27, 2017 · 7 comments

Comments

@superfedya
Copy link

Hi,

My site root directory is: /var/www/mysite.com

I installed composer via composer create-project drupal-composer/drupal-project:8.x-dev /var/www/mysite.com --stability dev --no-interaction

Everything works fine except that now my site address become mydomain.com/web/core/index.php instead of mydomain.com/index.php.

Any way to fix that?

Thanks

@webflo
Copy link
Member

webflo commented Mar 27, 2017

Add --no-install to the composer create-project. Adjust the paths in composer.json and run composer install. But its this setup is not recommended because this the vendor folder will end up in a web accessible path. It is more secure to change the webserver config to work with the default folder layout.

@webflo webflo added the support label Mar 27, 2017
@frob
Copy link

frob commented May 12, 2017

Could this be added as a piece of configuration? This would allow people to use this composer project without having to adopt the project's opinionated file structure.

For example, we are already putting our files in /web/public and not just /web if this directory structure where a part of configuration then we could use this project without forking/modifying all the places where this directory is used.

@webflo
Copy link
Member

webflo commented May 12, 2017

Changing the composer.json is easy. But .gitignore and a few other files is not so easy.

@frob
Copy link

frob commented May 12, 2017

If it can be changed in one place it would be a non-issue. As it is, it is in 5 places just in the composer.json

@frob
Copy link

frob commented Jun 12, 2017

I am also not sure if the drush policy will still be enforced with a different folder structure.

@allella
Copy link

allella commented Oct 11, 2017

Replying to old questions but hopefully it helps someone in the future. Also, I believe this issue can be closed because there are simple fixes to both questions.

@superfedya It is now best practice to have certain files outside of the root public directory. This is why many frameworks and CMS have a "web" or "public" or "pub" directory where the public files can live. A directory below that is where sensitive things like .git, private files and such can live.

The simple way to deal with a /var/www/mysite.com/web is to edit your web server's document root. For example, in Apache this would mean setting DocumentRoot /var/www/mysite.com/web This should be easy even if you don't have access to your Apache or Nginx configuration files because changing the document root is a basic setting in shared hosting platforms like cPanel and Plesk.

@frob the drupal-project allows you to specify different install paths if you don't like /web. You simple edit the extra.installers-paths section of the main composer.json. For example, if you prefer /web/public instead of /web then it would look like below

    "extra": {
        "installer-paths": {
            "web/public/core": ["type:drupal-core"],
            "web/public/libraries/{$name}": ["type:drupal-library"],
            "web/public/modules/contrib/{$name}": ["type:drupal-module"],
            "web/public/profiles/contrib/{$name}": ["type:drupal-profile"],
            "web/public/themes/contrib/{$name}": ["type:drupal-theme"],
            "drush/contrib/{$name}": ["type:drupal-drush"]
        }
    }

@weitzman
Copy link
Contributor

Also the drupal-launcher uses that installer-paths entry to find drupal root so it would be compatible with the above approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants