<?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!</title>
	<atom:link href="http://www.vvvegard.net/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.vvvegard.net/blog</link>
	<description>Learn me a book!</description>
	<lastBuildDate>Fri, 20 Aug 2010 23:29:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using rdiff-backup to keep your files safe and secure!</title>
		<link>http://www.vvvegard.net/blog/using-rdiff-backup-to-keep-your-files-safe-and-secure/237/</link>
		<comments>http://www.vvvegard.net/blog/using-rdiff-backup-to-keep-your-files-safe-and-secure/237/#comments</comments>
		<pubDate>Fri, 20 Aug 2010 23:21:25 +0000</pubDate>
		<dc:creator>Vegard Hansen</dc:creator>
				<category><![CDATA[Backup]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Lenny]]></category>

		<guid isPermaLink="false">http://www.vvvegard.net/blog/?p=237</guid>
		<description><![CDATA[Rdiff-backup is a small nifty python-based incremental backup software. Rdiff is similar to rsync, but adds support for incremental and revision-based backup. This way you can keep, in this example, up to 14 days of changes. Rdiff-backup also differs (!) from rsnapshot as it only stores the changes over time of a certain file, and [...]]]></description>
			<content:encoded><![CDATA[<p>Rdiff-backup is a small nifty python-based incremental backup software. Rdiff is similar to rsync, but adds support for incremental and revision-based backup. This way you can keep, in this example, up to 14 days of changes. Rdiff-backup also differs (!) from rsnapshot as it only stores the changes over time of a certain file, and this saves you a lot of storage. It&#8217;s extremely usable for database-backups, as they tend to change little but grow huge.</p>
<p>You might have to do small adjustments to stuff like users and parent directory. In this guide i use /root/ as parent directory for most actions, and all commands should work then.</p>
<p><span id="more-237"></span></p>
<p><strong>Upgrading and Installing</strong></p>
<p>It&#8217;s important that you do this on your target server and the server you are backuping, or else rdiff-backup will not be able to use ssh as it starts an rdiff-server on your target machine.</p>
<p style="padding-left: 30px;">apt-get update<br />
apt-get install rdiff-backup</p>
<p><strong>Setting up SSH with keys</strong></p>
<p>After installing rdiff we need to generate ssh-keys so that you can have automated rdiff-backups. I&#8217;ll only cover this briefly, but if you are unsure try to consult another guide i made about setting up key-based ssh authentication.</p>
<p style="padding-left: 30px;">ssh-keygen<br />
scp .ssh/id_rsa user@host:.ssh/id_rsa</p>
<p>This generates the keys you need and send them to the appropriate user on your remote machine for storing backups. If you are setting up more servers to use the same backup location copy id_rsa.pub over to them.</p>
<p><strong>Using rdiff-backup</strong></p>
<p style="padding-left: 30px;">rdiff-backup -v5 &#8211;print-statistics /local-dir user@host::/remote-dir<br />
rdiff-backup &#8211;remove-older-than 2W user@host::/remote-dir</p>
<p>Now we have created the first and initial backup, this might take some time, depending on your connection speed, disks and CPU. You should be able to watch what&#8217;s stores since we issued the -v5 comand (verbos 5).</p>
<p><strong>Automating it</strong></p>
<p style="padding-left: 30px;">echo &#8220;#!/bin/sh&#8221; &gt;&gt; rdiff-backup.sh<br />
echo &#8220;rdiff-backup -v5 &#8211;print-statistics /local-dir user@host::/remote-dir&#8221; &gt;&gt; rdiff-backup.sh<br />
echo &#8220;rdiff-backup &#8211;remove-older-than 2W user@host::/remote-dir&#8221; &gt;&gt; rdiff-backup.sh</p>
<p><strong>Running it</strong></p>
<p style="padding-left: 30px;">crontab -e</p>
<p>And insert the following line</p>
<p style="padding-left: 30px;">* 0 * * * /root/rdiff-backup.sh</p>
<p>Save it! Now you can just sit back and relax and let &#8216;em backups flow, each night at twelve o&#8217; clock.</p>
<p><strong>Restoring</strong></p>
<p>Maybe the most boring part but also the most important part, restoring. When you restore with rdiff-backup you can restore to any date you want, as long as it&#8217;s still being kept. In this guide we used 2W, or two weeks, so we should be able to restore a file 14 days back. Nifty!</p>
<p style="padding-left: 30px;">rdiff-backup -r 14D user@host::/remote-dir/file /local-dir/file</p>
<p>This will restore the 14 days old file (-r 14D) of &#8220;file&#8221; to &#8220;/local-dir/file&#8221;. Pretty nifty, ey? If you are doing disaster recovery you can also recover an entire directory.</p>
<p><strong>Final words</strong></p>
<p>Do some simple tests, like backing up and restoring. This way you don&#8217;t get caught with your pants down when you actually need to restore something, and you ensure that backups actually are working &#8211; as this guide is not fully tested nor foolproof.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vvvegard.net/blog/using-rdiff-backup-to-keep-your-files-safe-and-secure/237/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing the MacBook Pro SuperDrive, the ninja way!</title>
		<link>http://www.vvvegard.net/blog/fixing-the-macbook-pro-superdrive-the-ninja-way/228/</link>
		<comments>http://www.vvvegard.net/blog/fixing-the-macbook-pro-superdrive-the-ninja-way/228/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 22:10:30 +0000</pubDate>
		<dc:creator>Vegard Hansen</dc:creator>
				<category><![CDATA[Macbook]]></category>
		<category><![CDATA[ninja]]></category>
		<category><![CDATA[burn]]></category>
		<category><![CDATA[burn disk]]></category>
		<category><![CDATA[cannot burn]]></category>
		<category><![CDATA[cleaning]]></category>
		<category><![CDATA[disk]]></category>
		<category><![CDATA[macbook]]></category>
		<category><![CDATA[superdrive]]></category>

		<guid isPermaLink="false">http://www.vvvegard.net/blog/?p=228</guid>
		<description><![CDATA[If you ever had the following error message on you Macbook&#8217;s SuperDrive, The disc can&#8217;t be burned; it might be incompatible with this disc drive. Please try a different brand of disc, or try burning at a slower speed. you are probably in luck. It&#8217;s does not seem to be some sort of firmware error [...]]]></description>
			<content:encoded><![CDATA[<p>If you ever had the following error message on you Macbook&#8217;s SuperDrive,</p>
<blockquote><p>The disc can&#8217;t be burned; it might be incompatible with this disc drive. Please try a different brand of disc, or try burning at a slower speed.</p></blockquote>
<p>you are probably in luck. It&#8217;s does not seem to be some sort of firmware error or anything wrong with the disk you are using. It&#8217;s simply the SuperDrives laser that has gotten dusty and needs cleaning. Simple find a creditcard and a t-shirt with <em>long threaded weaving</em>. Use the creditcard to hold the cloth wrapped around and insert it into the SuperDrive and carefully move it back and forth whilst applying a <em>little</em> force downwards. The optical sensor should be on the left side, but I cleaned both sides.</p>
<p>Note, if you are within warranty you should not do this at home. I guess mighty Steve would void your ass back to outer space if he ever saw you doing it&#8230; For some pictures of the madness, head over to <a href="http://picasaweb.google.com/116546159631570220926/CleaningSuperdrive#">PicasaWeb</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vvvegard.net/blog/fixing-the-macbook-pro-superdrive-the-ninja-way/228/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to setup &#8220;Chrome To Phone&#8221;</title>
		<link>http://www.vvvegard.net/blog/how-to-setup-chrome-to-phone/216/</link>
		<comments>http://www.vvvegard.net/blog/how-to-setup-chrome-to-phone/216/#comments</comments>
		<pubDate>Wed, 26 May 2010 17:19:53 +0000</pubDate>
		<dc:creator>Vegard Hansen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.vvvegard.net/blog/?p=216</guid>
		<description><![CDATA[Chrome to Phone is a quite genius little tool. Let&#8217;s say you&#8217;ve got to catch a buss but you are reading a very interesting article on the Internet? Sending the link via email or even relocating it on your phone is very time consuming, Google has solved that with Chrome To Phone. Even more interestingly you [...]]]></description>
			<content:encoded><![CDATA[<p>Chrome to Phone is a quite genius little tool. Let&#8217;s say you&#8217;ve got to catch a buss but you are reading a very interesting article on the Internet? Sending the link via email or even relocating it on your phone is very time consuming, Google has solved that with Chrome To Phone. Even more interestingly you can make a route on Google Maps and then send that route to your phone, just by the click of a button.</p>
<p>To install Chome To Phone you need to head over to <a href="http://code.google.com/p/chrometophone/">Googles project server</a>, as this is very beta at the moment.  Download and install the plugin for your Chrome browser and then open &lt;your favorite barcode scanner&gt; and scan the 2d-barcode for the Android App. To be able to install this app you need to setup your phone to accept applications from unknown sources under Settings -&gt; Applications.</p>
<p>The Application requires that you run the latest version of Android, Froyo. This is yet to be publicly released, but should hit you in a few weeks if you own a Nexus One. Other phones most likely must wait a few months before Android Froyo is delivered to their phones.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vvvegard.net/blog/how-to-setup-chrome-to-phone/216/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What I&#8217;d like to see in Android anno Froyo</title>
		<link>http://www.vvvegard.net/blog/what-id-like-to-see-in-android-anno-froyo/214/</link>
		<comments>http://www.vvvegard.net/blog/what-id-like-to-see-in-android-anno-froyo/214/#comments</comments>
		<pubDate>Sat, 22 May 2010 16:09:05 +0000</pubDate>
		<dc:creator>Vegard Hansen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[froyo]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[squid]]></category>

		<guid isPermaLink="false">http://www.vvvegard.net/blog/?p=214</guid>
		<description><![CDATA[Now that Android 2.2 is shipping out to us lucky few who owns a Google Nexus One-phone there is one thing i&#8217;d like to see: A tiny portable version of Squid&#8217;s forwarding proxy (transparent) so that you can get the most out of your precious phone connection and hopefully speeding browsing experience up a few notches for [...]]]></description>
			<content:encoded><![CDATA[<p>Now that Android 2.2 is shipping out to us lucky few who owns a Google Nexus One-phone there is one thing i&#8217;d like to see: A tiny portable version of Squid&#8217;s forwarding proxy (transparent) so that you can get the most out of your precious phone connection and hopefully speeding browsing experience up a few notches for multiple users.</p>
<p>So &#8211; who is up for the challange? I don&#8217;t have the knowledge, hopefully someone has.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vvvegard.net/blog/what-id-like-to-see-in-android-anno-froyo/214/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Benchmarking opcode php-cachers with Apache2 on Debian Lenny</title>
		<link>http://www.vvvegard.net/blog/benchmarking-opcode-php-cachers-with-apache2-on-debian-lenny/181/</link>
		<comments>http://www.vvvegard.net/blog/benchmarking-opcode-php-cachers-with-apache2-on-debian-lenny/181/#comments</comments>
		<pubDate>Sun, 14 Mar 2010 04:20:35 +0000</pubDate>
		<dc:creator>Vegard Hansen</dc:creator>
				<category><![CDATA[Cache]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Lenny]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[apache2]]></category>
		<category><![CDATA[apc]]></category>
		<category><![CDATA[eaccelerator]]></category>
		<category><![CDATA[memcache]]></category>
		<category><![CDATA[php5]]></category>
		<category><![CDATA[php5-memcache]]></category>
		<category><![CDATA[scale]]></category>
		<category><![CDATA[xcache]]></category>

		<guid isPermaLink="false">http://www.vvvegard.net/blog/?p=181</guid>
		<description><![CDATA[In this article I will focus on how to squeeze (No, not the SID/testing release of Debian) the last drop of juice from your Apache2-installation with small measurements, focusing on PHP performance. And if you&#8217;re really serious you might want to look into my articles about Varnish as well! Welcome to the world of caching [...]]]></description>
			<content:encoded><![CDATA[<p>In this article I will focus on how to squeeze (No, not the SID/testing release of Debian) the last drop of juice from your Apache2-installation with small measurements, focusing on PHP performance. And if you&#8217;re really serious you might want to look into my articles about <a href="http://www.vvvegard.net/blog/category/varnish/" target="_blank">Varnish</a> as well! Welcome to the world of caching dynamic data! Not really, just some parts of it&#8230;<span id="more-181"></span></p>
<p>All the benchmarks in this article is based on Apache Benchmarking (ab) tool, so the numbers <strong>will not</strong> translate directly to a production environment. This was all done locally on a virtually hosted Debian Lenny (5.0.4) on VMWare Fusion. You should see much higher numbers than this in a real world scenario. If not you should highly consider buying a new server. The virtual server was running on a single 2,4Ghz shared core, with 1024MB virtually allocated memory and 8GB virtual drive.</p>
<p>For the actual tests i make ab run a series of 1000 requests with 10 concurrent requests at a time. In order for it to be a fair fight I run all tests twice. The page that is requested is a Pressflow-installation with a story consisting of three paragraphs of random bits and bytes, in total the document is 6755 bytes (very small). Apache is set up to respond to rewrites too, as most servers are.</p>
<p>My main configuration consists of Apache2, php5, phpmyadmin and mysql-server. In a production environment you might not need packages such as phpmyadmin and mysql-server, this is just installed for testing purposes. For bleeding edge packages i suggest taking a look at <a href="http://www.dotdeb.org/" target="_blank">dotdeb</a>, but i cannot vouch for the stability of said repository.</p>
<blockquote>
<pre>apt-get install apache2 php5 phpmyadmin mysql-server</pre>
</blockquote>
<p style="text-align: left;">With this fairly plain and simple setup up and running it&#8217;s time to crack some numbers. What we are focusing on is average request time, requests per second and time per request. On a basic Apache2 setup with default configuration and MPN Worker we get these numbers. You find the whole output at <a href="http://static.vvvegard.net/files/benchmarking/" target="_blank">http://static.vvvegard.net/files/benchmarking/</a>.</p>
<blockquote>
<pre>Apache2 Default Configuration
Time taken for tests:   97.409 seconds
Requests per second:    10.27 [#/sec] (mean)
Time per request:       974.094 [ms] (mean)</pre>
</blockquote>
<p>From this we can read that we get around 10 req/s. This is not bad &#8211; <em>considering the setup</em> &#8211; but you&#8217;d want to see a lot more if you are to survive a sudden traffic rush, keep in mind that most of a sites traffic hits within a short time. Also, it took a whopping 974ms (on average, 10 concurrent!) to load each page. That almost 1 second, and that&#8217;s not counting in other factors such as network latency and the rendering speed of your visitors browser. This is just to actually get the damn data!</p>
<p>Moving on we&#8217;re going to try out some of the most popular opcode cachers for PHP. First of is my personal favorite, as before of writing this article, APC &#8211; Alternative PHP Cache.</p>
<blockquote>
<pre>apt-get intall php-apc
apt-cache show php-apc</pre>
</blockquote>
<p>As the last command shows us we&#8217;ve installed &#8220;Version: 3.0.19-2&#8243; of php-apc. This is the latest version of APC in the repository as of writing this. APC is very minimalistic in it&#8217;s design and does not require a lot of configuration to get it working. But we add the following line in order to beef it up a bit, you might want to experiment with this, depending on how many sites you host or how heavy the scripts are. Numbers are in MB, duh.</p>
<blockquote>
<pre>echo "apc.shm_size = 128" &gt;&gt; /etc/php5/conf.d/apc.conf
apache2ctl restart</pre>
</blockquote>
<p>Now that we&#8217;ve got that settled we move on to the actual benchmarking. As with Apache2 default configuration you can access the full benchmark at<a href="http://static.vvvegard.net/files/benchmarking/" target="_blank">http://static.vvvegard.net/files/benchmarking/</a>. You will also find a <a href="http://static.vvvegard.net/files/benchmarking/config" target="_blank">sample configuration</a> here.</p>
<blockquote>
<pre>APC Default Configuration
Time taken for tests:   26.041 seconds
Requests per second:    38.40 [#/sec] (mean)
Time per request:       260.414 [ms] (mean)</pre>
</blockquote>
<p>We see a great improvement in time taken, requests served per second and the time it took per request. As we can see it&#8217;s almost 4 times faster with little to none actual work done.</p>
<p>Moving on we&#8217;re going to test a bit more advanced opcode cacher, XCache. It&#8217;s actually a side project from the super snappy and lightweight web server lighttpd but since is&#8217;s made for PHP it works with Apache2 to.</p>
<blockquote>
<pre>apt-get install php5-xcache
apt-cache show php5-xcache</pre>
</blockquote>
<p>The latest stable release in the repository is &#8220;Version: 1.2.2-3&#8243;. Like with APC I  did little modifications to the configuration shipped with Debian. Please note that XCache is a lot more flexible and secure because of it&#8217;s design; but also more complex and easier to break.</p>
<blockquote>
<pre>nano /etc/php5/conf.d/xcache.ini
Edit xcache.size to 128M</pre>
</blockquote>
<p style="text-align: left;">Just as with the others you find the complete benchmark at <a href="http://static.vvvegard.net/files/benchmarking/" target="_blank">http://static.vvvegard.net/files/benchmarking/</a> and configurations in <a href="http://static.vvvegard.net/files/benchmarking/config">http://static.vvvegard.net/files/benchmarking/config</a>.</p>
<blockquote>
<pre>XCache Default Configuration
Time taken for tests:   25.523 seconds
Requests per second:    39.18 [#/sec] (mean)
Time per request:       255.233 [ms] (mean)</pre>
</blockquote>
<p>As we can see it&#8217;s only slightly faster than APC with a pretty basic configuration, but you should be able to squeeze a little more juice out of it by tuning the configuration a little more. Not groundbreakingly much faster than APC, but I guess the added flexibility might make XCache a better choice than APC.</p>
<p>Moving further along we hit the first obstacle, eAccelerator. It&#8217;s not in Debian Lenny repository, so we have to compile it from source. This will probably make eAccelerator much more up to date and some of the difference shown might be because of this. There are also people who have made their <a href="http://kevin.deldycke.com/2009/08/how-to-install-eaccelerator-php5-debian-lenny/" target="_blank">own packages</a> of this, use at own risk!</p>
<p>First we need to install some essentials for building a package form source. I will not get into detail in how to install and configure eAccelerator but if you run into any problems be sure to drop a line. These commands should do the magic! Please note that due to restrictions, (that you can remove) the maximum allowed shared memory under Linux Kernel 2.6 is 32MB so we run it on 32MB. This should not show any effects during this test as it&#8217;s a small site and not that much to actually cache, in bytes.</p>
<blockquote>
<pre>apt-get install build-essential autoconf automake libtool m4 php5-dev
wget http://bart.eaccelerator.net/source/0.9.6/eaccelerator-0.9.6.tar.bz2
tar -xjvf eaccelerator-0.9.6.tar.bz2
phpize5
./configure
make; make install
cd /etc/php5/conf.d/
wget http://static.vvvegard.net/files/benchmark/config/eaccalerator.ini
mkdir /var/cache/eaccelerator
chmod 777 /var/cache/eaccelerator
apache2ctl restart</pre>
</blockquote>
<p>Like with XCache eAccelerator has a lot more flexible features than APC. There is a lot of tuning that can be done if you take your time. As with the rest you&#8217;ll find the complete benchmark at <a href="http://static.vvvegard.net/files/benchmarking/" target="_blank">http://static.vvvegard.net/files/benchmarking/</a> and configurations at <a href="http://static.vvvegard.net/files/benchmarking/config">http://static.vvvegard.net/files/benchmarking/config</a>.</p>
<blockquote>
<pre>eAccelerator Default Configuration
Time taken for tests:   24.341 seconds
RRequests per second:    41.08 [#/sec] (mean)
Time per request:       243.408 [ms] (mean)</pre>
</blockquote>
<p style="text-align: left;">Here we see a marginal speed increase from both XCache and APC, but this might just be because if runs the latest available version of eAccelerator as of writing. You might also tweak eAccelerator a lot for more juice by visiting their <a href="http://eaccelerator.net/wiki/Settings" target="_blank">wiki</a> to get some good hint&#8217;s and tips. When it comes to security I guess eAccelerator is in for a beating, from my point of perspective you should not run this in a multi-user environment as users potentially can access and read each others PHP-files.</p>
<p style="text-align: left;">Moving yet again along we&#8217;re going to put php5-memcache up to the tests. Php5-memcache is a lot like APC with fewer possible configurations than XCache and eAccelerator. And like the others you find the complete benchmark at <a href="http://static.vvvegard.net/files/benchmarking/" target="_blank">http://static.vvvegard.net/files/benchmarking/</a> and configurations in <a href="http://static.vvvegard.net/files/benchmarking/config">http://static.vvvegard.net/files/benchmarking/config</a>. We&#8217;re using the default configuration shipped with Debian, no modifications.</p>
<blockquote>
<pre>apt-get install php5-memcache
apt-cache show php5-memcache</pre>
</blockquote>
<p>We&#8217;re getting &#8220;Version: 3.0.1-1&#8243; of php5-memcache. This seems to be quite new as far as I could see. And that makes what comes next even more depressing.</p>
<blockquote>
<pre>php5-memcache Default Configuration
Time taken for tests:   98.439 seconds
Requests per second:    10.16 [#/sec] (mean)
Time per request:       984.391 [ms] (mean)</pre>
</blockquote>
<p>Woha! It&#8217;s actually worse than native PHP. This might be because of the configuration, but my gut feeling tells me there is something more in the grass, the server load went trough the roof with php5-memcache.</p>
<p>To sum it all up, most OPCode cachers do a really good job in both speeding up you requests and makes your server scale a little more than it does without any caching capability. Running a cacher is highly recommended as it reduces hits on your disks and makes your server scale a lot better. The tests also showed that most cachers make the server peak 4x as much on requests per second, witch should do the trick if you experience slowdown during peak hour on your server. In a combination with Varnish and a fine tuned setup you should be able to get around 150-200 req/s on backend servers while serving 1500+ req/s from Varnish, with a 90% cache-hit rate.</p>
<p>Next time I&#8217;ll make some nice graphs with rrdtool too <img src='http://www.vvvegard.net/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':-D' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.vvvegard.net/blog/benchmarking-opcode-php-cachers-with-apache2-on-debian-lenny/181/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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[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 [...]]]></description>
			<content:encoded><![CDATA[<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.<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</pre>
</blockquote>
<p>This should add the user. You may want to edit /etc/passwd and set it up with no shell access. Do this by editing &#8220;/bin/bash&#8221; to &#8220;/bin/false&#8221;. You may also want to set a strong password all though this is not essential as the user has no shell access, and this should, to my knowledge, remove the need for a password.</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>1</slash:comments>
		</item>
		<item>
		<title>Rått med tiltshift-fotografering</title>
		<link>http://www.vvvegard.net/blog/ratt-med-tiltshift-fotografering/100/</link>
		<comments>http://www.vvvegard.net/blog/ratt-med-tiltshift-fotografering/100/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 22:36:22 +0000</pubDate>
		<dc:creator>Vegard Hansen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.vvvegard.net/blog/?p=100</guid>
		<description><![CDATA[Hulkamania from Keith Loutit on Vimeo.]]></description>
			<content:encoded><![CDATA[<p><object width="400" height="225"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=7827404&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=ffffff&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=7827404&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=ffffff&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="225"></embed></object>
<p><a href="http://vimeo.com/7827404">Hulkamania</a> from <a href="http://vimeo.com/keithloutit">Keith Loutit</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vvvegard.net/blog/ratt-med-tiltshift-fotografering/100/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Grr, Posten Norge..</title>
		<link>http://www.vvvegard.net/blog/grr-posten-norge/97/</link>
		<comments>http://www.vvvegard.net/blog/grr-posten-norge/97/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 22:35:05 +0000</pubDate>
		<dc:creator>Vegard Hansen</dc:creator>
				<category><![CDATA[Svada]]></category>

		<guid isPermaLink="false">http://www.vvvegard.net/blog/?p=97</guid>
		<description><![CDATA[Som selverklært Google-fanboy måtte jeg jo selvsagt ha meg en Google Nexus One (Ja, den telefonen), og satt febrilsk å oppdaterte siden hvor man skulle kunne kjøpe den på lanseringsdagen. Til min store skuffelse ble den kun lansert i 4 land; USA, UK, Hong Kong og Singapore. Jeg visste heldigvis råd og benyttet meg av [...]]]></description>
			<content:encoded><![CDATA[<p>Som selverklært Google-fanboy måtte jeg jo selvsagt ha meg en Google Nexus One (Ja, den telefonen), og satt febrilsk å oppdaterte siden hvor man skulle kunne kjøpe den på lanseringsdagen. Til min store skuffelse ble den kun lansert i 4 land; USA, UK, Hong Kong og Singapore. Jeg visste heldigvis råd og benyttet meg av bekjente i Singapore for å bestille en telefon til meg. Det tok 4 dager fra telefonen ble registrert på postkontoret i Singapore til den var ankommet Norge. Men der sluttet moroa!</p>
<p><strong>22.01.2010</strong>: Telefonen ankommer Norge. Blir utrolig nok fortollet bare timer etter og videresendt til Posten Norge for videre forsendelse.<br />
<strong>25.01.2010</strong>: Telefonen er registrert på omlastningssentralen, under en kilometer unnav meg, men blir informert om at Posten Norge ikke kjører ut pakker på mandager.</p>
<p>Posten har med andre ord prestert å bruke vanvittige tre dager på å frakte en telefon fra Oslo til Kristiansand, og ikke nok med det så driver de ikke utkjøring på mandager. Hva er det for noe tull? Totalt sett så har pakken brukt lengst tid på <strong>kortest</strong> reise, faktisk en hel dag på en knapp kilometer. Det er helt fantastisk. Jeg tror faktisk man må legge godviljen til for å klare å prestere <em>så dårlig</em>. Ikke nok med det, som privatperson kan jeg ikke hente den på omlastningssentralen, selv om den er døgnbemannet. Dette er bare en tjeneste de tilbyr til bedrifter.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vvvegard.net/blog/grr-posten-norge/97/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Forskjellen på AT&amp;T og T-Mobile sitt 3G-nettverk</title>
		<link>http://www.vvvegard.net/blog/forskjellen-pa-att-og-t-mobile-sitt-3g-nettverk/79/</link>
		<comments>http://www.vvvegard.net/blog/forskjellen-pa-att-og-t-mobile-sitt-3g-nettverk/79/#comments</comments>
		<pubDate>Sun, 20 Dec 2009 03:07:12 +0000</pubDate>
		<dc:creator>Vegard Hansen</dc:creator>
				<category><![CDATA[Svada]]></category>
		<category><![CDATA[3g]]></category>
		<category><![CDATA[att]]></category>
		<category><![CDATA[hsdpa]]></category>
		<category><![CDATA[nexus one]]></category>
		<category><![CDATA[t-mobile]]></category>
		<category><![CDATA[umts]]></category>

		<guid isPermaLink="false">http://www.vvvegard.net/?p=79</guid>
		<description><![CDATA[Siden det er mye uklarhet rundt Nexus One og hvilket mobilnett den bruker har jeg nå oppdatert posten. Nexus One fra AT&#38;T bruker 850Mhz og 1900Mhz for UMTS, mens samme telefonen fra T-Mobile USA bruker 1700Mhz og 2100Mhz. Frekvensbånd UMTS (HSPA): Telenor: 2100Mhz Netcom: 2100Mhz Tele2: 2100Mhz AT&#38;T: 850Mhz og 1900Mhz T-Mobile USA: 1700Mhz og 2100Mhz [...]]]></description>
			<content:encoded><![CDATA[<p>Siden det er mye uklarhet rundt Nexus One og hvilket mobilnett den bruker har jeg nå oppdatert posten. Nexus One fra AT&amp;T bruker 850Mhz og 1900Mhz for UMTS, mens samme telefonen fra T-Mobile USA bruker 1700Mhz og 2100Mhz.</p>
<p><strong>Frekvensbånd UMTS (HSPA):</strong></p>
<p><strong>Telenor: </strong>2100Mhz<br />
<strong>Netcom: </strong>2100Mhz<br />
<strong>Tele2: </strong>2100Mhz<br />
<strong>AT&amp;T: </strong>850Mhz og 1900Mhz<br />
<strong>T-Mobile USA: </strong>1700Mhz og 2100Mhz</p>
<p>Siden vi i Norge kun bruker 2100Mhz-båndet for UMTS kan vi kun bruke Nexus One-modellen fra T-Mobile USA. Hvis du har kjøpt en Nexus One fra AT&amp;T vil du slite med at mobilen ikke klarer å registrere seg i mobilnettet, det kan du mest sannsynlig løse ved å skru av 3G under Settings -&gt; Wireless &amp; Network. Hvis du har kjøpt den i Singapore eller UK skal det fungere helt fint, siden de bruker samme frekvensbånd som oss i Norge.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vvvegard.net/blog/forskjellen-pa-att-og-t-mobile-sitt-3g-nettverk/79/feed/</wfw:commentRss>
		<slash:comments>0</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! -->