Question

How to install drush on LAMP 16.04?

Hi, I have tried to install drush via Composer on a LAMP 16.04, but I keep getting this error (and a couple more), when I try ‘drush status’:

PHP Fatal error: Uncaught ReflectionException: Class DOMDocument does not exist in /home/USER/.composer/vendor/consolidation/output-formatters/src/Transformations/DomToArraySimplifier.php:24


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

OK, I’ve figured it out:

In order to get the installation of Composer, and subsequently Drush, to work, zip and unzip extensions needs to be installed:

$ apt-get update $ apt-get install zip unzip

Then it’s pretty plain sailing installing Composer. Make sure you have installed proper version of Curl first:

$ apt-get install curl php7-cli git

Then: $ curl -sS https://getcomposer.org/installer | sudo php – --install-dir=/usr/local/bin --filename=composer

And Drush:

$ composer global require drush/drush

Then use Composer to create your project. If you run into permission issues, then:

  1. Add “www” group and add your user to this group: $ sudo groupadd www $ sudo usermod -a -G www [user]

  2. logout/login

  3. Set ownership and write permissions: $ sudo chown -R root:www /var/www $ sudo chmod 2775 /var/www $ find /var/www -type d -exec sudo chmod 2775 {} + $ find /var/www -type f -exec sudo chmod 0664 {} +

Also note, you cannot run Composer on the smallest server config. It’s fairly memory hungry, so min. 1GB is recommended.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel