<?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; Debian</title>
	<atom:link href="http://www.vvvegard.net/blog/tag/debian/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 nginx on Debian Lenny</title>
		<link>http://www.vvvegard.net/blog/setting-up-nginx-on-debian-lenny/132/</link>
		<comments>http://www.vvvegard.net/blog/setting-up-nginx-on-debian-lenny/132/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 22:49:59 +0000</pubDate>
		<dc:creator>Vegard Hansen</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[Lenny]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[scale]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[static]]></category>

		<guid isPermaLink="false">http://www.vvvegard.net/blog/?p=132</guid>
		<description><![CDATA[In this article i will i will focus on how to install, configure and setup Nginx. Nginx is a popular web server, load balancer and reverse caching proxy for many high traffic sites. Personally I prefer to use Apache2 with proper configuration and Varnish as frontend. In some cases you might want to use Nginx as frontend [...]]]></description>
			<content:encoded><![CDATA[<p>In this article i will i will focus on how to install, configure and setup Nginx. Nginx is a popular web server, load balancer and reverse caching proxy for many high traffic sites. Personally I prefer to use Apache2 with proper configuration and Varnish as frontend. In some cases you might want to use Nginx as frontend for compressing data after it has been received from the backend server, either to ease the load on the backend servers or because the backeds does not support this feature, as is the case with Varnish.<span id="more-132"></span></p>
<p>Please note that this is my first encounter with Nginx, so bare with me if I do some weird stuff. I try to document whatever I am doing, mostly to educate my self. You should not use any configuration found in this article in a production environment if you are not one hundred percent clear what it does and why it does it.</p>
<p>In this article we&#8217;ll install nginx from source as the latest stable release in Debian Lenny is very old. Please note that this <strong>might not</strong> be the case with Squeeze/SID, but in my articles I focus on using the latest stable release of Debian.</p>
<blockquote><p>apt-get install build-essential libpcre3-dev libpcre3 libssl-dev zlib1g-dev</p></blockquote>
<p>This will install all essential build utilities that you will need to build a program from source. In addition to this we install some libraries to support SSL and PECR to support rewrites.</p>
<blockquote>
<pre>cd /root
wget http://nginx.org/download/nginx-0.7.65.tar.gz
tar -zxvf nginx-0.7.65.tar.gz
cd nginx-0.7.65</pre>
</blockquote>
<p>Please go to <a href="http://nginx.org" target="_blank">nginx.org</a> and fetch the latest stable version of Nginx. As of writing this 0.7.65 is the latest stable release. We download it, untar it and move in to the folder. You probably knew this <img src='http://www.vvvegard.net/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  (4)</p>
<blockquote>
<pre>./configure --prefix=/usr/local /
--sbin-path=/usr/local/sbin /
--conf-path=/etc/nginx/nginx.conf /
--pid-path=/var/run/nginx.pid /
--error-log-path=/var/log/nginx/error.log /
--http-log-path=/var/log/nginx/access.log /
--with-http_ssl_module /
--with-debug</pre>
</blockquote>
<p>This tells the compiler where to put stuff and what modules we want to configure it with or without. Please refer to <a href="http://wiki.nginx.org/NginxInstallOptions" target="_blank">nginx wiki</a> if you want more prefixes. If you encounter any errors, read them and install whatever it is missing. Use some good old fashion Google-Fu! And please let me know in a comment if I made a Boo-Boo. (3)</p>
<blockquote>
<pre>make; make install</pre>
</blockquote>
<p>This uses the information given to it when we configured it and installs nginx. Normally this should go by without any errors as the step above should have found any short comings.</p>
<blockquote>
<pre>cd /etc/init.d/
wget http://static.vvvegard.net/files/nginx/nginx
chmod +x  nginx</pre>
</blockquote>
<p>This is a modified version of the startup script to comply with the special configuration we use. The original script can be found at <a href="http://articles.slicehost.com/2007/10/19/debian-etch-adding-an-nginx-init-script" target="_blank">articles.slicehost.com</a>. With this startup script you should be able to start, stop, restart or just reload it. I recommend you to visit the site that i snagged this startup script from, they have a lot of good articles on nginx and hosting in general! (2)</p>
<blockquote>
<pre>/etc/init.d/nginx start</pre>
</blockquote>
<p>This starts nginx and you should now be able to access it via your <a href="http://www.google.com/chrome" target="_blank">favorite browser</a>.</p>
<blockquote>
<pre>Server: nginx/0.7.65</pre>
</blockquote>
<p>This is the header that nginx puts out, and this verifies that nginx is actually serving us pages. I prefer to use Live HTTP Headers add-on for Firefox to inspect HTTP Headers.</p>
<blockquote>
<pre>cd /etc/nginx
mv nginx.conf old_nginx.conf
wget http://static.vvvegard.net/files/nginx/nginx.conf</pre>
</blockquote>
<p>This replaces the standard configuration to a modified version that comply with the standards of Debian. This is fairly basic and should work in most cases. (1)</p>
<blockquote><p>mkdir sites-enabled/<br />
cd sites-enabled/<br />
wget http://static.vvvegard.net/files/nginx/000-default</p></blockquote>
<p>Again, to comply with Debian standards we store all of our virtual hosts in it&#8217;s own folder and instead of including everyone manually we include everything in that folder with wildcard. (1)</p>
<blockquote>
<pre>/etc/init.d/nginx restart</pre>
</blockquote>
<p>Now this won&#8217;t do much, it will basically just serve static files located in &#8220;/var/www&#8221;. If we&#8217;d want PHP you&#8217;d have to either do it via fastcgi or use nginx as a frontend for Apache2, primarily for caching and compressing and let Apache2 handle all dynamic data.</p>
<p>Resources:<br />
(1) <a href="http://www.ubuntugeek.com/using-nginx-as-a-reverse-proxy-to-get-the-most-out-of-your-vps.html" target="_blank">http://www.ubuntugeek.com/using-nginx-as-a-reverse-proxy-to-get-the-most-out-of-your-vps.html</a><br />
(2) <a href="http://articles.slicehost.com/2007/10/19/debian-etch-installing-nginx" target="_blank">http://articles.slicehost.com/2007/10/19/debian-etch-installing-nginx</a><br />
(3) <a href="http://wiki.nginx.org/Main" target="_blank">http://wiki.nginx.org/Main</a><br />
(4) <a href="http://nginx.org/" target="_blank">http://nginx.org/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.vvvegard.net/blog/setting-up-nginx-on-debian-lenny/132/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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! -->
