For Drupal 10 there's a recommended project structure (httpdocs/web, httpdocs/vendor) and a legacy structure (httpdocs, httpdocs/vendor). These are suitable for sites on shared hosts that provide SSH access only to a single server directory.

Provided you have full root access to the server, another option is to move the recommended structure one level up, while Apache still uses httpdocs as DocumentRoot. This separates Composer files from the website even more clearly.

domain/httpdocs/...  (Drupal site)

I used this with non-Drupal PHP projects, so Composer is basically fine with it. Now I wonder how to configure Drupal 10 in order to work with this structure, too. Moving the files obviously isn't enough, so what else is needed to make this work?

  • 3
    I don't get your point. Drupal proposes a /web and a /vendor directory. It doesn't matter where those 2 directories are. They can be in a httpdocs/web/, they could in root /web, they could be /somewhere/over/the/rainbow/web ...
    – Hudri
    Nov 5, 2023 at 13:25
  • 2
    Have to agree with Hudri - what you’ve proposed is the recommended directory structure already, you’ve just replaced the more common web or docroot with httpdocs. Other than updating the web root path in composer.json, there’s nothing else to do (unless we’ve misunderstood)
    – Clive
    Nov 5, 2023 at 15:28
  • If you're on a shared hosting platform that uses cPanel I think the following might help answer your question - forums.cpanel.net/threads/… Nov 8, 2023 at 9:36
  • I understand that it basically doesn't matter where those two directories are. I just wonder how to change the configuration of an already running site that was installed using the legacy structure (in addition to moving the files).
    – Anders
    Nov 9, 2023 at 10:12
  • @Hudri of course it matters, putting vendor into the public docroot will make the files accessible from outside, you should not do this
    – john Smith
    Nov 10, 2023 at 12:55

1 Answer 1


Please follow the guide how to install Drupal 10

composer create-project drupal/recommended-project my_site_name_dir

You need to keep this structure, the "project-root" will be at my_site_name_dir and your webserver must point to the "web-root" which will be at my_site_name_dir/web by default, AFAIS you want to change only the directory of the web-root which you can easily do by adjusting the composer.json drupal-scaffold, e.g

"extra": {
        "drupal-scaffold": {
            "locations": {
                "web-root": "web/"

and adjust the installer_paths accordingly

and make composer install

  • Thanks. This is a solution for new installations. Any chance this can also be applied to an existing installation? I mean, are there hard-wired dependencies in the database, or is this just a matter of external configuration files?
    – Anders
    Nov 11, 2023 at 13:12
  • Composer is managing the dependencies and will install the same thirdparty stuff you already had based on the lock file, so its not just for new installations. You can just rename the webroot, tell your webserver where the new directory is, there shouldnt be any "hardwired" dependencies, because for the webapp the webroot is the root so it does not matter, its just important that in {webroot}/autoload.php it points correctly to ../vendor/autoload.php
    – john Smith
    Nov 11, 2023 at 17:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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