In this guide, we will show you how to install Drupal on a CentOS 8 VPS.
Drupal is a free and open-source web content management framework that is written in PHP. It allows us to create a website for a specific idea or business and gives us great tools that let us customize and make our business exactly the way we want to. In this tutorial, we will install Drupal on top of a LAMP stack. LAMP (Linux, Apache, MySQL, and PHP) is a very common web service stack that is widely used these days.
Apache is the web server, MySQL is the database server, PHP provides an excellent environment for scripts, and it all runs on top of Linux. This provides us with an excellent foundation on which we plan to install Drupal. We will use the latest CentOS 8 Linux distribution in this tutorial, but this tutorial may also work for other versions and distributions of Linux. Let’s get started.
Table of Contents
1. Prerequisites, Login, and Updates
To start, you’re going to need a CentOS 8 server or VPS that has an SSH accessible IP address with full root access (or a user with administrative access). Our VPSes all come with root access included, so we can continue.
First, we need to log in and update any packages that are currently out-of-date.
Log in to your CentOS 8 VPS with the
ssh root@IP_Address -p Port_number
You can replace the “root” user with a user that has sudo privileges if necessary, and make sure to replace
Port_number with your server’s actual IP address and SSH port number.
Make sure your system is up-to-date with the latest updates by running the following two commands:
2. Installing Apache
Installing Apache – the most popular web server in the world – is very easy. Simply run the following command:
yum install httpd
To start Apache and to enable it to auto-start on server boot, run these commands:
systemctl enable httpd systemctl start httpd
To verify that the installation is okay and the Apache web server is up and running we can try to access the server’s IP address in a web browser (e.g.
http://184.108.40.206/) – if we receive the Apache welcome screen, we are good to go.
We can check that the Apache service is properly started and working with the following command:
systemctl status httpd
3. Install the MariaDB Database Server
To install the MariaDB Database server package, run this next command:
yum install mariadb-server
During the installation, we will be asked to enter a password for the MySQL root user. It is a good idea to create a password for the MySQL root user. Make sure to use a strong password.
To set MariaDB to start at boot and start the MariaDB service for the first time, run:
systemctl enable mariadb systemctl start mariadb
To improve the security level of the MariaDB installation, we strongly recommend to run the command below:
We will be given the option to change the MariaDB root password, remove anonymous user accounts, disable root logins outside of the localhost, and remove all test databases before finally reloading privileges. It is recommended that you answer yes to all of the prompts.
For the Drupal setup, we need to create a database and connect it with a user that we will create as well. First, log in to the MariaDB console:
mysql -u root -p
Then, create a new MariaDB database and user with permissions to use it:
create database drupal_db; grant all on drupal_db.* to 'drupal_user' identified by 'password'; flush privileges; exit;
These SQL commands will create a database called
drupal_db, grant all permissions to a new user called
drupal_user that has the password ‘
password‘, before saving all permissions and exiting. You can choose names different from
drupal_user if you like, and we strongly recommend changing ‘
password‘ to a stronger password.
4. Install PHP and extensions
To install PHP and the required PHP extensions for Drupal, we have to run the following command:
yum install php php-pear php-mysqlnd php-curl php-mbstring php-gd php-xml php-pear php-fpm php-mysql php-pdo php-opcache php-json php-zip php-cli
To be sure that
php-fpm service will work even after a server reboot, run the following commands:
systemctl enable php-fpm systemctl start php-fpm
5. Download and Install Drupal
Download latest Drupal version from the Drupal official site:
cd /opt wget https://ftp.drupal.org/files/projects/drupal-8.8.5.tar.gz
Extract the Drupal archive file:
tar -xvf drupal-8.8.5.tar.gz
Move the extracted files and directories in the document root of the website:
mv drupal-8.8.5 /var/www/html/drupal
Modify the file permissions to allow Apache to access the files inside the
chown -R apache:apache /var/www/html/drupal
Configure Drupal settings:
cd /var/www/html/drupal/sites/default cp -p default.settings.php settings.php
settings.php file and configure these settings to your needs.
6. Create an Apache configuration file
To create a new configuration file for the Drupal website, we can create a new Apache configuration file:
A basic Apache configuration file looks similar to this:
Now just $43 .99
<VirtualHost *:80> ServerAdmin firstname.lastname@example.org ServerName example.com DocumentRoot /var/www/html/drupal <Directory /var/www/html/drupal/> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> ErrorLog /var/log/httpd/drupal_error.log CustomLog /var/log/httpd/drupal_access.log combined </VirtualHost
Don’t forget to change the domain name next to ServerAdmin and ServerName (
example.com) in order to make it work with your unique registered domain name.
Restart the Apache service and you are ready:
systemctl restart httpd
7. Complete the Drupal Installation
Open the Drupal website in your favorite web browser using the domain name you set in the Apache configuration. It should look something like this:
http://example.com. Once you access the site, you should see the Drupal ‘Welcome screen’ with the first step of the installation wizard.
Choose the Installation Language, continue to the next steps and finish the installation of your Drupal website:
Don’t forget to use the same database name and MariaDB username that you entered when you were creating the MariaDB database user for the Drupal website. That should be it! You now have a successful Drupal installation on your CentOS 8 VPS.
While the Drupal installation process is quite simple, that’s not the entire story of hosting your own CMS. That’s why if you use our Managed Drupal hosting, your support needs will be completely covered. We do maintenance, tailor-made optimization, and any requests that you might have, all included in the price of the VPS forever.
We hope this tutorial helped you install Drupal on your CentOS 8 server. If so, please consider sharing this post on social media by using our share shortcuts, or leave a comment down below if you have any questions or suggestions. Thank you.
2 thoughts on “How to Install Drupal on CentOS 8”
you left y in systemctl start mariadb
Thank you for that, we already fixed the typo.