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.
Drupal Mariadb 10.4
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
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:
To start Apache and to enable it to auto-start on server boot, run these commands:
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://220.127.116.11/) – 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:
3. Install the MariaDB Database Server
To install the MariaDB Database server package, run this next command:
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:
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:
Then, create a new MariaDB database and user with permissions to use it:
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:
To be sure that
php-fpm service will work even after a server reboot, run the following commands:
5. Download and Install Drupal
Download latest Drupal version from the Drupal official site:
Extract the Drupal archive file:
Move the extracted files and directories in the document root of the website:
Modify the file permissions to allow Apache to access the files inside the
Configure Drupal settings:
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:
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:
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.