How to Configure zPanel with Varnish Cache
|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
Ubuntu LTS:
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)
CentOS:
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:
/etc/zpanel/configs/apache/
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):
nano httpd-vhosts.conf
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
That’s all.
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.
hello
i have install zpanel in my VPS and try to install varnish front of apache BUT in :
1- install varnish
2- only user this page instruction config for varnish
http://servermom.wpengine.com/configure-zpanel-varnish-cache/1443/
but when restart apache and start varnish my domains not be loaded and are loading main zpanel login page !
can you give me full instruction and config varnish for zpanel?! from 0 to 100 ….
as long as you’ve configured its backend correctly and have correct settings in your Apache’s httpd.conf file, everything should be fine. Or, you can share your default.vcl and Apache’s .conf file here
problem Solved !
only please delete follow line from this post :
“Just follow the guide but do not alter default configuration of Apache2/httpd and do not start Varnish just yet.”
both varnish and httpd config must change within installation and after changes port of ZPanel.
thanks
Will Varnish work with Webmin? Can you update post with Webmin & Varnish ?
and how about combining this tutorial, configuring varnish for zpanel, with ‘How to Run Ghost with Varnish Cache. Because while i configure varnish for zpanel, my ghost-based site shows 500 error
and while i configure varnish to run with ghost, i can’t open zpanel, everytime i try to open zpanel, the result is the browser displaying my ghost blog
Ghost is running on Node.js while zPanel is Apache. I believe each binds to different port so you have to specify different backend in your Varnish configuration
holly sh*t it realy fasten up my site.
Thanks for the tut.
I did all according to your guide. However, now when I type in http://www.example.com it goes to my Zpanel. Before when I typed in http://www.example.com it would go to my website. panel.example.com would go to my Zpanel. Any idea why? I also tried setting the domain in a new directory /public_html/example_com and it still goes to ZPanel.
you should try reviewing (and editing) your zpanel’s virtual-hosts file configuration:
🙂 make sure each your domain have virtual hosts entry
at /etc/zpanel/configs/apache/httpd-vhosts.conf
i have vhost but when i try to akses example.com or mydomain.com always show zpanel admin login page.
any somethink to fix mom….?;
May I see your httpd-vhosts.conf file (via Pastebin.com)
I have the same problem and have changed all the . So what can i do to fix this?
I was having the same problem.
When ever I went to my domain the zpanel login page would show up.
Check your domain root and see if there’s an extra index.html file that was created by zpanel.
Got rid of that and it was fine.
Hi Mom! after I did “yum update” httpd stop working what ever I do I couldn’t fix it so I decided to reinstall apache, finally httpd started but now I only see “Apache 2 Test Page” on every domain and zpanel cp.
If i can just find how to install httpd to Zpanel all will be fine i think
CentOS release 6.6 (Final) Apache/2.2.15 (Unix)
P.S. I’m ready to pay for help i really need to fix it urgently. Thanks in advance!
You need to reconfigure Apache config file (httpd.conf) especially at the virtual hosts section (the section that holds all your domains/websites). Anyway, have you created backup of that file?
Thank you for your tutorial
Please mom i dont know why if am going to install ZPANEL 10.1.1 on centos its show server shutdows please help me