I have been trying to install Varnish on ubuntu 18.04. I have used this article https://hostadvice.com/how-to/how-to-setup-varnish-http-cache-on-an-ubuntu-18-04-vps-or-dedicated-server/,
after I run the command
curl -I http://localhost but I get the error curl: (7) Failed to connect to localhost port 80: Connection refused .
/etc/default/varnish
/etc/varnish/default.vcl
Results of curl -I http://localhost:8080
the output of
sudo service varnich restart is Failed to restart varnich.service: Unit varnich.service not found.
how can I resolve this problem ?
Naruto Uzumaki
Naruto UzumakiNaruto Uzumaki
2 Answers
Update
Based on the new info the problem is the Varnish VCL config. It's missing alot of information.
Here is an example VCL modified according to your setup
Replace the contents in your default.vcl with this and then restart Varnish.
There isn't any service listening on
localhost:80
Double check that Varnish is running
If Varnish is running then you have to check the Varnish config
Should print something like
Where the key is
-a :80
Also make sure that your
Varnish service have the same port config
Then try to restart Varnish
Tip
You can verify that Apache is working by curling on port
8080
Jacob RastadJacob Rastad
Your configuration is faulty to begin with.
In the DAEMON_OPTS you've set varnish to listen on port 80, while in the default.vcl you're configuring a backend for varnish which should listen on the same 80 port.
This will lead into a neverending loop.
In your case, you want to set apache as a backend for varnish. As you've configured apache to run on port 8080, you'll need to reflect this in the default.vcl
Do a
sudo service varnish restart afterwards.
Marius MMarius M
Not the answer you're looking for? Browse other questions tagged apacheubuntucachingvarnish or ask your own question.
If you want to install Varnish cache server on Ubuntu, you can quickly fire up the terminal and run the commands sudo apt install varnish… However, doing that will not install the latest version of Varnish cache on your systems….
If you need the latest version of Varnish, you’ll have to manually compile it yourself and install…. this post shows students and new users how to manually compile and install Varnish cache 6.0 which is the latest at the time of this post on Ubuntu 16.04 | 18.04 LTS servers…
Ubuntu 18.04.5
For this post, we’ll install Apache2 web server and configure it to listen on port 8080… then install Varnish and configure it to listen on port 80… Varnish will cache all requests for Apache2 pages when they are made….
To get this working, please follow the steps below:
Step 1: Install Apache2 HTTP Server
To install Apache2 on Ubuntu run the commands below….
After installing Apache2, the commands below can be used to stop, start and enable Apache2 to always startup everytime the server boots up.
By default apache2 HTTP service automatically is bond to port 80 and 443 for HTTPS. We want Varnish to communicate over port 80 instead… So continue below to configure Apache2 to talk on Port 8080…
To quickly change the port run the commands below to open Apache2 default port configuration file.
However, this method only works for owner-restricted PDFs and for files that are smaller than 5 MB. Open secure pdf files.
sudo nano /etc/apache2/ports.conf
Then make sure the file has these lines. Save when done.
Next, open Apache2 default virtualhost config file.
sudo nano /etc/apache2/sites-available/000-default.conf
Then make the highlighted change below.
<VirtualHost 127.0.0.1:8080>
Save then file and exit.
Then restart Apache2
sudo systemctl restart apache2.service
Now to access Apache2, you’ll have to enter the server IP or hostname followed by port # 8080.
ex. http://localhost:8080
Step 2: Installing Varnish 6.0
Now that Apache2 is installed and communicating over port 8080, follow the steps below to install the latest version of Varnish…
First install all dependencies for Varnish by running the commands below.
sudo apt-get install make automake autotools-dev libedit-dev libjemalloc-dev libncurses-dev libpcre3-dev libtool pkg-config python-docutils python-sphinx graphviz autoconf-archive curl git
Next, run the commands below to download Varnish package…
cd /tmp && git clone https://github.com/varnishcache/varnish-cache
How To Install Ubuntu 18.04
After that, change into varnish-cache folder and begin compiling…
Next, run the commands below to install Varnish cache…
sudo make install
It should take a few minutes for it to install… after that Varnish will now be installed in /usr/local. The varnishd binary is in /usr/local/sbin/varnishd. To make sure that the necessary links and caches of the most recent shared libraries are found, run
sudo ldconfig
If Varnish was successfully installed, run the commands below to start it….
sudo varnishd -a :80 -T localhost:6082 -b localhost:8080
That should do it… to test, run the commands below.
curl -I http://localhost
and you should see something like the text below:
Enjoy!
You may also like the post below:
Comments are closed.
|
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |