Kickoff a Drupal 8 development environment

Submitted by christophe on Mon, 08/02/2016 - 10:01

Drupal 8 evolves quickly, and it's easy to get lost amongst the several documentations that have been written since the beta releases, Drush and PHP version needs upgrade. Some things that I have learned.

Option 1 : No VM setup on Mac OSX, via Homebrew

Okay, VM's are easier to maintain solutions, but in some situations you just don't have enough RAM for having Virtualbox running all the time.

Give a try to this superb nginx, PHP-FPM, MySQL, phpMyAdmin installation provided by frdmn. It really shines !
http://blog.frd.mn/install-nginx-php-fpm-mysql-and-phpmyadmin-on-os-x-mavericks-using-homebrew/

Once this setup done, there is very little work to get Drupal 8 running.

  1. Create you Drupal virtual hosts under /usr/local/etc/nginx/sites-available
    Here is an example of the configuration file that I use.
    The only point to figure out is that we must replace the  fastcgi_pass unix:/var/run/php5-fpm.sock; by fastcgi_pass 127.0.0.1:9000;
  2. Symlink under the sites-enabled :
    ln -sfv /usr/local/etc/nginx/sites-available/drupal8-dev /usr/local/etc/nginx/sites-enabled/drupal8-dev
  3. Then nginx.restart

Personaly, I increased the memory_limit to 512 under /usr/local/etc/php/5.6/php.ini.

Other resources about nginx configuration and Drupal
https://www.nginx.com/resources/wiki/start/topics/recipes/drupal/

Then, you can install Drupal Console and Drush (see below, described under "Option 3").

Option 2 : Drupal VM

An up-to-date VM (Vagrant / Ansible) of a Drupal 8 friendly environment is maintained by Jeff Geerling http://www.drupalvm.com/.
It is useable out of the box, with a really clean configuration file. Apache OR Nginx, Drush 8, PHP 5.6, Drupal Console, Solr, Behat, XDebug, Mailhog, ... in about 5 minutes.
Oh, by the way there is a nice configurator as well.

If you choose this option, you can just stop reading here.

Note that unless VDD, that allows several sites configuration via the configuration file, Vlad and Drupal VM are focused on one site setup. 
Unfortunately VDD maintenance seems to be a bit abandoned. It still works well for Drupal 7.

Option 3 : Vlad (VM)

Vlad is another good starting point. At the time of writing, there is still some finetuning to cover, described hereunder.

Update 1/2017: DrupalVM has gaining huge popularity, but VLAD is still a really nice option to run the Drupal 7 websites you are still maintaining, because DrupalVM focuses more on Drupal 8.

Still needed to add the following declarations in /etc/php/5.6/apache2/php.ini to get rid of the PHP fatal error 'Undefined class constant MYSQL_ATTR_USE_BUFFERED_QUERY'.

 

[PHP]
extension=pdo.so
extension=pdo_mysql.so

After editing restart (or reload) Apache

sudo service apache2 restart

See https://www.drupal.org/node/1016622


If you still not believe in Vagrant and prefer a custom install directly on your OS, make sure that you have at least PHP 5.5.9 running (on Linux, check out https://launchpad.net/~ondrej/+archive/ubuntu/php5).
See https://www.drupal.org/docs/7/system-requirements/overview

Update Drush to the latest release

During the betas, Drush 7 was ok. We need Drush 8.
Nowadays, it is a Composer PHP world, so get rid of your old Drush install and install it with Composer.

Uninstall Drush, let's use the most common uninstall, but it still depends on your flavour (Pear, Homebrew, ...).

pear uninstall drush/drush

If you do not have Composer yet installed

curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
export PATH="$HOME/.composer/vendor/bin:$PATH"
source ~/.bash_profile

Then install the latest version of Drush globally

composer global require drush/drush:dev-master

It's now time to review the changes on Drush Commands for Drupal 8 (e.g. cache-rebuild / cr instead of cache-clear / cc).

Install Drupal Console

Drupal Console provides nice debug helpers and allows the generation of boilerplate code (scaffold a module, as a replacement of Drupal 6, 7 Module Builder, ...).

curl https://drupalconsole.com/installer -L -o drupal.phar
mv drupal.phar /usr/local/bin/drupal
chmod +x /usr/local/bin/drupal

Get started

Under Vlad, installation is a breeze : install the latest stable or the current dev version.

/var/www/drupal8_install.sh
/var/www/drupal8dev_install.sh

If you didn't used Vlad, you still can use Drupal Console (drupal site:install) or drush.

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.