Substitute TARGET_DIRECTORY with the actual directory
$ mkdir TARGET_DIRECTORY
$ composer create-project drupal-composer/drupal-project:8.x-dev TARGET_DIRECTORY --stability dev --no-interaction
If composer runs out of memory, increase PHP's memory_limit
. This could be set to a value such as 2G
, or unlimited -1
.
$ which composer
/usr/bin/composer
$ php -d memory_limit=-1 /usr/bin/composer create-project drupal-composer/drupal-project:8.x-dev TARGET_DIRECTORY --stability dev --no-interaction
Make sure Apache can write...
$ sudo chown -R YOUR_USERNAME:www-data TARGET_DIRECTORY
Set up a MySQL/MariaDB database for the site.
Go to the site with a browser, and complete setting-up the site.
Update web/sites/default/settings.php
$settings['trusted_host_patterns'] = [
'^example\.com$',
];
Add to composer.json
under installer-paths
:
"htdocs/modules/custom/{$name}": ["type:drupal-custom-module"],
"htdocs/themes/custom/{$name}": ["type:drupal-custom-theme"]
Set the correct permissions for the default
directory and settings.php
$ chmod 555 TARGET_DIRECTORY/web/sites/default
$ chmod 444 TARGET_DIRECTORY/web/sites/default/settings.php
Find all instances of web/
and replace with htdocs/
in the composer.json
file.
See: https://scriptun.com/drupal-8/public-directory-from-web-to-public-html
Before
"extra": {
"composer-exit-on-patch-failure": true,
"patchLevel": {
"drupal/core": "-p2"
},
"drupal-scaffold": {
"locations": {
"web-root": "web/"
}
},
"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/Commands/contrib/{$name}": ["type:drupal-drush"]
}
}
After
"extra": {
"composer-exit-on-patch-failure": true,
"patchLevel": {
"drupal/core": "-p2"
},
"drupal-scaffold": {
"locations": {
"web-root": "htdocs/"
}
},
"installer-paths": {
"htdocs/core": ["type:drupal-core"],
"htdocs/libraries/{$name}": ["type:drupal-library"],
"htdocs/modules/contrib/{$name}": ["type:drupal-module"],
"htdocs/profiles/contrib/{$name}": ["type:drupal-profile"],
"htdocs/themes/contrib/{$name}": ["type:drupal-theme"],
"drush/Commands/contrib/{$name}": ["type:drupal-drush"]
}
}
Then, regenerate autoload declarations by running the following command:
composer dump-autoload
cd TARGET_DIRECTORY
mkdir -p config/sync
Update web/sites/default/settings.php
$settings['config_sync_directory'] = '/var/www/vhosts/TARGET_DIRECTORY/config/sync';
Add these 2 lines to the composer.json
file under installer-paths
.
"htdocs/modules/custom/{$name}": ["type:drupal-custom-module"],
"htdocs/themes/custom/{$name}": ["type:drupal-custom-theme"]
The result should resemble this:
"installer-paths": {
"htdocs/core": ["type:drupal-core"],
"htdocs/libraries/{$name}": ["type:drupal-library"],
"htdocs/modules/contrib/{$name}": ["type:drupal-module"],
"htdocs/profiles/contrib/{$name}": ["type:drupal-profile"],
"htdocs/themes/contrib/{$name}": ["type:drupal-theme"],
"drush/Commands/contrib/{$name}": ["type:drupal-drush"],
"htdocs/modules/custom/{$name}": ["type:drupal-custom-module"],
"htdocs/themes/custom/{$name}": ["type:drupal-custom-theme"]
}