HugeServer Knowledgebase

How to install Drupal with PHP 7 on Ubuntu 16.04

Introduction

Drupal is one of the greatest free and open-source content management systems that used to make many of the websites you see every day. Easy content authoring, excellent security, and reliable performance are some of the most important benefits of using Drupal, but the most important feature of Drupal that sets it apart from other CMS is the flexibility and modularity which is one of the core principals of it. It’s also a great choice for creating integrated digital frameworks. You can extend it to anyone, or many, of thousands of add-ons. Modules expand Drupal’s functionality.

We are assuming that you have root permission, otherwise, you may start commands with “sudo”.

Drupal Logo

Requirments

For install and using Drupal, you need the following things:

  • A web server like Apache or Nginx
  • A database like Mysql (MariaDB)
  • PHP 5.5 or Higher

We are going to Install Apache as our web server, MariaDB as our Database and PHP 7.

Install Apache

You can easily install Apache from the official repository with the command below:

apt-get install apache2

After installation execute the following commands to start your Apache service and make it run at startup;

systemctl start apache2

systemctl enable apache2

Install MariaDB 10.1 (Latest)

At the time of the writing, 10.1 is the latest stable version available for Ubuntu 16.04.

For adding the MariaDB official repository you have to install the Pyhton Software Properties package first:

apt-get install python-software-properties

Then add the needed key with the following command:

apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8

Now you can install MariaDB 10.1 with the following command:

apt-get install mariadb-server

And after the installation, don’t forget to start and enable the service:

systemctl start mariadb

systemctl enable mariadb

Install PHP 7

PHP 7 is not provided by the official repository, but you can install is from PPA repository.

For adding “PPA” repo you need issue the following command:

add-apt-repository ppa:ondrej/php

execute the following command to fetch the new repository list:

apt-get update

Then you can execute the following command to install PHP 7 and the needed extensions:

apt-get install php7.0 php7.0-curl php7.0-gd php7.0-mbstring php7.0-xml php7.0-json php7.0-mysql php7.0-opcache libapache2-mod-php7.0

Creating Database

First of all, we need to do some initial configuration for MariaDB.

Run the Mysql installer script with the following command:

mysql_secure_installation

Set a password for the “root” user and answer all other question with “y”

Login to root user with the following command:

mysql -u root -p

Now we can create our database with the command below (Make sure to replace the red parts with your preferred values):

create database HS;

grant all privileges on HS.* to 'username'@'localhost' identified by 'password';

flush privileges;

Download and install Drupal

Download the Drupal source from its official website in your document root:

cd /var/www

wget https://ftp.drupal.org/files/projects/drupal-8.3.7.tar.gz

Extract the file:

tar xvzf drupal-8.3.7.tar.gz

Switch to Drupal source directory:

cd drupal-8.3.7

Move everything to the correct document root:

mv ./* /var/www/html

You have to set “Apache” as the owner of the Drupal Files with the following command:

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

Now you can open your browser and enter your server Domain name or IP address to see the following page:

Drupal Deployment Page

You can go ahead and install Drupal easily through the wizard.
 
For more information and news you can check out Drupal official website!

Was this tutorial helpful?

Thank you for your vote.Thank you for your vote.

Similar Posts

One thought on “How to install Drupal with PHP 7 on Ubuntu 16.04”

  1. Instructions are good except mv ./* /var/www/html. Hidden files are ignored. I used mv .[a-z]* /var/www/html after.
    Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *

*