Drupal performs great with caching proxy servers like Varnish. When looking for an easy way to speed up your Drupal websites the steps below are a good place to start. When dealing with high-traffic Drupal websites or blogs you may want to implement some kind of caching mechanism to speed up the sites. One of the popular proxy servers that are also caching servers is Varnish. If you want to build a fast Drupal site with lots of web traffic, setting up Varnish as a proxy caching server will go a long way.

How to install Drupal CMS with Nginx and Varnish support on Ubuntu Linux

As described above, Drupal performs great with caching proxy servers like Varnish. When looking for an easy way to speed up your Drupal websites the steps below are a good place to start. Below is how to do that on Ubuntu Linux.

Install Nginx

To install Nginx, run the commands below Next, run the commands below to stop, start and enable the Nginx service to always start up with the server boots.

Install Varnish

Now that Nginx is installed, run the commands below to install Varnish After installing Varnish, the commands below can be used to start, stop and enable Varnish to always start up when the server boots

Switch port to 8080

Nginx listens on port 80 by default. Since we want Varnish to listen for all traffic coming to port 80, let’s configure Nginx to use another port number. Then make the highlighted change below. Save the file and exit. After that, run the commands below to disable the Nginx default site. Then restart Nginx Now Nginx default site is disabled.

Install MariaDB

To install MariaDB run the commands below After installing, the commands below can be used to stop, start and enable the MariaDB service to always start up when the server boots. After that, run the commands below to secure the MariaDB server by creating a root password and disallowing remote root access. sudo mysql_secure_installation When prompted, answer the questions below by following the guide.

Enter current password for root (enter for none): Just press the Enter Set root password? [Y/n]: Y New password: Enter password Re-enter new password: Repeat password Remove anonymous users? [Y/n]: Y Disallow root login remotely? [Y/n]: Y Remove test database and access to it? [Y/n]:  Y Reload privilege tables now? [Y/n]:  Y

PHP 7.1 isn’t available on Ubuntu’s default repositories. To install it, you will have to get it from third-party repositories. Run the commands below to add the below third-party repository to upgrade to PHP 7.1 Then update and upgrade to PHP 7.1 Run the commands below to install PHP 7.1 and related modules. After installing PHP 7.1, run the commands below to open the FPM PHP default file. Then make the changes on the following lines below in the file and save. The value below is great setting to apply in your environments.

Create Drupal Database

Now that you’ve installed all the packages are installed, run the commands below to create a blank Drupal database. Login to the MariaDB database server Then create a database called drupal Create a database user called drupaluser with a new password Then grant the user full access to the database. Finally, save your changes and exit.

Download Drupal Latest Release

Next, visit the Drupal site and download the latest package. or run the commands below to download and extract Drupal content. After downloading, run the commands below to extract the downloaded file and move it into a new Drupal root directory. Then run the commands below to set the correct permissions for Drupal to function properly.

Configure the Nginx server block

Finally, configure the Nginx server block configuration file for Drupal. This file will control how users access Drupal content. Run the commands below to create a new configuration file called drupal Then copy and paste the content below into the file and save it. Replace the highlighted line with your domain name and directory root location. Save the file and exit.

Enable the server block

After configuring the server block above, enable it by running the commands below To load all the settings above, restart Nginx by running the commands below.

Configure Varnish to use port 80

Now that port 80 is free, let’s configure Varnish to use that post instead. To assign port 80 to Varnish, run the commands below. Varnish default configure file is located at /etc/default/varnish Open it by running the commands below: Then look for the config block under Alternative 2 and make the highlighted changes as shown below. Save the file when you’re done. Next, run the commands below to open the default.vcl file Then add the highlighted lines shown below under sub vcl_recv and sub vcl_backend_response Save the file and close. When you’re done, restart Varnish and Nginx Next, run the commands below to start Varnish if it won’t start. After that, open your browser and browse your domain name to launch the WordPress configuration wizard. And you should see the WordPress setup wizard Follow the wizard until you’ve successfully set up WordPress. That’s it!