How To Install Deluge on Ubuntu 18.04 LTS

Install Deluge on Ubuntu 18

Deluge is a popular multi-platform bittorrent client often used to provide torrenting / seedbox functionality on Linux servers. Like rTorrent, deluge uses libtorrent as its backend. Supported by daemon-service, awesome interface, and great plugin support, Deluge surpass Transmission and rTorrent for functionality.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation Deluge bittorrent client on an Ubuntu 18.04 Bionic Beaver server.

Install Deluge on Ubuntu 18.04 LTS Bionic Beaver

Step 1. First make sure that all your system packages are up-to-date by running these following apt-get commands in the terminal.

sudo apt-get update
sudo apt-get upgrade

Step 2. Installing Deluge on Ubuntu 18.04 LTS.

Use the following command to install Deluge daemon and Deluge Web interface on Ubuntu 18.04 server:

sudo add-apt-repository ppa:deluge-team/ppa
sudo apt install deluged deluge-webui

Then create the Deluge user and group:

sudo adduser --system --group deluge
sudo gpasswd -a wpcademy deluge

Step 3. Create Systemd Service.

Create a systemd service file for deluge with your favourite text editor such as nano:

nano /etc/systemd/system/deluged.service

Add following lines:

[Unit]
Description=Deluge Bittorrent Client Daemon
After=network-online.target

[Service]
Type=simple
User=deluge
Group=deluge
UMask=007

ExecStart=/usr/bin/deluged -d

Restart=on-failure

# Configures the time to wait before service is stopped forcefully.
TimeoutStopSec=300

[Install]
WantedBy=multi-user.target

Now start deluge deamon with the following command:

systemctl start deluged
systemctl enable deluged

Next, we create a systemd service file for deluge web:

nano /etc/systemd/system/deluge-web.service

Add following lines:

[Unit]
Description=Deluge Bittorrent Client Web Interface
After=network-online.target

[Service]
Type=simple

User=deluge
Group=deluge
UMask=027

ExecStart=/usr/bin/deluge-web

Restart=on-failure

[Install]
WantedBy=multi-user.target

Save and close the file also start and enable deluge-web:

systemctl start deluge-web
systemctl enable deluge-web

Step 4. Accessing Deluge.

Deluge will be available on HTTP port 8112 by default. Open your favorite browser and navigate to http://yourdomain.com:8112 or http://server-ip:8112. The default password for deluge is deluge, better change it when you are first to login.

Congratulation’s! You have successfully installed Deluge. Thanks for using this tutorial for installing Deluge bittorrent client on your Ubuntu 18.04 LTS system. For additional help or useful information, we recommend you to check the official Deluge web site.

How To Install Yarn on Ubuntu 18.04 LTS

Install Yarn on Ubuntu 18

Yarn is an advanced package management software for Node.js applications. It is a fast, secure, and reliable alternative that any other Nodejs package manager’s.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation R open source programming language on an Ubuntu 18.04 Bionic Beaver server.

Install Yarn on Ubuntu 18.04 LTS Bionic Beaver

Step 1. First make sure that all your system packages are up-to-date by running these following apt-get commands in the terminal.

sudo apt-get update
sudo apt-get upgrade
[php]



<strong> Step 2. Installing Yarn on Ubuntu 18.04 LTS.
</strong>

First, Yarn repository and import the repository’s GPG key:

[php]
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

Next, update the package index and install Yarn using following command:

sudo apt-get update
sudo apt-get install yarn

If using nvm you can avoid the node installation by doing:

sudo apt install --no-install-recommends yarn

Verify the installation:

yarn --version

Step 3. Using Yarn.

Create a new Yarn project use yarn init:

yarn init my_yarn_wpcademy

Adding dependency:

yarn add [package_name]

Upgrading dependency:

yarn upgrade [package_name]
yarn upgrade [package_name]@[version_or_tag]

Installing all project dependencies:

yarn

Congratulation’s! You have successfully installed Yarn. Thanks for using this tutorial for installing Yarn on your Ubuntu 18.04 LTS Bionic Beaver. For additional help or useful information, we recommend you to check the official Yarn web site.

How To Install VNC Server on Ubuntu 18.04 LTS

Install VNC Server on Ubuntu 18

VNC (Virtual Network Computing) server is a free and open source software which is designed for allowing remote access to the Desktop Environment of the server to the VNC Client whereas VNC viewer is used on remote computer to connect to the server .

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation VNC Server on an Ubuntu 18.04 Bionic Beaver server.

Install VNC Server on Ubuntu 18.04 LTS Bionic Beaver

