-3

I am following this link to set-up a Drupal 8 site, I am installing drupal-composer/drupal-project as a template for my composer install for the first time, as I forced myself into drupal 8 for future reasons. I am not a developer myself.

Forth point of the installation says that:

...

  1. Modify the composer.json file to configure your preferred installation paths. It is highly recommended to use a sub-directory such as webroot, www, html, web, etc... when scaffolding your Drupal web site.

...

Why?

Why is it recommended and what would happen if I don't do it.

I am not able to find any decent documentation anywhere mentioning this, and I am pretty sure though that it is not drupal-specific, so please give some light on this.

How do I deploy this site, as on my localhost, I access the site as my.dev/web and I want to use mysite.com instead of mysite.com/web when I put it online. I am avoiding redirecting with .htaccess

1

A Drupal project is often/usually more than just the webroot, there are other files/folders that can be part of a project. Two specific examples are the private files folder, and the configuration folder. Storing these out of the webroot acts as a layer of security, as they are not web accessible. The configuration folder is one that is managed with Git, allowing for deployment of a project to different environments.

on my localhost, I access the site as my.dev/web and I want to use mysite.com instead of mysite.com/web when I put it online.

You do not need to put your site in a sub-directory. Using cpanel as an example, the default webroot is at /home/example/public_html. You can create a symlink from /home/example/web to /home/example/public_html (or the other way around, I get them mixed up). Then you create your project at /home/example. The web directory then becomes /home/example/web - which points at /home/example/public_html due to the symlink.

I wrote a blog post that gets into the topic in more depth: https://www.morpht.com/blog/drupal-and-composer-part-2-managing-drupal-8-site-composer

  • Will do that, thanks for the answer. – innocent rock Aug 23 at 13:19
  • I wished a simple answer and you provided with an amazing guide, you are the boss man 8) – innocent rock Aug 23 at 19:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.