<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Vvvegard! &#187; Varnish</title>
	<atom:link href="http://www.vvvegard.net/blog/category/varnish/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.vvvegard.net/blog</link>
	<description>Learn me a book!</description>
	<lastBuildDate>Sun, 27 Feb 2011 03:11:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Setting up Varnish 2.0.6 on Debian Lenny</title>
		<link>http://www.vvvegard.net/blog/setting-up-varnish-2-0-6-on-debian-lenny/106/</link>
		<comments>http://www.vvvegard.net/blog/setting-up-varnish-2-0-6-on-debian-lenny/106/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 20:49:17 +0000</pubDate>
		<dc:creator>Vegard Hansen</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[Lenny]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Varnish]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[scale]]></category>
		<category><![CDATA[source]]></category>

		<guid isPermaLink="false">http://www.vvvegard.net/blog/?p=106</guid>
		<description><![CDATA[Update 12.2001: Varnish-software.com now offers an official debian repo, you should use that instead of installing it via source. Check www.varnish-software.com for more information! Due to the strict rules of Debian many of the packages in stable releases are very old. In some cases though we want to run the latest version of a program, [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update 12.2001: Varnish-software.com now offers an official debian repo, you should use that instead of installing it via source. Check <a href="http://www.varnish-software.com">www.varnish-software.com</a> for more information!</strong></p>
<p>Due to the strict rules of Debian many of the packages in stable releases are very old. In some cases though we want to run the latest version of a program, mainly due to new features and increased speed. The latest version of Varnish under Debian Lenny&#8217;s repositories is 1.1.2 (apt-cache show varnish), but in most cases we&#8217;d want to run the latest, especially with rapidly developed programs like Varnish. Varnish 2.0.6 is alos available in the Debian repository for SID/Squeeze or via backports.</p>
<p><span id="more-106"></span></p>
<blockquote>
<pre>apt-get install build-essential</pre>
</blockquote>
<p>Now we got most of the essential stuff for building the packages under Debian Lenny.</p>
<blockquote>
<pre>cd /root
wget http://sourceforge.net/projects/varnish/files/varnish/2.0.6/varnish-2.0.6.tar.gz/download
tar -zxvf varnish-2.0.6.tar.gz
cd varnish-2.0.6/</pre>
</blockquote>
<p>Now we have fetched the (as of now) latest stable version of Varnish from the developers them selves. Moving on we configure it and install it.</p>
<blockquote>
<pre>./configure --prefix=/usr/local --sysconfdir=/etc --localstatedir=/var/lib --mandir=/usr/share/man
make
make install</pre>
</blockquote>
<p>This tells the compiler where to put stuff and then installs it. We&#8217;ve chosen most of the common places on Debian Lenny. This may vary on different operating systems. If you get any errors read them and install whatever it is missing. This should not be necessary if you remembered the first step.</p>
<blockquote>
<pre> ldconfig</pre>
</blockquote>
<p>This tells Debian to update the location of the libs. This is vital to get Varnish to work on Debian Linux. Failing to do this step will result in a &#8220;file not found&#8221; when trying to start Varnish. (2)</p>
<blockquote>
<pre>cp redhat/varnish.sysconfig /etc/default/varnish</pre>
</blockquote>
<p>This is the main varnish configuration file. This has nothing to do with how Varnish handles request but how the daemon is run. If you are unsure how to configure this just run with &#8220;Alternative 2&#8243;.</p>
<blockquote>
<div id="_mcePaste"><span style="font-family: Times; line-height: normal; font-size: small;"></p>
<pre>DAEMON_OPTS="-a &lt;out-side IP&gt;:80 \
             -T localhost:6082 \
             -f /etc/varnish/default.vcl \
             -u varnish -g varnish \
             -s file,/var/lib/varnish/varnish_storage.bin,512M"</pre>
<p></span></div>
</blockquote>
<p>This is a pretty basic setup that listens to port 80. The control daemon runs on localhost:6082. This you can telnet into and get various stats, load/unload configuration files when Varnish is running. Very useful tool when tuning your Varnish configuration. Also, this setup uses a 512MB cache-file, this might be too high or to low for your site, depending on how much memory you have avaliable and how much content needs/can be cached.</p>
<blockquote>
<pre>nano /etc/varnish/default.vcl</pre>
</blockquote>
<p>This is where the main configuration is done. You should set it up with atleast one backend server. Personally i run Apache2 with appropriate tools as backends, but you may run any web server of your choice. Try running your backend servers locally bound to port 80, this way you can trick them into not rewriting url when Varnish forwards the requests to them. If you do this remember to bind Varnish to your out-side IP-address, or else you will not be able to bind two applications to the same port.</p>
<blockquote>
<pre>/usr/local/sbin/varnishd -f /etc/varnish/default.vcl</pre>
</blockquote>
<p>This will start Varnish, telling it to use the configuration file located in /etc/varnish/. If you did all your steps right you should be seeing something like this in your HTTP headers. You should make a startup-script for this if you are running it on a production server. (1)</p>
<blockquote>
<pre>X-Varnish: 1861896702
Age: 0
Via: 1.1 varnish</pre>
</blockquote>
<p>Now we&#8217;ve got a fully functioning setup of Varnish. Before you run this on a production site you may want to consult with the developers of Varnish to tune the installation to your needs. You should also make varnish run under it&#8217;s own user and group. Varnish does this by default but you have to actually add the user first.</p>
<blockquote>
<pre>adduser varnish --disabled-login --no-create-home</pre>
</blockquote>
<p>This should add the user.</p>
<p>Resources:<br />
(1) <a href="http://www.all2e.com/Ressourcen/Artikel-und-Fallstudien/Varnish-installation-and-setup-on-ez-publish-based-systems">http://www.all2e.com/Ressourcen/Artikel-und-Fallstudien/Varnish-installation-and-setup-on-ez-publish-based-systems</a><br />
(2) <a href="http://varnish-cache.org/changeset/4420">http://varnish-cache.org/changeset/4420</a><br />
(3) <a href="http://varnish-cache.org/">http://varnish-cache.org/</a><br />
(4) <a href="http://kristianlyng.wordpress.com/ ">http://kristianlyng.wordpress.com/ </a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.vvvegard.net/blog/setting-up-varnish-2-0-6-on-debian-lenny/106/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
