#!/bin/sh
sudo -i
apt update && apt upgrade
#Install Apache webserver
apt install apache2
systemctl start apache2
systemctl status apache2
#Being a webserver, Apache listens on port 80 by default. Use the netstat command as shown to verify this.
sudo netstat -pnltu
#Install Varnish HTTP Accelerator
apt install varnish
systemctl start varnish
systemctl status varnish
#Configuring Apache and Varnish HTTP Cache
nano /etc/apache2/ports.conf
listen to port 80 to 8080
nano /etc/apache2/sites-enabled/000-default.conf
listen to port 80 to 8080
systemctl restart apache2
#Setting up Varnish to listen to port 80
nano /etc/default/varnish
Scroll and locate the attribute ‘DAEMON_OPTS’. Be sure to change the port from 6081 to port 80
#If you check the /etc/varnish/default.vcl file, you should get the output shown below.
nano /etc/varnish/default.vcl
#Lastly, we need to edit the /lib/systemd/system/varnish.service and modify the port in ExecStart directive from port 6081 to 80.
nano /lib/systemd/system/varnish.service
Locate the ExecStart directive and change the port from port 6081 to 80.
systemctl restart apache2
systemctl daemon-reload
systemctl restart varnish
#Testing the Configuration
curl -I server_IP
Free Web Hosting