How to install Drupal with PHP 7 on Ubuntu 16.04

Drupal is a free and open source content management framework written in PHP. Drupal core, contains basic features common to content-management systems. These include user account registration and maintenance, menu management, RSS feeds, taxonomy, page layout customization, and system administration. The Drupal core installation can serve as a simple Web site, a single- or multi-user blog, an Internet forum, or a community Web site providing for user-generated content.Drupal runs on any computing platform that supports both a Web server capable of running PHP and a database to store content and configuration.

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:

 
Was this answer helpful? 0 Users Found This Useful (0 Votes)