Step 1. First make sure that all your system packages are up-to-date by running these following apt-get commands in the terminal.

sudo apt-get update
sudo apt-get upgrade
[php]

<strong> Step 2. Installing VNC Server on Ubuntu 18.04 LTS.</strong>

First, type the following command to install Xfce on your server:
[php]
sudo apt install xfce4 xfce4-goodies xorg dbus-x11 x11-xserver-utils

Next, install TigerVNC on your Ubuntu server:

sudo apt install tigervnc-standalone-server tigervnc-common

Once installed the next step is to run the vncserver command which will create the initial configuration and set up the password:

vncserver

Result:

You will require a password to access your desktops.

Password:
Verify:
Would you like to enter a view-only password (y/n)? n
/usr/bin/xauth:  file /home/chedelics/.Xauthority does not exist

New 'server2.wpcademy.com:1 (chedelics)' desktop at :1 on machine server2.wpcademy.com
Starting applications specified in /etc/X11/Xvnc-session
Log file is /home/chedelics/.vnc/server2.wpcademy.com:1.log

Use xtigervncviewer -SecurityTypes VncAuth -passwd /home/chedelics/.vnc/passwd :1 to connect to the VNC server.

After VNC Server started and created some of it’s files. We are now can turn it off to modify the xstartup file (startup script) to make it start with xfce4:

vncserver -kill :1
[php]

<strong> Step 3. Configuring VNC Server. </strong>

First, create the following file:
[php]
~/.vnc/xstartup

Add following files:

#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
exec startxfce4

Next, Run the following command to make sure permissions are correct:

chmod u+x ~/.vnc/xstartup

Step 4. Creating a Systemd unit file.

The next step is to create VNC Server statup script:

/etc/systemd/system/[email protected]

Add following files:

