How to Install & Config Drupal 8 on Ubuntu 14.04 + Ngnix

| Drupal Development | 0 seen

In this article I will provide information how to install latest Drupal 8 version on Ubuntu 14.04 machine with Nginx.

Tools involved: Putty, Notepad++

I assume you have already configured Nginx on your machine, if not, here is a tutorial for LEMP Server Ubuntu 12.04 for serving Drupal on Nginx, don't be afraid of version 12.04, as in version 14.04 the only differences that might occur are in Ngnix config blocks, which I will cover in this article.

If you are looking for a great VPS server, try Linode, I have been using it for more than 4 years and can only highly recommend, their VPS starts $10/mo.

Now, once you have all set up, open Putty and login to your server with sudo privileges:

Add new virtual domain

sudo mkdir -p /srv/www/{public_html,logs}
sudo usermod -a -G www-data admin
sudo chown -R www-data:www-data /srv/www
sudo chmod -R 775 /srv/www/ sudo

Make sure you change admin in second row to your username

Configure Nginx to serve Drupal 8

Add a new server_name

sudo nano /opt/etc/nginx/sites-available/

copy/paste code bellow (make sure you change to your actual domain name)

server {
        listen   80; ## listen for ipv4; this line is default and implied
        #listen   [::]:80 default ipv6only=on; ## listen for ipv6
        # This is the full path to your index file 
        root /srv/www/;
access_log /srv/www/;
error_log /srv/www/;
        # Make site accessible from http://localhost/
        # This will be your domain name

location = /favicon.ico {
    log_not_found off;
    access_log off;
  location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
  # This matters if you use drush
  location = /backup {
    deny all;
  # Very rarely should these ever be accessed outside of your lan
  location ~* \.(txt|log)$ {
    deny all;
rewrite ^/core/authorize.php/core/authorize.php(.*)$ /core/authorize.php$1;
  location ~ \..*/.*\.php$ {
    return 403;
  location / {
    # This is cool because no php is touched for static content
    try_files $uri @rewrite;
  location @rewrite {
    # Some modules enforce no slash (/) at the end of the URL
    # Else this rewrite block wouldn't be needed (GlobalRedirect)
    rewrite ^/(.*)$ /index.php?q=$1;
  location ~ \.php$|^/update.php {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
    include fastcgi_params;
 fastcgi_index index.php;    
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_intercept_errors on;

    # Set cache key to include identifying components

    fastcgi_cache_valid 200 301 15s;
    fastcgi_cache_valid 302     1m;
    fastcgi_cache_valid 404     1s;
    fastcgi_cache_min_uses 1;
    fastcgi_cache_use_stale error timeout invalid_header updating http_500;
    fastcgi_ignore_headers Cache-Control Expires;
    fastcgi_pass_header Set-Cookie;
    fastcgi_pass_header Cookie;
    ## Add a cache miss/hit status header.
    add_header X-Micro-Cache $upstream_cache_status;
    ## To avoid any interaction with the cache control headers we expire
    ## everything on this location immediately.
    expires epoch;
    ## Cache locking mechanism for protecting the backend of too many
    ## simultaneous requests.
    fastcgi_cache_lock on;
  location ~* ^(?!/system/files).*\.(js|css|png|jpg|jpeg|gif|ico|ttf|svg)$ {
    ## If the image does not exist, maybe it must be generated by drupal (imagecache)
    try_files $uri @rewrite;
    expires 7d;
    log_not_found off;

  ## private files protection
  location ~ ^/sites/.*/private/ {
    access_log off;
    deny all;

CTRL+O and Enter CTRL+X to exit

Make a symlink

sudo ln -s /opt/etc/nginx/sites-available/ /opt/etc/nginx/sites-enabled

Restart Nginx

sudo /etc/init.d/nginx restart

Download Drupal 8

I'm going to use wget to download latest Drupal 8 version (as of writing: 8.2.1)

cd /srv/www/
sudo wget
sudo tar -xvzf drupal-8.2.1.tar.gz
sudo cp drupal-8.2.1/* public_html/ -R
sudo chown www-data:www-data public_html -R

Now, open phpMyAdmin and create a new database (we will need latter)

Next, you should point your DNS entries, allow them to populate and visit your site via the browser (you can cheat this by entering your domain name and IP in Windows hosts file)

Open your domain name

You should see following screen:

Drupal 8 install screen

Drupal 8 install screen

You can choose which language to set your Drupal installation, decide and click on Save and Continue

Choose Drupal vesrion

Choose Drupal version

You can choose to install Standard on Minimal. If you are new to Drupal and just exploring, Standard will be fine. If you will choose Minimal - that's fine too, but you will need later to define your content types et.c. Standard will suit in 90% cases. Once you have decided, click on Save and Continue.

Drupal database configuration

Drupal database configuration

Enter details for your database (you created it via phpMyAdmin). Again, Save and Continue

It might take some time (about a minute) while Drupal will finish installation, and you will be prompted with the final window, asking to enter site maintenance and other details.

Drupal Site Configuration

Drupal Site Configuration

Here you should give your site a name, enter administrator email address and choose Username (don't use admin, use something generic)

Congrats, you just finished Drupal 8 installation!

Default Drupal 8 homepage

Default Drupal 8 homepage

Happy Drupalling!