Set-up-Drupal-8-on-Ubuntu

Drupal Setup Guide

This Document explains how to install Drupal 8 in Ubuntu 16.04 LTS Server, along with installing and setting Apache 2, PHP and MySQL.

Installation Overview

Before installing Drupal 8, check the requirements on Drupal requirements. This guide uses Apache/2.4.18, PHP 7.0.8 , MySQL v5.7 as the development environment.

Note: Ubuntu 16.04 LTS Server includes Apache 2, PHP, MySQL by default, you can select to include them while installing the Ubuntu on your PC.

Before You Begin

  • The Drupal installation consists the usage of browser, so you should have GUI (instead of pure CLI interface) first. For Ubuntu 16.04 LTS Server does NOT contain a GUI interface, you may pick KDE, Gnome, Lxde as Desktop Environment first.
  • Most command below needs the sudo permission, if the terminal returns Permission denied, remember to use sudo as possible.

Install MySQL, Apache2, PHP

MySQL

  • Install MySQL

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    # sudo apt-get update
    # sudo apt-get install mysql-server
    # sudo apt-get install mysql-client-core5.7
    ```
    *Note: remember to set root password while installing mysql-server*
    * Config MySQL
    * Remember setup MySQL user and password after installation.
    * Log into MySQL server with `mysql -u root -p`, enter the
    * Create a database. You can create datebase with any name you like(assuming '**drupal**' here).
    CREATE DATABASE drupal;
    
    1
    2
    3
    #### Apache2
    * Install Apache2

    sudo apt-get update

    sudo apt-get install apache2

    1
    2
    3
    4
    5
    6
    7
    8
    *Note: you can check the Apache running by visiting the `http://localhost`. If a 'Apache2 Ubuntu Default Page' shows, the Apache server works.*
    * Config Apache2
    * mod\_rewrite
    To enable mod_rewrite:
        # sudo a2enmod rewrite
        # sudo service apache2 restart
    
    1
    2
    3
    4
    5
    6
    7
    *Note: the command a2enmod rewrite is unique to the Debian Linux based systems.*
    * clean\_urls
    Assuming to set `/var/www/` as the folder to install Drupal 8.
    To get clean URLs working, modify `/etc/apache2/apache2.conf`, the result should be like
    <Directory /var/www/> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory>
    1
    2
    3
    4
    5
    6
    (otherwise the .htaccess file won't take effect.)
    After modify the config file, remember to restarting the apache2 server with `sudo service apache2 restart`
    *Note: Also you should change the permission of `/var/www/` folder using `# sudo chmod 777 /var/www/` for the installation of Drupal 8.*
    #### PHP

    sudo apt-get update

    sudo apt-get install php php-gd php-dom php-simplexml php-xml php-mysql

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    After installing`php-gd php-dom php-simplexml php-xml` extensions, remember to reboot the computer to make sure the extension makes effect.
    *Note: To make sure PHP works, you can create a `info.php` in `/var/www/html/` using `echo "<?php phpinfo(); ?>" > /var/www/html/info.php`, then visit `http://localhost/info.php`. If a PHP info page shows up, PHP works on your PC.*
    Install Drupal 8
    ---
    * Download Drupal 8 from [Download & Extend](https://www.drupal.org/download).
    * After download the file `drupal-8.2.1.tar.gz`, extract the file(you will get `drupal-8.2.1`),rename it as `drupal` and move it into `/var/www/html/`.
    * Open the browser, visit `http://localhost/drupal/`, and you will see a brand new GUI SETUP interface like:
    ![](http://imgur.com/IocReLZ.jpg)
    Choose English.
    ![](http://imgur.com/s6oaQXZ.jpg)
    Select Standard.
    *Note: you may face some problems while the verify requirements step, try checking the Troubleshoot to solve them*
    ![](http://imgur.com/SXUAQTY.jpg)
    Fill in the Database name and username as set before.
    ![](http://imgur.com/5zTFAAh.jpg)
    Happy installing :)
    ![](http://imgur.com/Vhbzecq.jpg)
    After installation completes, you will configure site as you like.
    ![](http://imgur.com/8LEYBob.jpg)
    After all the things set up, the site should be like this.
    Enjoy it!
    Troubleshoot
    ---
    ### Why I can not extract the drupal-8.2.1.tar.gz file
    Extract it with `tar -zxvf drupal-x.y.z.tar.gz` (considering `x.y.z` is the version you downloaded.)
    ### Why I can not move the folder to `/var/www/html/`
    Use`sudo mv ~/Downloads/drupal /var/www/html/drupal`
    ### When I visit 'http://localhost/info.php', nothing shows up.
    Execute `sudo apt-get install libapache2-mod-php` in the command line.
    ### When I visit `http://localhost/drupal/`, it only shows `handle($request) $response- send() $kernel- terminate($request $response);`
    make sure you have install `php-gd`, which is a php graphics
    library.
    ### Why I meet with a File system warnup during Verify requirements
    Create a folder as `/var/www/html/drupal/sites/default/files`, then grant it the permission by using the following commands.

cd /var/www/html/drupal/sites/default/
sudo mkdir files
sudo chmod 777 files

1
2
### Why I meet with a Settings file warnup during Verify reuqirements
Copy the `default.settings.php` to `settings.php` in `/var/www/html/drupal/sites/default/`, then grant it the permission to be modified by using the following commands.

cd /var/www/html/drupal/sites/default/

sudo cp default.settings.php setttings.php

sudo chmod 777 settings.php

```