[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[Service]
Type=simple
User=chedelics
PAMName=login
PIDFile=/home/%u/.vnc/%H%i.pid
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill :%i > /dev/null 2>&1 || :'
ExecStart=/usr/bin/vncserver :%i -geometry 1440x900 -alwaysshared -fg
ExecStop=/usr/bin/vncserver -kill :%i

[Install]
WantedBy=multi-user.target

The next step is to enable the unit file with the following command:

sudo systemctl daemon-reload
sudo systemctl enable [email protected]
sudo systemctl start [email protected]

Step 4. Connecting to VNC server.

To access remote desktop on vnc server from windows system, you must have vnc viewer installed on your system. There are various vnc viewer available to use. Download any one and install on your system, for example:

TightVNC
RealVNC
TigerVNC

tightvnc-connection

Congratulation’s! You have successfully installed VNC Server. Thanks for using this tutorial for installing VNC Server on your Ubuntu 18.04 LTS Bionic Beaver. For additional help or useful information, we recommend you to check the official VNC web site.

How To Install Vagrant on Ubuntu 18.04 LTS

Install Vagrant on Ubuntu 18

Vagrant is an open source tool for building an entire virtual development environment. Frequently, a test environment is needed for analyzing the latest release and new tools. Also, it reduces the time spent on re-building that your OS. By default, vagrant uses virtualbox for managing the Virtualization. Vagrant acts as the fundamental configuration for managing/deploying multiple reproducible virtual environments with the same configuration.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation Vagrant virtual development environment on an Ubuntu 18.04 Bionic Beaver server.

Install Vagrant on Ubuntu 18.04 LTS Bionic Beaver

 

Step 1. First make sure that all your system packages are up-to-date by running these following apt-get commands in the terminal.

sudo apt-get update
sudo apt-get upgrade

Step 2. Installing VirtualBox.

Install Virtualbox from the terminal using following command:
[/php]
apt install virtualbox


<strong> Step 3. Installing Vagrant on Ubuntu 18.04 LTS.
</strong>
Install Vagrant from the terminal using following command:

[php]
apt install vagrant

To verify that the installation was successful run the following command which will print the Vagrant version:

vagrant --version

Step 4. Deploy your development environment.

Vagrant can quickly deploy the development environment. The following command will install precise32 box from the vagrant website. A box is nothing more then a specially packaged image that can later be used to provision a server:

vagrant box add precise32 http://files.vagrantup.com/precise32.box

Create a root directory for your Project. Then create a vagrant file in this folder by calling ‘vagrant init’, which will be the central file for the project configuration:

mkdir vagrant_project_wpcademy
cd vagrant_project wpcademy
vagrant init

Edit the Vagrantfile in this directory and replace:

config.vm.box = "precise32"

Start Environment:

vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'precise32'...
[default] Matching MAC address for NAT networking...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...

Congratulation’s! You have successfully installed Vagrant. Thanks for using this tutorial for installing Vagrant virtual development environment on your Ubuntu 18.04 LTS Bionic Beaver system. For additional help or useful information, we recommend you to check the official Vagrant web site.

How To Install Nagios on Ubuntu 18.04 LTS

Install Nagios on Ubuntu 18

Nagios is an open source software that can be used for network and infrastructure monitoring. Nagios will monitor servers, switches, applications and services. It alerts the System Administrator when something went wrong and also alerts back when the issues has been rectified. Resources that can be monitored include CPU, memory and disk space loads, log files, temperature or hardware errors. It can monitor various parameters and problems for services like HTTP, SMTP, DNS, and with the help of plugins it can be highly extended. Nagios core was originally designed to run under Linux, although it should work under most other unices as well.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation Nagios on a Ubuntu 18.04 (Bionic Beaver) server.

Install Nagios on Ubuntu 18.04 LTS Bionic Beaver

Step 1. First make sure that all your system packages are up-to-date by running these following apt-get commands in the terminal.

sudo apt-get update
sudo apt-get upgrade
[php]

<strong> Step 2. Install LAMP (Linux, Apache, MariaDB and PHP) server.</strong>

A Ubuntu 18.04 LAMP server is required. If you do not have LAMP installed, you can follow our guide here. Also install all required PHP modules:
[php]
apt-get install php7.1-cli php7.1-mbstring php7.1-gd php7.1-opcache php7.1-mysql php7.1-json php7.1-mcrypt php7.1-xml php7.1-curl

Step 3. Create users and groups for Nagios.

For security reasons, create a user and group specifically to run Nagios:

useradd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagcmd www-data

Step 4. Installing Nagios and plugins on Ubuntu 18.04 LTS.

First thing to do is to go to Nagios’s download page and download the latest stable version of Nagios, At the moment of writing this article it is version 4.4.2:
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.2.tar.gz
tar -zxvf /tmp/nagios-4.4.2.tar.gz
cd /tmp/nagios-4.4.2/

Perform below steps to compile the Nagios from the source code:

./configure --with-nagios-group=nagios --with-command-group=nagcmd --with-httpd_conf=/etc/apache2/sites-enabled/
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf

Next steps, Download latest nagios-plugins source and install using following commands:

wget http://www.nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz
tar xzf nagios-plugins-2.1.1.tar.gz
cd nagios-plugins-2.1.1
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install

Step 5. Configure Nagios on Ubuntu 18.04 Bionic Beaver.

Edit the /usr/local/nagios/etc/objects/contacts.cfg config file with your favorite editor and change the email address associated with the nagiosadmin contact definition to the address you’d like to use for receiving alerts.

nano /usr/local/nagios/etc/objects/contacts.cfg

Change the email address field to receive the notification:

[...]
define contact{
contact_name nagiosadmin ; Short name of userus
generic-contact ; Inherit default values from generic-contact template (defined above)
alias Nagios Admin ; Full name of useremail
[email protected] ; <<=== CHANGE THIS TO YOUR EMAIL ADDRESS ===
[...]

Step 6. Configure Apache web server for Nagios.

Now create nagios apache2 configuration file:

nano /etc/apache2/sites-enabled/nagios.conf

Edit the following lines if you want to access nagios administrative console from a particular IP series, Here, I want to allow nagios administrative access from 192.168.1.0/24 series only:

[...]
## Comment the following lines ##
#   Order allow,deny
#   Allow from all

## Uncomment and Change lines as shown below ##
Order deny,allow
Deny from all
Allow from 127.0.0.1 192.168.1.0/24
[...]

Enable Apache’s rewrite and cgi modules:

sudo a2enmod rewrite
sudo a2enmod cgi

Configure Apache authentication:

We need to setup the password for the user nagiosadmin. This username will be used to access the web interface so it is important to remember the password that you will input here. Set the password running the following command and enter the password twice:

# sudo htpasswd -s -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin

Restart Apache for the changes to take effect:

systemctl restart apache2

Step 7. Verify and Start Nagios service.

Next we have to make Nagios start at boot time, so first verify that the configuration file has no errors running the following command:

sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

And you should get the output:

[...]
Checking objects...
    Checked 8 services.
    Checked 1 hosts.
    Checked 1 host groups.
    Checked 0 service groups.
    Checked 1 contacts.
    Checked 1 contact groups.
    Checked 24 commands.
    Checked 5 time periods.
    Checked 0 host escalations.
    Checked 0 service escalations.
Checking for circular paths...
    Checked 1 hosts
    Checked 0 service dependencies
    Checked 0 host dependencies
    Checked 5 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors:   0

Things look okay - No serious problems were detected during the pre-flight check
[...]

Ubuntu 18.04 uses systemd for starting / stopping all the services, so, we need to create nagios.service file:

nano /etc/systemd/system/nagios.service

Add the following lines:

[Unit]
Description=Nagios
BindTo=network.target

[Install]
WantedBy=multi-user.target

[Service]
User=nagios
Group=nagios
Type=simple
ExecStart=/usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg

Enable Nagios to start automatically at system startup:

systemctl enable /etc/systemd/system/nagios.service

Now, start Nagios service:

systemctl start nagios

Step 8. Accessing Nagios.

Nagios will be available on HTTP port 80 by default. Open your favorite browser and navigate to http://your-domain.com/nagios or http://server-ip/nagios and complete the required the steps to finish the installation. When prompted for username and password you will introduce the username “nagiosadmin” and the password that you entered in step 6.
Nagios-admin-panel
Congratulation’s! You have successfully installed Nagios. Thanks for using this tutorial for installting Nagios monitoring tool in ubuntu 18.04 (Bionic Beaver) systems. For additional help or useful information, we recommend you to check the official Nagios web site.

How To Install ELK Stack on Ubuntu 18.04 LTS

Install ELK Stack on Ubuntu 18

ELK stack is a popular, open source log management platform. It is used as a centralized management for storing, analyzing and viewing of logs. Centralized management makes it easier to study the logs and identify issues if any for any number of servers.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation ELK Stack on an Ubuntu 18.04 Bionic Beaver server.

Install ELK Stack on Ubuntu 18.04 LTS Bionic Beaver

Step 1. First make sure that all your system packages are up-to-date by running these following apt-get commands in the terminal.

sudo apt-get update
sudo apt-get upgrade

Step 2. Installing Java on Ubuntu 18.04 LTS.

Now install the Java by using the following command:

apt -y install oracle-java8-installer

Next, you can also set the JAVA_HOME and other defaults by installing oracle-java8-set-default:

apt -y install oracle-java8-set-default

Then, You can now verify if the JAVA_HOME variable is set by running:

echo "$JAVA_HOME"

Verify the Java version:

[[email protected] ~]# java -version
openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-8u181-b11-1~deb9u1-b11)
OpenJDK 64-Bit Server VM (build 25.181-b11, mixed mode)

Step 3. Installing Elasticsearch on Ubuntu 18.04 LTS.

First, install Elasticsearch using the apt package manager from the official Elastic repository:

wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
echo "deb http://packages.elastic.co/elasticsearch/2.x/debian stable main" | sudo tee -a /etc/apt/sources.list.d/elasticsearch-2.x.list
apt-get update

Then, install Elasticsearch with apt using the following command:

apt-get -y install elasticsearch

Start the Elasticsearch service and set it to automatically start on boot:

systemctl restart elasticsearch
systemctl enable elasticsearch

Elasticsearch is now installed. Edit it’s configurations now, using following commands:

nano /etc/elasticsearch/elasticsearch.yml

Step 4. Installing Kibana on Ubuntu 18.04 LTS.

First, create the Kibana source list:

echo "deb http://packages.elastic.co/kibana/4.5/debian stable main" | sudo tee -a /etc/apt/sources.list.d/kibana-4.5.x.list

Now install Kibana with this command:

apt-get update
apt-get -y install kibana

Once the installation is completed, open the kibana.yml file and restrict the remote access to the Kibana instance:

nano /etc/kibana/kibana.yml

# Specifies the address to which the Kibana server will bind. IP addresses and host names are both valid values.
# The default is 'localhost', which usually means remote machines will not be able to connect.
# To allow connections from remote users, set this parameter to a non-loopback address.
server.host: "localhost"

Start the Kibana service and set it to start automatically on boot:

systemctl start kibana
systemctl enable kibana

Step 5. Installing Logstash on Ubuntu 18.04 LTS.

First, create the Logstash source list:

echo 'deb http://packages.elastic.co/logstash/2.2/debian stable main' | sudo tee /etc/apt/sources.list.d/logstash-2.2.x.list

Next, Install Logstash using the apt package manager:

apt-get install logstash

Once the Logstash package is installed start the Logstash service and set it to start automatically on boot:

systemctl restart logstash
systemctl enable logstash

Step 6. Install and configure Nginx as a reverse proxy.

Next, use Nginx as a reverse proxy to access Kibana from the public IP address. To install Nginx, run:

apt-get install nginx

Create a basic authentication file with the openssl command:

echo "admin:`openssl passwd -apr1 YourPasswd`" | sudo tee -a /etc/nginx/htpasswd.kibana

Then, create a virtual host configuration file for the Kibana instance:

rm -f /etc/nginx/sites-enabled/default
nano /etc/nginx/sites-available/kibana
rm-f/etc/nginx/sites-enabled/default
nano/etc/nginx/sites-available/kibana
server {
listen 80 default_server;
server_name _;
return 301 https://$server_name$request_uri;
}

server {
listen 443 default_server ssl http2;

server_name _;

ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem;
ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key;
ssl_session_cache shared:SSL:10m;

auth_basic "Restricted Access";
auth_basic_user_file /etc/nginx/htpasswd.kibana;

location / {
proxy_pass http://localhost:5601;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}

Creating a symbolic link and test the Nginx configuration:

ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/kibana
nginx -t

Restart the Nginx service and set it to start automatically on boot:

systemctl restart nginx
systemctl enable nginx

Step 7. Accessing Kibana.

You can now access the kibana interface by opening your browser and typing:

https://Your-IpAddress

Congratulation’s! You have successfully installed ELK Stack. Thanks for using this tutorial for installing ELK Stack on your Ubuntu 18.04 LTS Bionic Beaver. For additional help or useful information, we recommend you to check the official ELK Stack web site.

How To Install Varnish Cache on Ubuntu 18.04 LTS

Varnish Cache on Ubuntu 18

Varnish Cache is a powerful open source HTTP accelerator that can be installed in front of any Webserver such as Apache or Nginx. Varnish Cache can improve overall performance of your web server by caching contents. The Varnish cache stores the copy of user request’s and serves the same page when the user revisits the webpage. It makes your website really fast and accelerate your web site performance up-to 300 – 1000x (means 80% or more).

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation Varnish Cache on a Ubuntu 18.04 (Bionic Beaver) server.

Install Varnish Cache on Ubuntu 18.04 LTS Bionic Beaver

Step 1. First make sure that all your system packages are up-to-date by running these following apt-get commands in the terminal.

sudo apt-get update
sudo apt-get upgrade

Step 2. Install Apache web server.

For this part we will be assuming that you have already installed Apache on your server and have it running properly. If not write this command in your terminal:

sudo apt-get install apache2

Step 3. Installing Varnish on Ubuntu 18.04 LTS.

Install Varnish using apt-get command:

apt-get install varnish

After the installation is finished, start and enable varnish.service using the systemctl command:

systemctl start varnish.service
systemctl enable varnish.service

Step 4. Configuring Varnish Cache on Ubuntu 18.04 Bionic Beaver.

Varnish is automatically configured to server content over port 80 and fetch contents from Apache on port 8080, we need to update Apache to serve content over port 8080:

# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf

NameVirtualHost 127.0.0.1:8080
Listen 127.0.0.1:8080

If you have any virtual hosts configured, you will need to update these as well – ensure your configuration looks like this:

<VirtualHost 127.0.0.1:8080>

We need to configure varnish to run on port 80. First, create a file called varnish.service inside the /etc/systemd/system directory:

### nano /etc/systemd/system/varnish.service

Then, add the following configuration:

[Service]
ExecStart=/usr/sbin/varnishd -j unix,user=vcache -F -a :80 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret -s malloc,256m

Once you save and exit out of that file, open up the default.vcl file:

### nano /etc/varnish/default.vcl
backend default {
    .host = "127.0.0.1";
    .port = "8080";
}

Restart the Apache and Varnish service for the changes to take effect:

systemctl restart apache2.service
systemctl restart varnish.service

You can check to see if varnish is working by typing the following command:

varnishstat

Step 5. Testing Varnish.

The test consists in making a HTTP request via curl and verifying that it is handled by Varnish:

[[email protected] ~ ]# curl -I 192.168.10.100
 HTTP/1.1 403 Forbidden
 Date: Mon, 17 March 2018 24:06:10 GMT
 Server: Apache/2.4.6 (Ubuntu) PHP/7.0.16
 Last-Modified: Thu, 16 Dec 2017 19:30:58 GMT
 ETag: "1321-5758ramona728280"
 Accept-Ranges: bytes
 Content-Length: 4897
 Content-Type: text/html; charset=UTF-8
 X-Varnish: 32779
 Age: 4
 Via: 1.1 varnish-v5
 Connection: keep-alive

Congratulation’s! You have successfully installed Varnish. Thanks for using this tutorial for installing Varnish Cache on Ubuntu 18.04 LTS (Bionic Beaver) system. For additional help or useful information, we recommend you to check the official Varnish web site.

[youtube https://www.youtube.com/watch?v=fGD14ChpcL4]