In this article, we will show you how to install Drupal on a CentOS server.

1.    Login to your server via SSH or KVM, via root.
2.    Disable selinux;

setenforce 0
sed -i ‘s/enforcing/disabled/g’ /etc/selinux/config

3.    Run the following command to install all the required packages for your Apache & MySQL stack, which will host the Drupal site;

yum install httpd mariadb-server mod_ssl -y

4.    We now need to install a version of PHP above 5.5.9 to be compatible with Drupal 8 and nano.

yum install centos-release-scl -y
yum-config-manager –enable rhel-server-rhscl-7-rpms -y
yum install php55 php55-php-gd php55-php-mysqlnd php55-php-pdo php55-php-json php55-php-curl php55-php-fpm php55-php-mbstring php55-php-opcache nano -y

5.    Run the following commands to the file /etc/httpd/conf.d/php.conf, this allows for Apache to pass the requests to PHP-FPM;

echo ‘<IfModule !mod_php5.c>’ >> /etc/httpd/conf.d/php.conf
echo ‘<FilesMatch \.php$>’ >>  /etc/httpd/conf.d/php.conf
echo ‘SetHandler “proxy:fcgi://127.0.0.1:9000″‘ >>  /etc/httpd/conf.d/php.conf
echo ‘</FilesMatch>’ >> /etc/httpd/conf.d/php.conf
echo ‘</IfModule>’  >> /etc/httpd/conf.d/php.conf

6.    Update the Apache config to allow for htaccess and PHP to be used, and update the timezone configuration in PHP (drupal will need this later);

sed -i ‘s/AllowOverride [Nn]one/AllowOverride all/g’ /etc/httpd/conf/httpd.conf
sed -i ‘s/DirectoryIndex index.html/DirectoryIndex index.php index.html/g’ /etc/httpd/conf/httpd.conf
sed -i ‘s/;date.timezone =/date.timezone = “America\/New_York”/g’ /opt/rh/php55/root/etc/php.ini

7.    Start Apache & MySQL on the server;

systemctl start httpd && systemctl start php55-php-fpm && systemctl start mariadb

8.    You should now be able to confirm that Apache is started by going to either your server IP address or the domain name you have pointed to the server, in this example we will use the server IP address.

9.    Create the MySQL user and database for Drupal, enter the mysql command to get to a prompt (choose a different password to the below one, just make sure it is secure!)

mysql
CREATE DATABASE drupal;
GRANT ALL PRIVILEGES ON drupal.* TO ‘drupal’@’localhost’ IDENTIFIED BY ‘Eh4wph8WItSO’;

10.    Download and put into place the latest version of Drupal, you’ll need to find the latest version of Drupal by going to the Drupal website https://www.drupal.org/download (at the time of writing this is 8.2.1);

curl -O https://ftp.drupal.org/files/projects/drupal-8.2.1.tar.gz
tar zxvf drupal-8.2.1.tar.gz
rmdir /var/www/html
mv drupal-8.2.1 /var/www/html

11.    Update the permissions so that we can upload files through the Drupal control panel;

chown -R apache:apache /var/www/html

12.    You can now go to your site URL or IP address in the browser to complete the Drupal installation, below are the following pages you should go through to complete the install;

Your server should verify all of the requirements with this configuration and continue past the “Verify requirements” screen.

On the following page you should enter the details that you used earlier when creating the MySQL database;

Now enter the details below that you want for the site and the installation will complete and automatically redirect you to the Drupal admin panel.