How to Install Drupal 7 on CentOS 7

How to Install Drupal 7 CMS on CentOS 7

We’ll show you, How to Install Drupal 7 on CentOS 7. In this tutorial we will help you install the latest version of Drupal on your CentOS 7 VPS with Nginx, MariaDB and PHP-FPM. Before we continue, we assume that you already have LEMP stack (Linux, Nginx, MariaDB and PHP) installed on your server. If not, you can follow the How to install LEMP tutorial to prepare your linux vps. If you already have LEMP stack installed on your server, we are good to go. Installing Drupal 7 on CentOS 7, is fairly easy task and it should not take more then 10 minutes to complete.

1. Update the OS system

First of all, you need to upgrade all your system software to the latest version available. This can be done using the command:

## yum update

2. Install required packages

Also, you need to install the required packages using yum:

yum install php-gd php-mbstring php-xml

3. Download Drupal

Next, you need to download Drupal from the official web site. The latest stable release is 7.32 so you can download it with the following command:

## wget http://ftp.drupal.org/files/projects/drupal-7.32.tar.gz

4. Unpack the Drupal archive

After that, you should unpack the tar.gz archive and move that directory to /var/www/html

## tar -zxvf drupal-7.32.tar.gz
## mv drupal-7.32 drupal
## mv drupal /var/www/html/

5. Configure Drupal

Now you can navigate to the /var/www/html/drupal/sites/default/ directory on your server, make a copy of the default.settings.php named settings.php and make that directory and file writable to all:

## cd /var/www/html/drupal/sites/default/
## cp default.settings.php settings.php
## chmod 666 settings.php
## chmod 777 /var/www/html/drupal/sites/default

6. Create new database

After you complete these few steps, you are ready to create the database. Log in to your MariaDB as root

## mysql -u root -p

and enter the following commands:

## create database DrupalDB;
## grant all on DrupalDB.* to Drupal_user@localhost identified by "sEcReT_pASsWoRd";
## exit

7. Configure web server

It is time to configure the web server so you can access the Drupal directory on your server using your domain name.

Navigate to /etc/nginx/conf.d with the command:

## cd /etc/nginx/conf.d

and create file drupal.conf:

## nano drupal.conf

with the following content:

server {
    server_name domain.com;
    listen 80;
    root /var/www/html/drupal;
    access_log /var/log/nginx/domain.com-access.log;
    error_log /var/log/nginx/domain.com-error.log;
    index index.php;

    location / {
        try_files  $uri $uri/ /index.php?$args;
    }

    location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
        access_log off;
        expires max;
    }
    location ~ /\.ht {
        deny  all;
    }
    location ~ \.php {
        try_files $uri = 404;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include /etc/nginx/fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

Do not forget to replace domain.com with your domain name.

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer
NVME 2 VPS

Now just $43 .99
/mo

GET YOUR VPS

8. Restart the web server

Now, restart your Nginx web server:

systemctl restart nginx

That’s it. It is time to use your favorite web browser and navigate to:

http://domain.com

Again, do not forget to replace domain.com with your domain name.
You should see something like this:

How to Install Drupal 7 on CentOS 7

Now you can follow the instructions and finish the Drupal 7 installation on your CentOS 7 VPS.

Of course you don’t have to install Drupal 7 on CentOS 7, if you use one of our Managed Drupal Hosting services, in which case you can simply ask our expert Linux admins to install Drupal for you. They are available 24×7 and will take care of your request immediately. We also published a guide for: How to Install Drupal on CentOS 8.

PS. If you liked this post, on how install Drupal 7 on CentOS 7, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Leave a Comment