Wednesday, 10 September 2014

Installing Drupal 8 on Ubuntu

I've been through the process of installing Drupal 8 on an Ubuntu virtual machine running on Windows several times now and I think I've got it down to a series of instructions that works every time.

Where I use the word "Download" you click it to do the downloading.

A. Virtual Machine on Windows

Assuming you're running Windows 7/8 machine the first thing you need is a Ubuntu virtual machine, you will need a decent Internet connection for this:

  1. Download and install the VMware player software;
  2. Download the XUbuntu virtual machine image (it's a compressed file);
    WARNING: This file is huge and the download process could take hours, depending on how good your connection is. If you have a bad connection then you may as well forget it right now.
  3. Unpack the XUbuntu 14.04t image into a folder where you want to keep your VMs (you can have more than one);
  4. Open up the folders and find the Xubuntu.vmx file and double-click it.
The virtual machine will run and everything will set-up. By the end of the process you will have a copy of XUbuntu running. And you will be filled with joy-joy feelings.

B. Adding the software

The next stage is to add all the software you want to use. Some items are essential, some are a good idea, others are entirely optional. You must have an Internet connection for this
  1. Click on the icon in the bottom left (it's the sam sort of thing as the Windows "Start" menu) and click Terminal Emulator;
    Just in case you don't know: a lot of Linux work is done on the command line.
  2. Type: sudo apt-get update
    This updates all the information about what packages are available for installing. The first time you do this (and if you leave it a while between commands) you will be asked for the password. it's password.
  3. Type: java -version
    It will tell you there isn't a version of java loaded and will then offer you some choices.
  4. Type: sudo apt-get install openjdk-7-jre-headless -y
    If you don't add the -y you'll be asked to confirm. Java will now be installed.
  5. The VM comes with Firefox, if you want Chrome (I prefer it) do this:
    a. Type: sudo apt-get install chromium-browser -y
    b. Launch Chrome from the menu under "Internet", sync with your G+ account as needed.
  6. I use Eclipse, so if you want it follow the instructions on this site. Select the PHP-specific version of Luna (at time of writing). Also in the instructions on that page use the original Exec=/opt/eclipse/eclipse command, and not the suggested change.
  7. Type: sudo apt-get install git -y
  8. Type: sudo apt-get install lamp-server^ -y
    The ^ is not a mistake, you need it. You will also need to enter the MySQL password.
  9. Type: sudo a2enmod rewrite
    To enable the apache2 rewrite module.
  10. Type: sudo service apache2 restart
    To restart apache2 (surprise!)
  11. Now you need to enable the PHP extensions you need. The only one that Drupal will actually tell you it wants is GD, but that is not in the system so it has to be loaded. There's a fairly awesome new method of doing this with PHP5.4 which we will now demonstrate:

    a. Type: 
    sudo apt-get install php5-<name> -y
    where <name> can be cgi, curl, gd, json, mysql, tidy, mcrypt, memcached, oauth, xdebug, xhprof and more. You can put them all on one line, one after the other with a space between, but don't forget to prefix with php5- in each case.

    b. Type: sudo php5enmod gd
    To enable the GD extension. So much better than fiddling with php.ini.

    You can find out more information about these here and here.
  12. Type: cd /var/www
    To move to the web directory.
  13. Type: sudo git clone --branch 8.0.x
    To bring down this version of Drupal 8, you can substitute the branch you want. This gives you a directory called 'drupal' you may want to change that.
  14. Finally you need to configure the virtual host in apache2 follow the instructions here.

C. Installing Drupal

This process is pretty much the same as for D6 and D7 but before you start there are a couple of things to do:
  1. Type: cd /var/www/drupal
    Or whatever you called your Drupal 8 directory in the end.
  2. Type: sudo chmod a+w -R sites/default
    This makes the settings directory and its contents read/writable which is necessary when going through the initial installation of Drupal.
  3. Type: cd ../..
    Go back up two directory levels.
  4. Type: chmod 777 drupal
    This allows your IDE (such as eclipse) to create its management files in the directory.
  5. Finally, go to your browser, type in the web address of your site (as configured in apache2 and the hosts file in step B.14) and you should be greeted with the Drupal install screen.

D. Relax

Job well done.

Drupal 8 (mostly)

It's customary to do a quick introduction to one's blog.

I've been earning money from Drupal for the last 8 years - almost every day of my working life has been about coding Drupal 5, 6, 7 and now 8.

My job as a contract web developer (working exclusively in Drupal) has taken to me to many different companies, large (NBC, BBC) and small (tiny), covering a wide range of subjects from control of broadcast TV to stock markets and healthcare.

I also have various contrib modules on

So I have a pretty wide knowledge of Drupal as well as lots of varied experience.

Which is where this blog comes in. I'll be using it for various hints and tips and bits of knowledge (the same as I do for my Drupal7-ish blog).

I am also in the process writing a series of books about using and developing for Drupal 8. If you want to know when they're available join my mailing list (on the right, just up there). Thanks.

Right well, that's enough of that.