If you use composer for Drupal 8, default you have your public data inside web directory. To change that, you need to edit composer.json and find extra section:
"extra": {
"installer-paths": {
"web/core": ["type:drupal-core"],
"web/libraries/{$name}": ["type:drupal-library"],
"web/modules/contrib/{$name}": ["type:drupal-module"],
"web/profiles/contrib/{$name}": ["type:drupal-profile"],
"web/themes/contrib/{$name}": ["type:drupal-theme"],
"drush/contrib/{$name}": ["type:drupal-drush"]
}
}
Change web, to your directory, for example public_html. So composer.json become:
"extra": {
"installer-paths": {
"public_html/core": ["type:drupal-core"],
"public_html/libraries/{$name}": ["type:drupal-library"],
"public_html/modules/contrib/{$name}": ["type:drupal-module"],
"public_html/profiles/contrib/{$name}": ["type:drupal-profile"],
"public_html/themes/contrib/{$name}": ["type:drupal-theme"],
"drush/contrib/{$name}": ["type:drupal-drush"]
}
}
You need to regenerate autoload declarations. To refresh autoloading from composer, run command:
composer dump-autoload
Run your website, should works fine if you renamed /web to /public_html
Short checklist in case of any problems:
- Rename folder /web to /public_html
- Modify extra section in composer.json
- composer dump-autoload
- Setup domain/vhost to point on a new folder and reload server configuration if needed
Add new comment