Knowledge Base

Allows you to search a variety of questions and answers

Search

Search results

Centos/RedHat

memcached and varnish are mysql and web accelerators that can greatly improve the performance of your server.

They can be installed from the EPEL repository. To add the EPEL repo to your repolist, first find the appropriate RPM (for Centos/RHEL) here:

http://fedoraproject.org/wiki/EPEL/FAQ#Using_EPEL

Note: If you are using Debian/Ubuntu or another OS look on the above site for the appropriate instructions.

Then add the repo using the following command:
 

Code:

rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm

Note: replace the above rpm link with the one you want to use.

Then run 'yum update' to update your repositories and finally run 'yum repolist' to ensure EPEL is installed.

Note: If you don't want to update any packages, just hit 'N' at the prompt and that's it.

After you have have EPEL repos active, you can use 'yum install' to install both memcached and varnish.

memcached configuration file will be located in /etc/sysconfig/memcached and you can start it using
 

Code:

/etc/init.d/memcached start

To have it start on boot, use
 

Code:

chkconfig memcached on

varnish configuration file will be in /etc/varnish. The file where you can change settings for varnish is /etc/sysconfig/varnish.

To start varnish, use:
 

Code:

/etc/init.d/varnish start

To have it start on boot use:
 

Code:

chkconcifg varnish on

For further details on how to get Varnish configured, please go here: http://www.thomasnetworks.net/2011/0...a-singel-site/

One thing to pay attention to is to ensure that you have your Apache and Varnish proxy setup correctly. I will provide an example below where your Cpanel's (or webserver's) main IP address is 1.2.3.4, with Apache running on port 81 instead of port 80.

1. First, go to WHM if using Cpanel and to Tweak Settings, then find where you can select on which port Apache listens. Change it to 81 from 80 and save. 
2. In the /etc/varnish/default.vcl file, you will need to change 
 

backend default {
.host = "127.0.0.1";
.port = "80";
}

to
 

backend default {
.host = "1.2.3.4";
.port = "81";
}

Quit & save (you can tweak additional options in the default. vcl file further, but that falls outside the scope of this tutorial)

3. Open up /etc/sysconfig/varnish and go to Advanced Method 3. There, change 
 

#VARNISH_LISTEN_ADDRESS=
VARNISH_LISTEN_PORT=81

to
 

VARNISH_LISTEN_ADDRESS=1.2.3.4
VARNISH_LISTEN_PORT=80

Quit and save (You can also tweak some settings in this file further if you wish).

4. Now restart apache (/etc/init.d/httpd restart) and then varnish (/etc/init.d/varnish restart) and your site will be running via varnish on port 80 with apache feeding it through port 81. 

If you are on a non-Cpanel server, you just need to edit your httpd.conf file accordingly. A good how-to can be found here: http://www.gnutoolbox.com/varnish-ht...erator-cpanel/.

If you are getting the following error when trying to start varnish:

varnishd dead but pid is still there (or something to that effect)

This may mean that your /dev/null is broken. Recreate it with mknod -m 666 /dev/null c 1 3.

See What Our Customers Say