Installing Drupal 8 on CentOS 7

I recently set up a development server for Drupal 8 using my favourite flavour of Linux, CentOS. Because Drupal 8 wants PHP version 5.4 or higher I decided to try the brand new CentOS 7. The nice thing about Linux is that you can install it on almost any old PC. I used an old Athlon 64 X2 computer with 4GB of RAM and 2 x 80GB mirrored hard disks.

CentOS does not like network cards integrated into the Motherboard so I purchased a TP-Link TG-3468 network card for $15, installed it, and CentOS was cool with that.

To make it easier to do a complete reinstall if I need to, I have documented all of the steps required to get Drupal 8 going. I have published it here in case it may help someone else.

All Linux commands are formatted like this:


LAMP Stack Specs

Linux: CentOS Linux release 7.0.1406 (Core)
Apache: 2.4.6 (CentOS)
MariaDB: 5.5.37-MariaDB MariaDB Server
PHP: 5.4.16

1. Install CentOS 7.0

Download the DVD ISO from

Burn the image to a DVD and install CentOS from the DVD. Select the option to install a Basic Web Server.  Select the “PHP Support” and “Perl for Web” Add-Ons as well. I also recommend that you install the server with a static IP address.

2. Start HTTPD service each time we start up

systemctl enable httpd.service

3. Set up the firewall

We can't access the server without opening up port 80 in the firewall. We'll also tell the firewall that the server is in our DMZ.

firewall-cmd --set-default-zone=dmz
firewall-cmd --zone=dmz --add-port=80/tcp --permanent

4. Install the database

One of the big changes in CentOS is that it no longer supports MySQL. Instead it uses a drop-in replacement called MariaDB. For all intents and purposes it is a clone of MySql and works exactly the same, so we just install it.

yum install mariadb-server mariadb
systemctl start mariadb

Run the following to set up security for the database. Just follow the prompts and answer as you wish:


Check the database is running and show the version:

mysql -u root -p -v

5. Start the MariaDB service each time we start up

systemctl enable mariadb.service

6. Install drush

To Follow..

Drupal 8 needs the latest version of Drush, version 7, which can only be downloaded from github at this stage. That version of drush also requires Composer to be installed.

7. Install compass

If you are a big fan of SASS like I am then you'll need to install Compass. We need to install ruby before we can install Compass:

yum install ruby
gem install compass

You should see something like:
Successfully installed sass-n.n.nn
Successfully installed chunky_png-n.n.nn
Successfully installed fssm-n.n.nn
Successfully installed compass-n.n.nn

If you're going to be using the popular Zengrids theme then you might as well install the zengrids gem at the same time:

gem install zen-grids

8. Configure Name-based Virtual Hosts

If you're going to be using Virtual Hosts then you'll need to configure it by editing the vhosts/conf file. Replace the settings with what is appropriate for you.

vim /etc/httpd/conf.d/vhosts.conf

File content:

# Default
VirtualHost *:80
    DocumentRoot /var/www/html
    ErrorLog logs/non-vhost-error_log
    CustomLog logs/non-vhost-access_log common
# orangeweb development
VirtualHost *:80
    DocumentRoot /var/www/vhosts/
    ErrorLog logs/orangeweb-error_log
    CustomLog logs/orangeweb-access_log common

9. Set up phpinfo.php

It is always handy to have phpinfo available so you can see what PHP components are installed. Create a phpinfo.php file in the web server root:

vim /var/www/html/phpinfo.php

File content:

// display php information
<?php phpinfo(); ?>

10. Install PHP components

Install any additional PHP components you may require. We also need mbstring and mysql for phpMyAdmin.

yum install php-mbstring php-mysql
systemctl restart httpd.service

11. Install PHPMyAdmin

Download the latest version from Replace the 4.2.7 with whatever the latest version is when you install it.

cd /var/www/html
mv phpMyAdmin-4.2.7-all-languages phpMyAdmin
rm –f *.zip

12. Install APC

I like to install the Alternative PHP Cache when I have loads of memory on my server anyway. It makes Drupal run just a little bit quicker:

yum install php-pear php-devel httpd-devel pcre-devel gcc make
pcel install apc

take all the defaults for the installation questions. Now create an apc.ini file to load apc in php:

vim /etc/php.d/apc.ini

File content:

;Enable apc extension module
systemctl restart httpd.service

Browse to phpinfo.php and make sure apc is listed.

Enable apc administration if you wish so you can see what it is doing, by copying the apc.php script to your webserver root folder:

cp /usr/share/pear/apc.php /var/www/html/

You can optionally add a username and password to apc.php to protect access. Simply edit the file and change the settings:


Now browse to apc.php to see it in operation.

You can also edit apc.php to increase the amount of memory it uses. The default is 32 MB, but if you have enough memory anyway you can up it.

vim /etc/php.d/apc.ini
systemctl restart httpd.service

13. Install git

Installing git is straightforward:

yum install git

14. Install Drupal 8

We have left the best until last.:

cd /var/www/html
drush dl drupal-8

This will create a folder called drupal-8.0.x-dev. Rename it to whatever you want to call it (for example drupal8). We also need to create a files folder for Drupal.

mv drupal-8.0.x-dev drupal8
cd drupal8/sites/default
mkdir files
chmod 777 files

Now browse to the drupal8 folder and follow the installation instructions. One of the things you will need to is create a database. We have already installed phpMyAdmin so that's easy.


If you come up against the error “The directory sites/default/files is not writable even if you have set the permission to 777 then you may need to disable SELinux Mode. You can test it by using

setenforce 0

If Drupal is happy after that then you should edit the /etc/selinux/config file and set the SELINUX value to disabled.

PHP will have been installed with default setttings, and you may want to review some of these. The php setttings (which should be in /etc/php.ini) that you may want to review are:

max_execution_time (maximum script execution time)
memory_limit (maximum amount of memory a script may consume)
error_reporting (you may want to set this to the development value)
display_errors (you may want to set this to the development value)
post_max_size (the maximum size of POSTS)
upload_max_filesize (also used as the maximum import file size by phpMyAdmin)

phpMyAdmin has an issue with the key_value table when you attempt to copy the database to another database. The only way that I have been able to copy the Drupal8 database is via the command line:

mysqldump drupal8 > drupal8.sql
mysql drupal8_backup < drupal8.sql


Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Fill in the blank.