This tutorial will cover how to setup Varnish Cache to run in front of zPanel’s default web server, Apache, on either CentOS or Ubuntu server. As a refresh, Varnish Cache is an awesome web accelerator software making it possible to cache web content either in server’s RAM or disk (that’s up to you) so the web request can even delivered with minimal access to Apache as the backend. As a result, CPU usage of your server will be decreased. Many says Varnish is a great weapon to survive from Digg or Reddit effect. The best part, it can also be installed alongside with a control panel like WHM/cPanel and yes zPanel.
This guide will show you how to configure zPanel installed and run with Varnish Cache.
Installing zPanel CP
Step 1 – Login to your server as root or as user with root / sudo privilege.
Step 2 – Now issue this command to install zPanelX CP
bash <(curl -Ss https://raw.github.com/zpanel/installers/master/install/Ubuntu-12_04/10_1_1.sh)
or (if above doesn’t work):
bash <(curl -Ss https://raw.githubusercontent.com/zpanel/installers/master/install/Ubuntu-12_04/10_1_1.sh)
bash <(curl -Ss https://raw.github.com/zpanel/installers/master/install/CentOS-6_4/10_1_1.sh)
or (if above doesn’t work):
bash <(curl -Ss https://raw.githubusercontent.com/zpanel/installers/master/install/CentOS-6_4/10_1_1.sh)
Step 3 – Once the installation progress done, you’ll be able to see your zPanel username (which is zadmin) and password.
For CentOS users, you can read my previous tutorials here and here to see more detailed instruction with pictures.
Step 4 – Configure all your basic zPanel setup for your site. Or at least add new website on your newly installed zPanel.
Installing Varnish Cache
Step 1 – Login back to your server via your favorite command line interface (like Putty on Windows).
Step 2 – Install Varnish following my previous guide:
Just follow the guide but do not alter default configuration of Apache2/httpd and do not start Varnish just yet.
Configuring zPanel Settings
Step 1 – Open up your favorite web browser and login to zPanel Dashboard as zadmin.
Step 2 – Now go to menu : Server Admin > Module Admin > Apache Config.
Step 3 – Then change Apache Port from 80 to another port according to the backend setting of Varnish you defined. Commonly I use 8080.
Step 4 – Scroll down that page and click the “Save Changes” button.
Step 5 – Now login back to your server via command line and go to zPanel’s Apache configuration. In CentOS it usually located at:
I’m not quite sure about Ubuntu (you tell me).
Step 6 – Use your favorite text editor to edit httpd-vhosts.conf file (I usually use Nano):
Step 7 – You should now see all default *:80 port will be replaced with *:8080 as well as all virtual hosts entries of all your domain. If not, try to restart Apache and if that still doesn’t help you, replace all :80 with :8080.
Save and exit when you’ve done editing.
Step 8 – That’s it. Now restart Apache and start Varnish Cache:
service httpd restart
service varnish start
I did setup one of my production server using zPanel + Varnish and this tutorial is posted based on that setup without re-practicing all the steps. So if you find some part or anything is missing from this guide just let me know.