Drupal 7 Installation on Centos 6.5 - Part 1

MySQL DatabaseApache HTTP ServerPHPThis article (including Part 2) covers the end-to-end process for installing Drupal version 7.28 on Centos 6.5 using the standard repo libraries.  Drupal is a mature, enterprise-worthy open source content management system that has a large and very helpful community spread throughout the global.

Drupal CMSDrupal (and Wordpress) could be used to create a 'marketing landing site' for a public cloud and this is the reason I have decided to cover its installation process.

The first part of the article will cover the setup of the LAMP stack on Centos 6.5 and part 2 will cover the installation and configuration of Drupal 7.28 on the aforementioned platform.


A Centos (x86_64) compatible hardware platform with (for argument's sake):

  • 2GB RAM
  • A processor less than 5 years old
  • At least 5GB free disk space
  • 1 NIC

​The following build was done entirely in a virtual machine of:

  • 2GB RAM
  • 1 vCPU
  • ​16GB virtual HDD

Centos 6.5 Installation

In order to keep your base build as lean as possible from standard installation media, use the Centos Minimal Install CD image.  The name of the file to download is CentOS-6.5-x86_64-minimal.iso.  Use the Centos download page to find the nearest place from which to download the file.

Build the base build, with your preferred language, keyboard and time zone settings.  Be sure to configure the NIC carefully with the correct IP, subnet and gateway details.  Once configuration has been completed, the installation will commence. You should see 205 packages installed.

Install, Configure and verify NTP

  • Login to the new server as root
  • Install the ntp time service
yum install -y ntp
  • ​Configure the service to start automatically
chkconfig --levels 235 ntpd on
  • Start the service
service ntpd start
  • Verify the date and time are now correct (may take a few seconds to actually update)

Patch the Operating System

  • ​Ensure the operating system is fully patched
yum update -y

That's the base build done.  Feel free to perform your own tests for name resolution and time accuracy

Install and Configure MySQL

  • Install mysql server and the client
yum install -y mysql-server mysql
  • Configure the service to start automatically
chkconfig --levels 235 mysqld on
  • Start the service
service mysqld start

There will likely be a little output on the screen.  You may see messages regarding name resolution if you don't have name resolution set-up correctly.  For the purposes of this installation, the error does not need to be fixed straight away.  Naturally, proper name resolution should be implemented in your production environment.

Within the text there will be a line regarding the execution of a script that secures the MySQL installation.  It is this script that will be run next

  • Secure the installation via the built in script and use the text below as examples of how to answer the script questions
  1. Current password: <press enter>
  2. Set root password? Y
  3. New password: <nice complex password, please>
  4. Re-enter new password: <the same, nice complex password, please>
  5. Remove anonymous user? Y
  6. Disallow root login remotely? Y *
  7. Remove test database? Y
  8. Reload privilege tables now? Y

* if for some reason you wish to allow remote root login to the server (to perform back-ups, for example), perform the following actions:

  • Run MySQL client with new password
mysql -u root -p
  • Enter the following commands into the client
SELECT user,host FROM mysql.user;
CREATE USER 'root'@'%' IDENTIFIED BY '123456';
SHOW GRANTS FOR 'root'@'%';

Edit the /etc/sysconfig/iptables file and add the following line:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
  • Restart iptables
​service iptables restart

Please remember - allowing remote access for a root account is a security risk and should not be put in place without proper consideration for the risks involved.

Install and Configure Apache Web Server

  • Install the web server
yum install -y httpd
  • Configure the service to start automatically
chkconfig --levels 235 httpd on
  • Edit /etc/sysconfig/iptables and add the following lines just below the sshd port 22 directive:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
  • Restart iptables firewall
service iptables restart
  • Start the apache web server
service httpd start
  • Verify the installation was successful.  From another machine Go to:

This should be the result:

Apache Centos test page

Install PHP

  • Install PHP core and Drupal required modules
yum install -y php php-mysql php-gd php-mbstring php-pear php-xml

It is worth checking that the PHP has been successfully installed.  Perform the following steps to validate the install:

  • Navigate the file system to the document root of the web server, /var/www/html
  • Create a file called 'validate.php' and add the following lines:

// Displays all info about the PHP install, including modules

  • Login over ssh and run
php /var/www/html/validate.php

​This should cause a large amount of output to the screen and display loads of information about the web server environmental variables.

Now confirm that apache is configured to interpret php files via the php language engine:

  • In a browser go to:
  • Inspect the output.


Php functional

Check to ensure the following sections are present:

  • mbstring
  • mysql
  • mysqli
  • ​xml

Part 1 Complete

You have now completed the installation of the base server and all software components necessary for Drupal to function.  In Part 2 the installation of Drupal will be performed atop this base.  I'll complete that tonight!