Composer
- Install unzip
- sudo yum install unzip
- Install git
- sudo yum install git
- Install composer
- sudo yum install composer
- Increase memory size on VM to 4GB or add Swap space
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
- Create a directory under htdocs or /var/html to hold the install
- Note a composer project will be setup in the directory you create, and drupal will be setup in a sub directory call web, the web directory is where your virtual machine should point.
- Create a database and user in MySQL
- Install Drupal and Drush with composer, if needed change the /var/www/drupal8 to the directory you created in step #5, this is a dev version of the composer config, but will install the latest stable version of Drupal
composer create-project drupal-composer/drupal-project:8.x-dev /opt/www/drupal8 --stability dev --no-interaction
Install Drush Globally (so you can run it from any project)
First, we'll install Drush with Composer.
alias drush='/home/username/.config/composer/vendor/drush/drush/drush'
- How to Maintain a Drupal 8 Site Built with Composer
Preparing to Update Drupal Core
You'll need to follow the steps below to update your core files if you installed Drupal using the Composer build.
- Run composer update drupal/core --with-dependencies to update Drupal Core and its dependencies.
- Run git diff to determine if any of the scaffolding files have changed. Review the files for any changes and restore any customizations to .htaccess or robots.txt.
- Commit everything all together in a single commit, so web will remain in sync with the core when checking out branches or running git bisect.
- In the event that there are non-trivial conflicts in step 2, you may wish to perform these steps on a branch, and use git merge to combine the updated core files with your customized files. This facilitates the use of a three-way merge tool such as kdiff3. This setup is not necessary if your changes are simple—keeping all of your modifications at the beginning or end of the file is a good strategy to keep merges easy.
- Copy drupal8/web/sites/default/default.settings.php settings.php
- Enable writting to settings.php disable SElinux on Centos7
# setsebool allow_httpd_anon_write=1
# chcon -t public_content_rw_t sites/default sites/default/settings.php sites/default/files
Make directory
drupal8/web/sites/default/files- Change permissions on settings.php and files to be writable by apache
- Change permissions on the directory to allow apache to create files in your directory
- sudo chgrp apache drupal8
- Create a database and user for drupal
- Add apache virutal site config for recipes site to /etc/httpd/conf.d
- sudo vim /etc/httpd/conf.d/recipes.conf
- Add the following:
ServerName recipes.web3us.com
ServerAlias recipes.web3us.com
ServerAdmin webmaster@web3us.com
DocumentRoot '/opt/www/recipes/web/'
Options +Indexes +FollowSymLinks
AllowOverride All
ErrorLog /var/log/httpd/recipes-error_log
CustomLog /var/log/httpd/recipes-access_log combined
# Possible values include: debug, info, notice, warn, error, crit
LogLevel warn
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/domain.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/domain.com/privkey.pemServerName recipes.web3us.com
ServerAlias recipes.web3us.com
ServerAdmin webmaster@web3us.com
DocumentRoot '/opt/www/recipes/web/'
Options +Indexes +FollowSymLinks
AllowOverride All
ErrorLog /var/log/httpd/recipes-error_log
CustomLog /var/log/httpd/recipes-access_log combined
# Possible values include: debug, info, notice, warn, error, crit
LogLevel warn
# ServerName: The domain that should match for this virtual host configuration. This should be your domain name.
# ServerAlias: All other domains that should matchfor this virtual host as well, such as the www subdomain.
# DocumentRoot: The directory from which Apache will serve the domain files.
# Options: This directive controls which server features are available in a specific directory.
# -Indexes: Prevents directory listings.
- Restart apache
- sudo systemctl restart httpd
- localhost/drupal8
- Check for errors
- sudo tail /var/log/httpd/error_log
- if running SSL check sudo tail /var/log/httpd/ssl_error_log
- Select language
- English
- Choose profile
- Demo: Umami Food Magazine (Experimental)
- Enter database, user, and password
- Install
- Configure site
- Set site name
- Create admin user
- Select country and timezone
- Save
- Login at: http://localhost/drupal8/web/user/login
- To add modules to drupal change to the project directory, the one above the /web
- composer require drupal/
- drush en
Create a custom DRUSH command on drupal 8. Submitted by editor on Tue, - 12:28. How to create a custom drush command for drupal 8? To create a custom drush command, you must create a custom module like this (Here, mymodule). Then add a file: YOURMODULE.drush.inc (Here mymodule.drush.inc). Use IMCE files browser for custom field on Drupal 8/9 Drupal 9 add inline JavaScript to a page programmatically Private Tempstore - Store data on Drupal 9 session. The Drush project has moved to Github. Use our Github project for contributing code, or reporting bugs, or requesting features. Please ask support questions on Drupal Answers. Please see the Migration wiki page for more information. Drush was originally developed by Arto for Drupal 4.7. In May 2007, it was partly rewritten and redesigned for Drupal 5 by frando. Drush is maintained by Moshe. I moved from using Docksal to Acquia ADS (Lando) which automatically upgraded my Drush from 8 to 9. My local site works fine but I can't get Drush 9 to 'see' my Drupal 8 site. The aliases seem to have been created and added to the drush/sites folder and running drush site:alias does show them. However running drush status shows my Drupal root. But in my Drupal 8 site, when I try run: $ drush uli. I got: mysite does not appear to be a resolvable hostname or IP, not starting browser. You may need to use the -uri option in your command or site alias to indicate the correct URL of this site.
To Update Drupal Core
- Check to see if outdated
- Update Drupaldirectory/composer.json if needed (moving from drupal 8.6 to 8.7) Note: If you are upgrading major version i.e. from 8.5 to 8.6, you need to edit composer.json and replace '~8.5.x' with '^8.6.0' for drupal/core and webflo/drupal-core-require-dev. I have also been told you can replace 8.6.0 with 8.6, but I have not tested that yet.
- replace '~8.5.x' with '^8.6.0' for drupal/core
- Update drupal/core with dependencies
- Update drupal and webflo
- To allow upgrade to Drupal 8.7.6 had to use this command as webflo is still behind
- Update the database
- Cache Reset
Troubleshooting
To display the dependency tree, browsing that might help you determine what requires the packages that need to be updated and inform a decision. You also might find github.com/webflo/drupal-core-strict useful, it fixes core dependencies to known good versions which might help you update with more confidence.
composer show --tree
Drush 8 Drupal 7
To figure out which dependency was blocking my Drupal core upgrade using the Composer command:
composer prohibits drupal/core:8.5.0
Since symfony/config
(a dependency of drush and drupal console), I needed to run
Drush Drupal 8 Commands
I still have no idea how I could've figured out I just needed to add symfony/config
in the update command (vs adding all the other symfony components)... but if I do, I'll try to update this answer with that information so others can benefit in the future!
Install/Upgrade a global Drush
Drupal 8 Drush Clear Cache
- MAMP users, and anyone wishing to launch a non-default PHP, needs to edit ~/.bashrc so that the right PHP is in your $PATH.
- We have documented alternative ways to install, including Windows.
- If you need to pass custom php.ini values, run
php -d foo=bar drush.phar --php-options=foo=bar
- Your shell now has useful bash aliases and tab completion for command names, site aliases, options, and arguments.
- A drushrc.php has been copied to ~/.drush above. Customize it to save typing and standardize options for commands.
- Upgrade using this same procedure.
Install a site-local Drush
In addition to the global Drush, it is recommended that Drupal 8 sites be built using Composer, with Drush listed as a dependency.
- When you run
drush
, the global Drush is called first and then hands execution to the site-local Drush. This gives you the convenience of runningdrush
without specifying the full path to the executable, without sacrificing the safety provided by a site-local Drush. - Optional: Copy the examples/drush.wrapper file to your project root and modify to taste. This is a handy launcher script; add --local here to turn off all global configuration locations, and maintain consistency over configuration/aliases/commandfiles for your team.
- Note that if you have multiple Drupal sites on your system, it is possible to use a different version of Drush with each one.
To figure out which dependency was blocking my Drupal core upgrade using the Composer command:
composer prohibits drupal/core:8.5.0
Since symfony/config
(a dependency of drush and drupal console), I needed to run
Drush Drupal 8 Commands
I still have no idea how I could've figured out I just needed to add symfony/config
in the update command (vs adding all the other symfony components)... but if I do, I'll try to update this answer with that information so others can benefit in the future!
Install/Upgrade a global Drush
Drupal 8 Drush Clear Cache
- MAMP users, and anyone wishing to launch a non-default PHP, needs to edit ~/.bashrc so that the right PHP is in your $PATH.
- We have documented alternative ways to install, including Windows.
- If you need to pass custom php.ini values, run
php -d foo=bar drush.phar --php-options=foo=bar
- Your shell now has useful bash aliases and tab completion for command names, site aliases, options, and arguments.
- A drushrc.php has been copied to ~/.drush above. Customize it to save typing and standardize options for commands.
- Upgrade using this same procedure.
Install a site-local Drush
In addition to the global Drush, it is recommended that Drupal 8 sites be built using Composer, with Drush listed as a dependency.
- When you run
drush
, the global Drush is called first and then hands execution to the site-local Drush. This gives you the convenience of runningdrush
without specifying the full path to the executable, without sacrificing the safety provided by a site-local Drush. - Optional: Copy the examples/drush.wrapper file to your project root and modify to taste. This is a handy launcher script; add --local here to turn off all global configuration locations, and maintain consistency over configuration/aliases/commandfiles for your team.
- Note that if you have multiple Drupal sites on your system, it is possible to use a different version of Drush with each one.
Drupal Compatibility
Drush Version | Drush Branch | PHP | Compatible Drupal versions | Code Style | Isolation Tests | Functional Tests |
---|---|---|---|---|---|---|
Drush 9 | master | 5.6+ | D8.4+ | |||
Drush 8 | 8.x | 5.4.5+ | D6, D7, D8.3- | - | ||
Drush 7 | 7.x | 5.3.0+ | D6, D7 | Unsupported | ||
Drush 6 | 6.x | 5.3.0+ | D6, D7 | Unsupported | ||
Drush 5 | 5.x | 5.2.0+ | D6, D7 | Unsupported |