Question

Configure Varnish with Apache on Ubuntu 14.04

  • Posted November 13, 2014

Hi

How can i install and configure Varnish to work whit Apache on Ubuntu 14.04?

Subscribe
Share

I followed these instructions and my site is being served however I’m not seeing any varnish headers. Am I missing a step?

Thanx

This comment has been deleted


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Configuring Varnish to work with Apache on Ubuntu 14.04 is largely similar to this article covering 12.04.

I just ran through a basic set up on 14.04. The first step is to install Apache and Varnish:

sudo apt-get install varnish apache2

Then we need to configure Varnish to listen on port 80. Edit the file /etc/default/varnish Find the section begin with “Alternative 2, Configuration with VCL” Make sure it’s uncommented and update the port:

DAEMON_OPTS="-a :80 \
             -T localhost:6082 \
             -f /etc/varnish/default.vcl \
             -S /etc/varnish/secret \
             -s malloc,256m"

Next we need to adjust Apache to listen on port 8080. Edit /etc/apache2/ports.conf and change Listen 80 to Listen 8080 Then edit /etc/apache2/sites-enabled/000-default.conf and change <VirtualHost *:80> to <VirtualHost *:8080>

Finally, restart Varnish and Apache with:

sudo service apache2 restart
sudo service varnish restart

Varnish is now sitting in front of Apache and serving cached content.

Configuring Varnish to work with Apache on Ubuntu 14.04 is largely similar to this article covering 12.04.

I just ran through a basic set up on 14.04. The first step is to install Apache and Varnish:

sudo apt-get install varnish apache2

Then we need to configure Varnish to listen on port 80. Edit the file /etc/default/varnish Find the section begin with “Alternative 2, Configuration with VCL” Make sure it’s uncommented and update the port:

DAEMON_OPTS="-a :80 \
             -T localhost:6082 \
             -f /etc/varnish/default.vcl \
             -S /etc/varnish/secret \
             -s malloc,256m"

Next we need to adjust Apache to listen on port 8080. Edit /etc/apache2/ports.conf and change Listen 80 to Listen 8080 Then edit /etc/apache2/sites-enabled/000-default.conf and change <VirtualHost *:80> to <VirtualHost *:8080>

Finally, restart Varnish and Apache with:

sudo service apache2 restart
sudo service varnish restart

Varnish is now sitting in front of Apache and serving cached content.

Configuring Varnish to work with Apache on Ubuntu 14.04 is largely similar to this article covering 12.04.

I just ran through a basic set up on 14.04. The first step is to install Apache and Varnish:

sudo apt-get install varnish apache2

Then we need to configure Varnish to listen on port 80. Edit the file /etc/default/varnish Find the section begin with “Alternative 2, Configuration with VCL” Make sure it’s uncommented and update the port:

DAEMON_OPTS="-a :80 \
             -T localhost:6082 \
             -f /etc/varnish/default.vcl \
             -S /etc/varnish/secret \
             -s malloc,256m"

Next we need to adjust Apache to listen on port 8080. Edit /etc/apache2/ports.conf and change Listen 80 to Listen 8080 Then edit /etc/apache2/sites-enabled/000-default.conf and change <VirtualHost *:80> to <VirtualHost *:8080>

Finally, restart Varnish and Apache with:

sudo service apache2 restart
sudo service varnish restart

Varnish is now sitting in front of Apache and serving cached content.

Configuring Varnish to work with Apache on Ubuntu 14.04 is largely similar to this article covering 12.04.

I just ran through a basic set up on 14.04. The first step is to install Apache and Varnish:

sudo apt-get install varnish apache2

Then we need to configure Varnish to listen on port 80. Edit the file /etc/default/varnish Find the section begin with “Alternative 2, Configuration with VCL” Make sure it’s uncommented and update the port:

DAEMON_OPTS="-a :80 \
             -T localhost:6082 \
             -f /etc/varnish/default.vcl \
             -S /etc/varnish/secret \
             -s malloc,256m"

Next we need to adjust Apache to listen on port 8080. Edit /etc/apache2/ports.conf and change Listen 80 to Listen 8080 Then edit /etc/apache2/sites-enabled/000-default.conf and change <VirtualHost *:80> to <VirtualHost *:8080>

Finally, restart Varnish and Apache with:

sudo service apache2 restart
sudo service varnish restart

Varnish is now sitting in front of Apache and serving cached content.

I’m using ubuntu 16 , and having link problems:

http://example.com/test is redirecting to http://example.com:8080/test and returning error :|

For Varnish to work on Ubuntu 15.04.

First grep:

If result is “/etc/systemd/system/multi-user.target.wants/varnish.service”

Change the ExecStart to this only.

Save and exit, restart Varnish.

systemctl restart varnish.service

@emshidiq I run multiple sites under one VPS and would like to know the answer too. Thanks for asking.