4

When I do composer create-project craftcms/craft, it will create a web folder. My webroot is called public_html though. Can I change this somehow, or should I make a symlink?

Or simply don't use composer to install in that case?

1 Answer 1

8

You can just rename web/ to public_html/, or move all the files inside web/ into public_html/. (Don’t forget to move the .htaccess and .env files, if the latter.)

As long as the location of the public_html/ folder is in the same place as the web/ folder was, you don’t need to change anything else.

my-project.test/
├── config/
├── ...
└── public_html/
    ├── index.php
    └── ...

If you need to change the location to something like this:

my-project.test/
├── craft/
│   ├── config/
│   └── ...
└── public_html/
    ├── index.php
    └── ...

Then just make sure that your CRAFT_BASE_PATH constant points to the right base path (craft/).

// old:
define('CRAFT_BASE_PATH', dirname(__DIR__));

// new:
define('CRAFT_BASE_PATH', dirname(__DIR__) . '/craft');
5
  • But won't that break composer update for later maintenance?
    – Urs
    Commented Aug 23, 2018 at 13:48
  • 1
    No it won't. Composer update installs everything into /vendor. All my projects use /public instead of /web.
    – Jay
    Commented Aug 23, 2018 at 13:50
  • Ok! So that would also be a valid setup: home/craft (with config, modules, storage, template and vendor, not accessible via web), home/public_html (with the content of web and a modified CRAFT_BASE_PATH)?
    – Urs
    Commented Aug 23, 2018 at 13:59
  • In that case just make sure that the CRAFT_BASE_PATH constant in public_html/index.php is pointed at the craft/ folder. Commented Aug 23, 2018 at 16:08
  • 2
    Just updated my answer to show what that would look like. Commented Aug 23, 2018 at 16:12

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.