Drupal is a popular high-performance CMS which is well-regarded for its customization and flexibility. Learn how to install Drupal 7 on CentOS 7 and Ubuntu 16.04.
There are two options for installing Drupal:
- On a new server: Drupal is available as a ready-to-use application which can be automatically installed on the server when it is built.
- On an existing server: Drupal can be manually installed and configured on an existing server.
To install on an existing server:
- Cloud Server running Linux (CentOS 7 or Ubuntu 16.04)
- Apache and MySQL/MariaDB installed and running.
Note: Apache and MySQL/MariaDB are installed and running on a standard Linux installation by default. If your server was created with a minimal installation, you will need to install and configure Apache and MySQL/MariaDB before you proceed.
Install Drupal on a New Server
Log in to the Cloud Panel then go to Infrastructure > Servers.
Click + Create to create a new server.
Enter a server name, then select the configuration you wish to use.
Click the Applications tab.
Click the Search icon, and search for Drupal.
Click Create to build the server.
After the server has been built, go to Infrastructure > Servers and select the new server.
Scroll down to the server information section, then click the Drupal Admin Area URL to log in to the Drupal Admin Area.
Log in with the username user and the password which was created when the server was built.
The server is created.
Verify Server Requirements
Drupal 7 requires PHP 5.2.5 or higher. Use the command sudo php -v to check your PHP version:
user@localhost:~# sudo php -v PHP 7.0.22-0ubuntu0.16.04.1 (cli) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.0.22-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies
In this example, the server is running PHP version 7.0.22.
Drupal 7 requires MySQL 5.0.15/MariaDB 5.1.44 or higher. Use the command sudo mysql -V to check your MySQL version:
user@localhost:~# sudo mysql -V mysql Ver 14.14 Distrib 5.7.20, for Linux (x86_64) using EditLine wrapper
In this example, the server is running MySQL version 5.7.
Drupal 7 requires Apache version 1.3 or higher. You can find your version of Apache with the following commands:
sudo httpd -v
sudo apache2 -v
This will return information about your Apache server.
Download and Uncompress Drupal
Connect to your server using SSH, and go to your website's document root. Download the current release from the Drupal website by using the command:
sudo wget [download URL]
To find the download URL, visit the current release page on the Drupal website. Go to the "Recommended release" for Drupal Core 7.x.
On the next page, copy the Download .tar.gz link. Right click on the download button and choose "Copy link location." You can then paste this URL into the command line by clicking Shift + Insert.
For example, to download the current stable release of Drupal 7 as of this article's publication (Drupal 7.50) the command is:
sudo wget https://ftp.drupal.org/files/projects/drupal-7.50.tar.gz
Unpack this file using the command:
sudo tar --strip-components=1 -xvzf [file name]
For example, to unzip the file downloaded above, the command is:
sudo tar --strip-components=1 -xvzf drupal-7.50.tar.gz
After the contents of the Drupal file have been unpacked, set the ownership of the files to the Apache user:
sudo chown -R apache:apache *
sudo chown -R www-data:www-data *
You can now delete the .tar.gz file:
sudo rm [file name]
In this example, the command is:
sudo rm drupal-7.50.tar.gz
Create the Database
Log in to MySQL/MariaDB with the command:
sudo mysql –u root –p
Create a database with the command:
CREATE DATABASE [database name];
For example, the command to create a database named my_drupal_site is:
CREATE DATABASE my_drupal_site;
Create a user for this database and grant all privileges with the command:
GRANT ALL ON [database name].* TO [database username]@localhost IDENTIFIED BY '[database user password]';
- [database name] with the name of your database.
- [database username] with the username you want to create for your database.
- [database user password] with a password for this user. Note: Be sure to give the user a strong password.
For example, the command to create a user named my_drupal_user with the password Fr4i*Re!2 with full privileges on the my_drupal_site database is:
GRANT ALL ON my_drupal_site.* TO my_drupal_user@localhost IDENTIFIED BY 'Fr4i*Re!2';
Exit the database with the command:
Open the Drupal installation location in a browser. You will see the Drupal installation page. Select Standard then click Save and Continue.
On the next page, click Save and Continue.
On the next page, select MySQL, MariaDB, or equivalent, then fill out the details of the database name, database user, and password which you created in the previous step. Then click Save and Continue.
On the next page, you will be asked to fill in some website details and create a Drupal Site Maintenance (admin) account. Fill out all the required fields, then scroll down and click Save and Continue.
The Drupal installation is complete.