<?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>Matejunkie &#187; debian</title>
	<atom:link href="http://www.matejunkie.com/tag/debian/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.matejunkie.com</link>
	<description>"Look behind you, a Three-Headed Monkey!"</description>
	<lastBuildDate>Thu, 07 Jan 2010 14:26:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>howto: nginx with php and Passenger (mod_rails) at once</title>
		<link>http://www.matejunkie.com/howto-nginx-with-php-and-passenger-mod_rails-at-once/</link>
		<comments>http://www.matejunkie.com/howto-nginx-with-php-and-passenger-mod_rails-at-once/#comments</comments>
		<pubDate>Tue, 19 May 2009 14:32:51 +0000</pubDate>
		<dc:creator>Mike Adolphs</dc:creator>
				<category><![CDATA[Binary Talks]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[passenger (mod_rails)]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[spawn_fcgi]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.matejunkie.com/?p=999</guid>
		<description><![CDATA[nginx is one hell of a webserver. It&#8217;s fast, efficient, small and reliable. According to  Netcraft&#8217;s webserver survey about 3 percent of world&#8217;s webserver are using nginx to deliver content and the amount of nginx-powered servers is growing strong. Since I was bothered by administrating another Apache (I do this all day long) and because [...]]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-1011 alignleft" title="nginx-logo" src="http://www.matejunkie.com/wp-content/uploads/2009/05/nginx-logo.png" alt="nginx-logo" width="220" height="55" /><a title="Nginx - Official website" href="http://nginx.net/" target="_blank">nginx</a> is one hell of a webserver. It&#8217;s fast, efficient, small and reliable. According to  <a title="Netcraft - Webserver Survey" href="http://news.netcraft.com/archives/web_server_survey.html" target="_blank">Netcraft&#8217;s webserver survey</a> about 3 percent of world&#8217;s webserver are using nginx to deliver content and the amount of nginx-powered servers is growing strong.<br />
Since I was bothered by administrating another Apache (I do this all day long) and because I was tired of letting the Apache balance on several Mongrels which is not just slow, but also quite inefficient for this low-traffic blog, I just migrated my whole environment to be served by nginx. And that wasn&#8217;t much of a problem.</p>
<p>Here&#8217;s how I proceeded on a Debian Lenny server, enabling nginx to serve content via PHP and Ruby through <a title="Phusion Passenger - mod_rails" href="http://www.modrails.com/" target="_blank">Phusion&#8217;s Passenger</a>, also known as mod_rails, at once.</p>
<h3>Requirements</h3>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># build-essential isn't installed by default, just in case you haven't done this yet</span>
<span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #c20cb9; font-weight: bold;">bzip2</span> build-essential
<span style="color: #666666; font-style: italic;"># Required ruby packages</span>
<span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> ruby ruby-dev ruby1.8 rubygems libopenssl-ruby
<span style="color: #666666; font-style: italic;"># FastCGI packages to make nginx work with PHP</span>
<span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> libfcgi libfcgi-perl libfcgi
<span style="color: #666666; font-style: italic;"># The whole php5 package (you might not need all of it)</span>
<span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> php5 php5-cgi php5-common php5-dev php5-mysql php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-cgi php5-mcrypt php5-curl php5-gd php5-memcache php5-mhash php5-pspell php5-snmp php5-sqlite libmagick9-dev php5-cli</pre></div></div>

<h3>Get PHP going</h3>
<p>To enable nginx to serve PHP-written content we have to retrieve something from the <a title="Lighttpd" href="http://www.lighttpd.net/" target="_blank">lighttpd project</a> what is called spawnfcgi. This is necessary because nginx isn&#8217;t capable to handle PHP by default. We therefore have to get a copy of the lighttpd source, unpack, configure and make it. We then only copy the spawnfcgi binary to a local directory.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>host ~ $ <span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>www.lighttpd.net<span style="color: #000000; font-weight: bold;">/</span>download<span style="color: #000000; font-weight: bold;">/</span>lighttpd-1.4.18.tar.bz2
user<span style="color: #000000; font-weight: bold;">@</span>host ~ $ <span style="color: #c20cb9; font-weight: bold;">tar</span> xvjf lighttpd-1.4.18.tar.bz2
user<span style="color: #000000; font-weight: bold;">@</span>host ~ $ <span style="color: #7a0874; font-weight: bold;">cd</span> lighttpd-1.4.18<span style="color: #000000; font-weight: bold;">/</span>
user<span style="color: #000000; font-weight: bold;">@</span>host ~<span style="color: #000000; font-weight: bold;">/</span>lighttpd-1.4.18 $ .<span style="color: #000000; font-weight: bold;">/</span>configure
user<span style="color: #000000; font-weight: bold;">@</span>host ~<span style="color: #000000; font-weight: bold;">/</span>lighttpd-1.4.18 $ <span style="color: #c20cb9; font-weight: bold;">make</span>
user<span style="color: #000000; font-weight: bold;">@</span>host ~<span style="color: #000000; font-weight: bold;">/</span>lighttpd-1.4.18 $ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> src<span style="color: #000000; font-weight: bold;">/</span>spawn-fcgi <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>spawn-fcgi</pre></div></div>

<p>After that we should give it a try to see whether it&#8217;s working:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>host ~ $ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>spawn-fcgi <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>php-cgi <span style="color: #660033;">-a</span> 127.0.0.1 <span style="color: #660033;">-p</span> <span style="color: #000000;">49232</span> <span style="color: #660033;">-P</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>fastcgi-php.pid
user<span style="color: #000000; font-weight: bold;">@</span>host ~ $ <span style="color: #c20cb9; font-weight: bold;">ps</span> aux<span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">grep</span> cgi
root     <span style="color: #000000;">31145</span>  <span style="color: #000000;">2.3</span>  <span style="color: #000000;">2.1</span> <span style="color: #000000;">191944</span> <span style="color: #000000;">11212</span> ?        Ss   <span style="color: #000000;">23</span>:<span style="color: #000000;">42</span>   <span style="color: #000000;">0</span>:00 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>php-cgi
root     <span style="color: #000000;">31147</span>  <span style="color: #000000;">0.0</span>  <span style="color: #000000;">0.8</span> <span style="color: #000000;">191944</span>  <span style="color: #000000;">4676</span> ?        S    <span style="color: #000000;">23</span>:<span style="color: #000000;">42</span>   <span style="color: #000000;">0</span>:00 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>php-cgi
root     <span style="color: #000000;">31148</span>  <span style="color: #000000;">0.0</span>  <span style="color: #000000;">0.8</span> <span style="color: #000000;">191944</span>  <span style="color: #000000;">4676</span> ?        S    <span style="color: #000000;">23</span>:<span style="color: #000000;">42</span>   <span style="color: #000000;">0</span>:00 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>php-cgi</pre></div></div>

<p>We then kill the processes since we&#8217;ll write an init script which starts the spawner by default. First of all, we&#8217;re writing a simple shell script which makes the exact same call as above. Then we&#8217;re putting the init script below into /etc/init.d.</p>
<h4>/usr/bin/php5-fcgi</h4>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>spawn-fcgi <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>php-cgi <span style="color: #660033;">-a</span> 127.0.0.1 <span style="color: #660033;">-p</span> <span style="color: #000000;">49232</span> <span style="color: #660033;">-C</span> <span style="color: #000000;">2</span> <span style="color: #660033;">-P</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>fastcgi-php.pid</pre></div></div>

<h4>/etc/init.d/php5-fcgi</h4>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #007800;">PHP_SCRIPT</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>php5-fcgi
<span style="color: #007800;">RETVAL</span>=<span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
        start<span style="color: #7a0874; font-weight: bold;">&#41;</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Starting fastcgi&quot;</span>
                <span style="color: #007800;">$PHP_SCRIPT</span>
                <span style="color: #007800;">RETVAL</span>=<span style="color: #007800;">$?</span>
  <span style="color: #000000; font-weight: bold;">;;</span>
        stop<span style="color: #7a0874; font-weight: bold;">&#41;</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Stopping fastcgi&quot;</span>
                <span style="color: #c20cb9; font-weight: bold;">killall</span> <span style="color: #660033;">-9</span> php-cgi
                <span style="color: #007800;">RETVAL</span>=<span style="color: #007800;">$?</span>
  <span style="color: #000000; font-weight: bold;">;;</span>
        restart<span style="color: #7a0874; font-weight: bold;">&#41;</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Restarting fastcgi&quot;</span>
                <span style="color: #c20cb9; font-weight: bold;">killall</span> <span style="color: #660033;">-9</span> php-cgi
                <span style="color: #007800;">$PHP_SCRIPT</span>
                <span style="color: #007800;">RETVAL</span>=<span style="color: #007800;">$?</span>
  <span style="color: #000000; font-weight: bold;">;;</span>
        <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Usage: php-fastcgi {start|stop|restart}&quot;</span>
                <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
  <span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #000000; font-weight: bold;">esac</span>
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #007800;">$RETVAL</span></pre></div></div>

<p>Dont&#8217; forget to make both scripts executable:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>host: ~ $ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span> +x <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>php5-fcgi
user<span style="color: #000000; font-weight: bold;">@</span>host: ~ $ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span> +x <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>php5-fcgi</pre></div></div>

<p>To start the spawner during boot we&#8217;re putting its init script into the default runlevel:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>host: ~ $ <span style="color: #c20cb9; font-weight: bold;">sudo</span> update-rc.d php5-fcgi defaults</pre></div></div>

<p>With the appropriate nginx configuration we&#8217;d be able to serve PHP content now, but before we&#8217;ll proceed we get Ruby going.</p>
<h3>Get Ruby going</h3>
<p>Since the deb package of rubygems only installs version 1.2.0, we have to upgrade it to at least 1.3.1. This has to be done manually since a &#8216;gem update &#8211;system&#8217; is disabled on Debian based distributions by default.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>host: ~ $ <span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>rubyforge.org<span style="color: #000000; font-weight: bold;">/</span>frs<span style="color: #000000; font-weight: bold;">/</span>download.php<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">45905</span><span style="color: #000000; font-weight: bold;">/</span>rubygems-1.3.1.tgz
user<span style="color: #000000; font-weight: bold;">@</span>host: ~ $ <span style="color: #c20cb9; font-weight: bold;">tar</span> xzf rubygems-1.3.1.tgz
user<span style="color: #000000; font-weight: bold;">@</span>host: ~ $ <span style="color: #7a0874; font-weight: bold;">cd</span> rubygems-1.3.1<span style="color: #000000; font-weight: bold;">/</span>
user<span style="color: #000000; font-weight: bold;">@</span>host: ~<span style="color: #000000; font-weight: bold;">/</span>rubygems-1.3.1 $ <span style="color: #c20cb9; font-weight: bold;">sudo</span> ruby setup.rb</pre></div></div>

<p>After these steps, a &#8216;gem &#8211;version&#8217; should show that it&#8217;s upgraded to 1.3.1. So this has been done, we&#8217;re ready for installing passenger now:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> passenger</pre></div></div>

<p>That&#8217;ll do the job for the Ruby prerequisites. One more step is required before starting the passenger installer: creating directories.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>host: ~ $ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>nginx
user<span style="color: #000000; font-weight: bold;">@</span>host: ~ $ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>body
user<span style="color: #000000; font-weight: bold;">@</span>host: ~ $ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>proxy
user<span style="color: #000000; font-weight: bold;">@</span>host: ~ $ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>fastcgi</pre></div></div>

<p>We&#8217;re now ready to install nginx, but rather than installing it via aptitude we&#8217;ll compile it manually since otherwise passenger wouldn&#8217;t work. We&#8217;ll therefore download the source and then run the passenger installer since it&#8217;ll compile nginx for us after answering a couple of questions.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>host: ~ $ <span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>sysoev.ru<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>nginx-0.6.36.tar.gz
user<span style="color: #000000; font-weight: bold;">@</span>host: ~ $ <span style="color: #c20cb9; font-weight: bold;">tar</span> xzf nginx-0.6.36.tar.gz
user<span style="color: #000000; font-weight: bold;">@</span>host: ~ $ <span style="color: #c20cb9; font-weight: bold;">sudo</span> passenger-install-nginx-module</pre></div></div>

<p>What now starts is an interactive dialogue which guides us through the passenger installation including the compilation of nginx and pcre as another requirement. After we&#8217;ve hit enter required software is being checked. If you&#8217;ve did the aptitude steps in the first place everything should be allright by now, but in case the installer bothers about something that&#8217;s missing, follow the steps provided by the installer. It&#8217;s self-explanatory.<br />
One more step and we&#8217;re asked to choose between two install methods. We choose 2 since we want to provide additional compile arguments before doing the actual work.</p>
<p>When we&#8217;re asked to provide the full path of the nginx source code, we type it in.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>user<span style="color: #000000; font-weight: bold;">/</span>nginx-0.6.36</pre></div></div>

<p>As the prefix we should rather choose /usr/local/nginx instead of /opt/nginx.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>nginx</pre></div></div>

<p>Now comes the important part since we&#8217;re able to provide additional arguments before the actual compilation begins. nginx is highly configurable and versatile, it depends on your environment what you want to achieve. You might want to take a look at the <a title="nginx - Wiki" href="http://wiki.nginx.org/NginxModules" target="_blank">official nginx Wiki</a> to get information about the different modules. For me the following arguments did a good job.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #660033;">--user</span>=www-data 
<span style="color: #660033;">--group</span>=www-data 
<span style="color: #660033;">--sbin-path</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin 
<span style="color: #660033;">--conf-path</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>nginx.conf 
<span style="color: #660033;">--error-log-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>error.log 
<span style="color: #660033;">--pid-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>nginx.pid 
<span style="color: #660033;">--lock-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lock<span style="color: #000000; font-weight: bold;">/</span>nginx.lock 
<span style="color: #660033;">--http-log-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>access.log 
<span style="color: #660033;">--http-client-body-temp-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>body 
<span style="color: #660033;">--http-proxy-temp-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>proxy 
<span style="color: #660033;">--http-fastcgi-temp-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>fastcgi 
--with-http_ssl_module 
--with-http_dav_module 
--with-http_gzip_static_module 
--with-http_stub_status_module 
<span style="color: #660033;">--with-openssl</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib 
--without-mail_pop3_module 
--without-mail_smtp_module 
--without-mail_imap_module</pre></div></div>

<p>Copy&#8217;n'paste of the output above won&#8217;t work because of the line break. If you want to adopt the exact same arguments stick to the output below:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #660033;">--conf-path</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>nginx.conf <span style="color: #660033;">--error-log-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>error.log <span style="color: #660033;">--pid-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>nginx.pid <span style="color: #660033;">--lock-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lock<span style="color: #000000; font-weight: bold;">/</span>nginx.lock <span style="color: #660033;">--http-log-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>access.log <span style="color: #660033;">--http-client-body-temp-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>body <span style="color: #660033;">--http-proxy-temp-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>proxy <span style="color: #660033;">--http-fastcgi-temp-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>fastcgi --with-http_ssl_module --without-mail_pop3_module --without-mail_smtp_module --without-mail_imap_module <span style="color: #660033;">--sbin-path</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin <span style="color: #660033;">--user</span>=www-data <span style="color: #660033;">--group</span>=www-data --with-http_dav_module --with-http_gzip_static_module --with-http_stub_status_module <span style="color: #660033;">--with-openssl</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib</pre></div></div>

<p>Pushing enter once more and nginx is finally getting compiled and installed. This usually won&#8217;t take more than 5 minutes and should return no error. After this the passenger installation provides additional information which can be ignored by now since you&#8217;ll find the exact same directives in the configuration output below.</p>
<h3>Get nginx going</h3>
<p>The first thing we&#8217;ll write is, of course, an init script. Copy&#8217;n'paste the output below into /etc/init.d/ and make it executable.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#! /bin/sh</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Description: Startup script for nginx webserver on Debian. Place in /etc/init.d and</span>
<span style="color: #666666; font-style: italic;"># run 'sudo update-rc.d nginx defaults', or use the appropriate command on your</span>
<span style="color: #666666; font-style: italic;"># distro.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Author:       Ryan Norbauer</span>
<span style="color: #666666; font-style: italic;"># Modified:     Geoffrey Grosenbach http://topfunky.com</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #660033;">-e</span>
&nbsp;
<span style="color: #007800;">PATH</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>sbin:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #000000; font-weight: bold;">/</span>sbin:<span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin
<span style="color: #007800;">DESC</span>=<span style="color: #ff0000;">&quot;nginx daemon&quot;</span>
<span style="color: #007800;">NAME</span>=nginx
<span style="color: #007800;">DAEMON</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$NAME</span>
<span style="color: #007800;">CONFIGFILE</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>nginx.conf
<span style="color: #007800;">PIDFILE</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$NAME</span>.pid
<span style="color: #007800;">SCRIPTNAME</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$NAME</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Gracefully exit if the package has been removed.</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #660033;">-x</span> <span style="color: #007800;">$DAEMON</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span>
&nbsp;
d_start<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #007800;">$DAEMON</span> <span style="color: #660033;">-c</span> <span style="color: #007800;">$CONFIGFILE</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot; already running&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
d_stop<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #c20cb9; font-weight: bold;">kill</span> <span style="color: #660033;">-QUIT</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$PIDFILE</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot; not running&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
d_reload<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #c20cb9; font-weight: bold;">kill</span> <span style="color: #660033;">-HUP</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$PIDFILE</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot; can't reload&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
  start<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Starting <span style="color: #007800;">$DESC</span>: <span style="color: #007800;">$NAME</span>&quot;</span>
        d_start
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;.&quot;</span>
        <span style="color: #000000; font-weight: bold;">;;</span>
  stop<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Stopping <span style="color: #007800;">$DESC</span>: <span style="color: #007800;">$NAME</span>&quot;</span>
        d_stop
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;.&quot;</span>
        <span style="color: #000000; font-weight: bold;">;;</span>
  reload<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Reloading <span style="color: #007800;">$DESC</span> configuration...&quot;</span>
        d_reload
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;reloaded.&quot;</span>
  <span style="color: #000000; font-weight: bold;">;;</span>
  restart<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Restarting <span style="color: #007800;">$DESC</span>: <span style="color: #007800;">$NAME</span>&quot;</span>
        d_stop
        <span style="color: #666666; font-style: italic;"># One second might not be time enough for a daemon to stop,</span>
        <span style="color: #666666; font-style: italic;"># if this happens, d_start will fail (and dpkg will break if</span>
        <span style="color: #666666; font-style: italic;"># the package is being upgraded). Change the timeout if needed</span>
        <span style="color: #666666; font-style: italic;"># be, or change d_stop to have start-stop-daemon use --retry.</span>
        <span style="color: #666666; font-style: italic;"># Notice that using --retry slows down the shutdown process somewhat.</span>
        <span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">5</span>
        d_start
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;.&quot;</span>
        <span style="color: #000000; font-weight: bold;">;;</span>
  <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
          <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Usage: <span style="color: #007800;">$SCRIPTNAME</span> {start|stop|restart|force-reload}&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>
          <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">3</span>
        <span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #000000; font-weight: bold;">esac</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>host: ~ $ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span> +x <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>nginx</pre></div></div>

<p>Now let&#8217;s create the Debian-like directory structure under /etc/nginx for different vhosts. This enables us to activate and deactivate vhosts the easy way via symlinking.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>host: ~ $ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>sites-available<span style="color: #000000; font-weight: bold;">/</span>
user<span style="color: #000000; font-weight: bold;">@</span>host: ~ $ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>sites-enabled<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>What&#8217;s left is the actual configuration work of nginx. Please stick to the output below and make sure to read the comments with a leading #.<br />
One short note: I&#8217;m not that familiar with all the aspects of nginx&#8217;s configuration yet, but the configuration below works just fine. In case you find any flaws or tweaks, I&#8217;d be glad to know about them.</p>
<h4>/etc/init.d/nginx.conf</h4>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user  www-data;
worker_processes  <span style="color: #000000;">1</span>;
&nbsp;
events <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    worker_connections  <span style="color: #000000;">1024</span>;
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
http <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    include       mime.types;
    default_type  application<span style="color: #000000; font-weight: bold;">/</span>octet-stream;
&nbsp;
    sendfile        on;
    <span style="color: #666666; font-style: italic;">#tcp_nopush     on;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">#keepalive_timeout  0;</span>
    keepalive_timeout  <span style="color: #000000;">65</span>;
&nbsp;
    <span style="color: #666666; font-style: italic;">#gzip  on;</span>
&nbsp;
    passenger_root <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>passenger-2.2.2;
    passenger_ruby <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ruby1.8;
&nbsp;
    include <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>sites-enabled<span style="color: #000000; font-weight: bold;">/*</span>;
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<h4>/etc/init.d/sites-available/site-xyz</h4>
<p>The following is an example for a virtual server with PHP support enabled, including various location directives, e.g. for the status page of nginx which is only available when the status module has been compiled. If you took my compile arguments above, don&#8217;t worry, it&#8217;s integrated.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">server <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        listen   <span style="color: #000000;">80</span>;
        server_name  www.example.com;
&nbsp;
        access_log  <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>example.com<span style="color: #000000; font-weight: bold;">/</span>logs<span style="color: #000000; font-weight: bold;">/</span>access.log;
&nbsp;
        location <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
                root   <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>example.com<span style="color: #000000; font-weight: bold;">/</span>htdocs;
                index  index.php;
&nbsp;
                <span style="color: #666666; font-style: italic;"># this serves static files that exist without running other rewrite tests</span>
                <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>-f <span style="color: #007800;">$request_filename</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
                    expires 30d;
                    <span style="color: #7a0874; font-weight: bold;">break</span>;
                <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
                <span style="color: #666666; font-style: italic;"># this sends all non-existing file or directory requests to index.php</span>
                <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">!</span>-e <span style="color: #007800;">$request_filename</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
                    rewrite ^<span style="color: #7a0874; font-weight: bold;">&#40;</span>.+<span style="color: #7a0874; font-weight: bold;">&#41;</span>$ <span style="color: #000000; font-weight: bold;">/</span>index.php?<span style="color: #007800;">q</span>=$<span style="color: #000000;">1</span> <span style="color: #c20cb9; font-weight: bold;">last</span>;
                <span style="color: #7a0874; font-weight: bold;">&#125;</span>
        <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
        location ~ .php$ <span style="color: #7a0874; font-weight: bold;">&#123;</span>
                fastcgi_pass   127.0.0.1:<span style="color: #000000;">49232</span>; <span style="color: #666666; font-style: italic;">#this must point to the socket spawn_fcgi is running on.</span>
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME    <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>example.com<span style="color: #000000; font-weight: bold;">/</span>htdocs<span style="color: #007800;">$fastcgi_script_name</span>;  <span style="color: #666666; font-style: italic;"># same path as above</span>
&nbsp;
                fastcgi_param  QUERY_STRING       <span style="color: #007800;">$query_string</span>;
                fastcgi_param  REQUEST_METHOD     <span style="color: #007800;">$request_method</span>;
                fastcgi_param  CONTENT_TYPE       <span style="color: #007800;">$content_type</span>;
                fastcgi_param  CONTENT_LENGTH     <span style="color: #007800;">$content_length</span>;
&nbsp;
                fastcgi_param  SCRIPT_NAME        <span style="color: #007800;">$fastcgi_script_name</span>;
                fastcgi_param  REQUEST_URI        <span style="color: #007800;">$request_uri</span>;
                fastcgi_param  DOCUMENT_URI       <span style="color: #007800;">$document_uri</span>;
                fastcgi_param  DOCUMENT_ROOT      <span style="color: #007800;">$document_root</span>;
                fastcgi_param  SERVER_PROTOCOL    <span style="color: #007800;">$server_protocol</span>;
&nbsp;
                fastcgi_param  GATEWAY_INTERFACE  CGI<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.1</span>;
                fastcgi_param  SERVER_SOFTWARE    nginx<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$nginx_version</span>;
&nbsp;
                fastcgi_param  REMOTE_ADDR        <span style="color: #007800;">$remote_addr</span>;
                fastcgi_param  REMOTE_PORT        <span style="color: #007800;">$remote_port</span>;
                fastcgi_param  SERVER_ADDR        <span style="color: #007800;">$server_addr</span>;
                fastcgi_param  SERVER_PORT        <span style="color: #007800;">$server_port</span>;
                fastcgi_param  SERVER_NAME        <span style="color: #007800;">$server_name</span>;
&nbsp;
                <span style="color: #666666; font-style: italic;"># required if PHP was built with --enable-force-cgi-redirect</span>
                <span style="color: #666666; font-style: italic;"># fastcgi_param  REDIRECT_STATUS    200;</span>
        <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;"># this location directive only works if compiled with the status module</span>
        location <span style="color: #000000; font-weight: bold;">/</span>nginx_status <span style="color: #7a0874; font-weight: bold;">&#123;</span>
                stub_status on;
                access_log   off;
                allow all;
        <span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>This is an example of a vhost configuration for a ruby powered vhost. As you can see the configuration here is much more straight-forward. Make sure that the root directive points to a directory of your project that&#8217;s called public.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">server <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        listen   <span style="color: #000000;">80</span>;
        server_name  www.example.com;
&nbsp;
        access_log  <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>example.com<span style="color: #000000; font-weight: bold;">/</span>logs<span style="color: #000000; font-weight: bold;">/</span>access.log
&nbsp;
        root <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>example.com<span style="color: #000000; font-weight: bold;">/</span>htdocs<span style="color: #000000; font-weight: bold;">/</span>site-xyz<span style="color: #000000; font-weight: bold;">/</span>public;
        passenger_enabled on;
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>Afterwards simply symlink the configuration from /sites-enabled to /sites-available and start nginx. If everything&#8217;s ok you may see nginx&#8217;s default website and be ready to add your own PHP and Ruby applications.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>host: <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>sites-enabled $ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>sites-available<span style="color: #000000; font-weight: bold;">/</span>site-xyz site-xyz</pre></div></div>

<p>If you&#8217;ve got questions or suggestions, don&#8217;t hesitate to start a discussion. I&#8217;m looking forward to improve this guide if it didn&#8217;t help you with the installation and configuration of nginx. The idea of using spawn_fcgi and the init script for it comes <a title="ElasticDog - Howto install wordpress on Nginx" href="http://elasticdog.com/2008/02/howto-install-wordpress-on-nginx/" target="_blank">from ElasticDog.com</a>, the init script for nginx has been written by Ryan Norbauer and modified by <a title="nor - nuby on rails" href="http://nubyonrails.com/" target="_blank">Geoffrey Grosenbach</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matejunkie.com/howto-nginx-with-php-and-passenger-mod_rails-at-once/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>iPod &amp; Linux = Floola</title>
		<link>http://www.matejunkie.com/ipod-linux-floola/</link>
		<comments>http://www.matejunkie.com/ipod-linux-floola/#comments</comments>
		<pubDate>Sun, 15 Feb 2009 10:31:50 +0000</pubDate>
		<dc:creator>Mike Adolphs</dc:creator>
				<category><![CDATA[Binary Talks]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[floola]]></category>
		<category><![CDATA[getlibs]]></category>
		<category><![CDATA[ipod]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.matejunkie.net//?p=739</guid>
		<description><![CDATA[Being a Linux/Unix addicted nerd, frequently using an iPod can sometimes be a bit of an iPain (also known as iTunes). Windows user can be more pleased regarding Apple&#8217;s gadget no.1. If they don&#8217;t want to use iTunes they can stick to Winamp&#8217;s built-in iPod support or even better ml_ipod. Linux users arent&#8217;s so spoiled [...]]]></description>
			<content:encoded><![CDATA[<p>Being a Linux/Unix addicted nerd, frequently using an iPod can sometimes be a bit of an iPain (also known as iTunes). Windows user can be more pleased regarding Apple&#8217;s gadget no.1. If they don&#8217;t want to use iTunes they can stick to Winamp&#8217;s built-in iPod support or even better ml_ipod.<br />
Linux users arent&#8217;s so spoiled in the first place. There are numerous projects like gnupod, gtkpod or Amarok&#8217;s iPod integration, but most of them are outdated, don&#8217;t work with newer iPods or lack of features. If you simply want to put files on it, you&#8217;re good to go with these tools, but if you want to make use of the iPod&#8217;s picture, podcast or video features you&#8217;ll be stranded.</p>
<p>To make a long story short: If you&#8217;re a Linux addicted guy having an iPod (no iPhone, no iPod Touch, but all others) who wants to manage his collection in a Linux environment, you probably want to use <a title="Floola" href="http://www.floola.com/" target="_blank">Floola</a>. It&#8217;s a most widely platform independent program with no need to install. It comes within a single binary which makes use of a few dependent libraries, but overall you&#8217;re free to store it directly on your iPod to use it from almost anywhere.</p>
<p>So how to use it in Ubuntu/Debian?</p>
<p>First of all, download the <a title="Floola download" href="http://www.floola.com/modules/wiwimod/index.php?page=download_linux" target="_blank">tar.gz</a> from its website and extract the archive&#8217;s content in a directory you prefer.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>server:~<span style="color: #000000; font-weight: bold;">/</span>Desktop$ <span style="color: #c20cb9; font-weight: bold;">tar</span> xzf Floola-linux.tar.gz
user<span style="color: #000000; font-weight: bold;">@</span>server:~<span style="color: #000000; font-weight: bold;">/</span>Desktop$ <span style="color: #7a0874; font-weight: bold;">cd</span> Floola-linux<span style="color: #000000; font-weight: bold;">/</span>
user<span style="color: #000000; font-weight: bold;">@</span>server:~<span style="color: #000000; font-weight: bold;">/</span>Desktop<span style="color: #000000; font-weight: bold;">/</span>Floola-linux$ <span style="color: #c20cb9; font-weight: bold;">ls</span>
Floola  Readme.txt</pre></div></div>

<p>You might try to run Floola via ./Floola now, but most users, especially 64-Bit OS freaks, need to install additional 32-Bit libraries to get it working:<br />
In case you haven&#8217;t done this yet, download the <a title="Download getlibs" href="http://www.boundlesssupremacy.com/Cappy/getlibs/getlibs-all.deb" target="_blank">deb</a> of <a title="Ubuntu Forums - getlibs" href="http://ubuntuforums.org/showthread.php?t=474790" target="_blank">getlibs</a> and install it on your system. It&#8217;s a commandline tool to ease the installation of libaries. When this step is done, you&#8217;re ready to install the missing libraries as seen below.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>server:~$ getlibs <span style="color: #660033;">-32</span> libgstbase-0.10.so.0 libxine.so.1
user<span style="color: #000000; font-weight: bold;">@</span>server:~$ getlibs <span style="color: #660033;">-p</span> gstreamer0.10-alsa
user<span style="color: #000000; font-weight: bold;">@</span>server:~$ getlibs <span style="color: #660033;">-p</span> libgstreamer0.10-<span style="color: #000000;">0</span>
user<span style="color: #000000; font-weight: bold;">@</span>server:~$ getlibs <span style="color: #660033;">-p</span> libgstreamer-plugins-base0.10-<span style="color: #000000;">0</span>
user<span style="color: #000000; font-weight: bold;">@</span>server:~$ getlibs <span style="color: #660033;">-p</span> gstreamer0.10-plugins-ugly
user<span style="color: #000000; font-weight: bold;">@</span>server:~$ getlibs <span style="color: #660033;">-l</span> libmad.so.0 libmpeg2.so.0 libdvdread.so.3 liboil-0.3.so.0 libsidplay.so.1
user<span style="color: #000000; font-weight: bold;">@</span>server:~$ getlibs liba52-0.7.4.so libcdio.so.7 libid3tag.so.0</pre></div></div>

<p>After these steps you should be ready to run Floola without problems. In case of a problem you probably want to take a look into Floola&#8217;s <a title="Floola documentation" href="http://www.floola.com/modules/wiwimod/index.php?page=docs" target="_blank">documentation and FAQs</a>. They&#8217;re also running a <a title="Floola forum" href="http://www.floola.com/modules/newbb/" target="_blank">forum</a> over there where you can turn in bug reports or make suggestions for new features.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matejunkie.com/ipod-linux-floola/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Useful graphs with SmokePing</title>
		<link>http://www.matejunkie.com/useful-graphs-with-smokeping/</link>
		<comments>http://www.matejunkie.com/useful-graphs-with-smokeping/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 06:21:17 +0000</pubDate>
		<dc:creator>Mike Adolphs</dc:creator>
				<category><![CDATA[Binary Talks]]></category>
		<category><![CDATA[cgi]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[network monitoring]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[rrd]]></category>
		<category><![CDATA[smokeping]]></category>
		<category><![CDATA[speedy-cgi]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.matejunkie.net//?p=710</guid>
		<description><![CDATA[SmokePing is a useful tool developed by Tobias Oetiker and Niko Tyni which monitors and visualize one&#8217;s network latency. The (for me) most important core features are the following: A wide range of measurement plugins Master/Slave setup is possible Good-looking rrd based graphs Open Source/GPL 2 (or higher) licensed In my opinion, it does a [...]]]></description>
			<content:encoded><![CDATA[<p><a title="SmokePing - target view" href="http://www.matejunkie.com/wp-content/uploads/2009/02/smokeping_01.png" target="_blank"><img class="size-thumbnail wp-image-715 alignright" title="SmokePing - target view" src="http://www.matejunkie.com/wp-content/uploads/2009/02/smokeping_01-150x150.png" alt="SmokePing - target view" width="150" height="150" /></a><a title="SmokePing website" href="http://oss.oetiker.ch/smokeping/index.en.html" target="_blank">SmokePing</a> is a useful tool developed by Tobias Oetiker and Niko Tyni which monitors and visualize one&#8217;s network latency. The (for me) most important core features are the following:</p>
<ul>
<li>A wide range of measurement plugins</li>
<li>Master/Slave setup is possible</li>
<li>Good-looking rrd based graphs</li>
<li>Open Source/GPL 2 (or higher) licensed</li>
</ul>
<p>In my opinion, it does a really good job on longterm monitoring when there&#8217;s need of drawing graphs over a long time period. Don&#8217;t get me wrong, SmokePing is capable for shortterm monitoring as well, e.g. exploring graphs for the last couple of hours to find network outages and its integrated alerting system does a good job, but I&#8217;d suggest using more advanced network monitoring solutions like Nagios for those purposes.</p>
<p>In <a title="Ubuntu Intrepid SmokePing package" href="http://packages.ubuntu.com/intrepid/net/smokeping" target="_blank">Ubuntu</a> (Intrepid) or <a title="Debian lenny SmokePing pakacge" href="http://packages.debian.org/de/lenny/smokeping" target="_blank">Debian</a> (Lenny) the package looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>server:~$ <span style="color: #c20cb9; font-weight: bold;">aptitude</span> show smokeping
Package: smokeping
State: installed
Automatically installed: no
Version: 2.3.6-<span style="color: #000000;">1</span>
Priority: extra
Section: universe<span style="color: #000000; font-weight: bold;">/</span>net
Maintainer: Ubuntu MOTU Developers
Uncompressed Size: 2732k
Depends: <span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">&gt;</span>= 5.6.0-<span style="color: #000000;">16</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, libnet-perl, libwww-perl, libsnmp-session-perl <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">&gt;</span>= <span style="color: #000000;">0.86</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, librrds-perl
         <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">&gt;</span>= <span style="color: #000000;">1.2</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, liburi-perl, fping <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">&gt;</span>= 2.4b2-to-ipv6-<span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, speedy-cgi-perl <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">&gt;</span>= <span style="color: #000000;">2.21</span>-<span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, exim4 <span style="color: #000000; font-weight: bold;">|</span>
         mail-transport-agent, debianutils <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">&gt;</span>= <span style="color: #000000;">1.7</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, adduser, lsb-base <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">&gt;</span>= <span style="color: #000000;">3.0</span>-<span style="color: #000000;">6</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>,
         libdigest-hmac-perl, ucf <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">&gt;</span>= <span style="color: #000000;">0.28</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Recommends: apache2 <span style="color: #000000; font-weight: bold;">|</span> httpd, libsocket6-perl, dnsutils, echoping
Suggests: curl, libauthen-radius-perl, libnet-ldap-perl, libnet-dns-perl, openssh-client,
          libio-socket-ssl-perl, libnet-telnet-perl
<span style="color: #7a0874; font-weight: bold;">&#91;</span>...<span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div>

<p>It&#8217;s easily installed with all its dependencies by the following command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> smokeping</pre></div></div>

<p><a href="http://www.matejunkie.com/wp-content/uploads/2009/02/smokeping_02.png"><img class="alignleft size-thumbnail wp-image-716" title="SmokePing - detailed view" src="http://www.matejunkie.com/wp-content/uploads/2009/02/smokeping_02-150x150.png" alt="SmokePing - detailed view" width="150" height="150" /></a>The html files will be installed to /var/www/smokeping, cgi to /usr/lib/cgi-bin and SmokePing&#8217;s configuration to /etc/smokeping. If you didn&#8217;t alter the apache configuration yet, the default vhost works just perfectly. You should be able to access the web-interface right away by typing http://localhost/smokeping/ in your favorite browser. If not, you&#8217;ve probably altered your webserver&#8217;s configuration and should know how to setup a cgi-capable environment for SmokePing on your own.</p>
<p>Let&#8217;s take a deeper look on the configuration in /etc/smokeping:</p>
<ul>
<li><strong>basepage.html</strong> &#8211; contains the structure and layout for the web-interface</li>
<li><strong>config</strong> &#8211; includes all files in /etc/smokeping/config.d</li>
<li><strong>config.d</strong> &#8211; directory for the distributed configuration
<ul>
<li><strong>Alerts</strong> &#8211; configuration for the alerting system</li>
<li><strong>Database</strong> &#8211; defines rrd parameters</li>
<li><strong>General</strong> &#8211; defines general information like owner, contact, mailhost, etc.</li>
<li><strong>pathnames</strong> &#8211; various pathnames that needs to be configured</li>
<li><strong>Presentation</strong> &#8211; options to define the presentation of SmokePing</li>
<li><strong>Probes</strong> &#8211; configuration of measurement plugins</li>
<li><strong>Slaves</strong> &#8211; part of the Master/Slave setup</li>
<li><strong>Targets</strong> &#8211; configuration of targets that needs to be monitored</li>
</ul>
</li>
<li><strong>smokemail</strong> &#8211; part of configuration for dynamic IP support</li>
<li><strong>tmail</strong> &#8211; tSmoke html mail template file</li>
</ul>
<p>Now don&#8217;t get frustrated. You don&#8217;t need to alter every single config file to get SmokePing running. As you may experience, most of the default values are working like a charm.</p>
<p>Let&#8217;s begin with configuring general information in /etc/smokeping/config.d/General. Feel free to configure the mailhost, but for an initial configuration there&#8217;s no need for it.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>server:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>smokeping$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cat</span> config.d<span style="color: #000000; font-weight: bold;">/</span>General
<span style="color: #000000; font-weight: bold;">***</span> General <span style="color: #000000; font-weight: bold;">***</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">@</span>include <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>smokeping<span style="color: #000000; font-weight: bold;">/</span>config.d<span style="color: #000000; font-weight: bold;">/</span>pathnames
&nbsp;
<span style="color: #666666; font-style: italic;"># Please edit this to suit your installation</span>
owner    = Mike Adolphs
contact  = mike<span style="color: #000000; font-weight: bold;">@</span>matejunkie.com
cgiurl   = http:<span style="color: #000000; font-weight: bold;">//</span>localhost<span style="color: #000000; font-weight: bold;">/</span>cgi-bin<span style="color: #000000; font-weight: bold;">/</span>smokeping.cgi
mailhost = smtp.mailhost.abc
<span style="color: #666666; font-style: italic;"># specify this to get syslog logging</span>
syslogfacility = local0
<span style="color: #666666; font-style: italic;"># each probe is now run in its own process</span>
<span style="color: #666666; font-style: italic;"># disable this to revert to the old behaviour</span>
<span style="color: #666666; font-style: italic;"># concurrentprobes = no</span></pre></div></div>

<p>The next file you probably want to configure is /etc/smokeping/config.d/Probes. There you&#8217;ll be able to define other measurement plugins besides ICMP. In the following example I&#8217;ve defined DNS and HTTP measurement methods. Each of the measurement plugins comes with various configuration parameters like pings, step, urlformat or else. Each plugin make use of the binary parameter. For a complete list of parameters you should consider the <a title="SmokePing documentation - configuration" href="http://oss.oetiker.ch/smokeping/doc/smokeping_config.en.html" target="_blank">official documentation</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>server:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>smokeping$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cat</span> config.d<span style="color: #000000; font-weight: bold;">/</span>Probes
<span style="color: #000000; font-weight: bold;">***</span> Probes <span style="color: #000000; font-weight: bold;">***</span>
&nbsp;
+ FPing
&nbsp;
binary = <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>fping
&nbsp;
+ DNS
&nbsp;
binary = <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>dig
pings = <span style="color: #000000;">5</span>
step = <span style="color: #000000;">180</span>
&nbsp;
+ Curl
&nbsp;
binary = <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>curl
pings = <span style="color: #000000;">5</span>
step = <span style="color: #000000;">60</span>
urlformat = http:<span style="color: #000000; font-weight: bold;">//%</span>host<span style="color: #000000; font-weight: bold;">%/</span></pre></div></div>

<p>The third and final configuration file for our initial configuration is /etc/smokeping/config.d/Targets where you&#8217;re able to define the targets that needs to be monitored. The layout of the configuration file is straight-forward. Therefore I won&#8217;t explain the various parameters in detail.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>server:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>smokeping$ <span style="color: #c20cb9; font-weight: bold;">cat</span> config.d<span style="color: #000000; font-weight: bold;">/</span>Targets
<span style="color: #000000; font-weight: bold;">***</span> Targets <span style="color: #000000; font-weight: bold;">***</span>                                              
&nbsp;
probe = FPing
&nbsp;
<span style="color: #666666; font-style: italic;">## You have to edit and uncomment all what you want below this.</span>
<span style="color: #666666; font-style: italic;"># Please, refer to smokeping_config man page for more info</span>
<span style="color: #666666; font-style: italic;"># The given adresses aren't real to avoid DoS.                 </span>
&nbsp;
menu = Top
title = Network Latency Grapher
remark = Welcome to the SmokePing website of Mike Adolphs.
&nbsp;
+ slashdot
&nbsp;
menu = slashdot
title = slashdot
&nbsp;
++ ICMP
&nbsp;
probe = FPing
menu = ICMP
title = ICMP
host = www.slashdot.org
&nbsp;
++ HTTP
&nbsp;
probe = Curl
menu = HTTP
title = HTTP
host = www.slashdot.org
&nbsp;
++ DNS
&nbsp;
probe = DNS
menu = DNS
title = DNS
lookup = www.slashdot.org
server = 141.1.1.1
host = www.slashdot.org</pre></div></div>

<p>As Ubuntu uses speedy-cgi with SmokePing&#8217;s cgi script its interpretation becomes persistent (and much faster in its execution in large environments). Therefore you have to touch /etc/smokeping/config when you&#8217;ve altered the configuration! Otherwise the changed configuration parts in /etc/smokeping/config.d won&#8217;t be recognized.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>server:~$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>smokeping<span style="color: #000000; font-weight: bold;">/</span>config</pre></div></div>

<p>You&#8217;re also free to change the interpreter from /usr/bin/speedy to /usr/bin/perl in the smokeping.cgi to disable the persistent behaviour:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>server:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>cgi-bin$ <span style="color: #c20cb9; font-weight: bold;">head</span> <span style="color: #660033;">-n2</span> smokeping.cgi
<span style="color: #666666; font-style: italic;">#!/usr/bin/speedy</span>
<span style="color: #666666; font-style: italic;"># -*-perl-*-</span></pre></div></div>

<p>&#8230; to &#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>server:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>cgi-bin$ <span style="color: #c20cb9; font-weight: bold;">head</span> <span style="color: #660033;">-n2</span> smokeping.cgi
<span style="color: #666666; font-style: italic;">#!/usr/bin/perl</span>
<span style="color: #666666; font-style: italic;"># -*-speedy-*-</span></pre></div></div>

<p><a href="http://www.matejunkie.com/wp-content/uploads/2009/02/smokeping_03.png"><img class="alignright size-thumbnail wp-image-717" title="SmokePing - graph exploration" src="http://www.matejunkie.com/wp-content/uploads/2009/02/smokeping_03-150x150.png" alt="SmokePing - graph exploration" width="150" height="150" /></a>One more note on reloading the daemon: In most cases it&#8217;s simply not necessary. SmokePing recognizes changes in the /etc/smokeping/config.d directory during runtime when you&#8217;re using /usr/bin/perl as the interpreter instead of the persistant method with speedy. But as I already said, for me SmokePing is a method to provide longterm monitoring without major changes to the targets. Therefore I don&#8217;t make use of these features and stick to the speedy way. Touching the file is not much of a problem, reloading the daemon a safe way to see whether there are syntax errors in the configuration or not.</p>
<p>If you want more information (you probably will), stick to the <a title="SmokePing documentation" href="http://oss.oetiker.ch/smokeping/doc/index.en.html" target="_blank">official documentation</a> or sign up and dig through the <a title="Smokeping mailing-list archives" href="https://lists.oetiker.ch/pipermail/smokeping-users/" target="_blank">archives</a> of the <a title="SmokePing mailing list" href="http://oss.oetiker.ch/smokeping/support.en.html" target="_blank">mailing list</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matejunkie.com/useful-graphs-with-smokeping/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>GeoIP Lookups</title>
		<link>http://www.matejunkie.com/geoip-lookups/</link>
		<comments>http://www.matejunkie.com/geoip-lookups/#comments</comments>
		<pubDate>Sat, 07 Feb 2009 06:34:16 +0000</pubDate>
		<dc:creator>Mike Adolphs</dc:creator>
				<category><![CDATA[Binary Talks]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[geoip]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[maxmind]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.matejunkie.net//?p=667</guid>
		<description><![CDATA[If you want to know the location of a server connected to the Internet, you need a tiny, useful tool called geoiplookup. In Debian or Ubuntu the installation is quite easy: sudo aptitude install geoip-bin After installation you&#8217;re able to use geoiplookup from the command line: user@server:~$ geoiplookup www.heise.de GeoIP Country Edition: DE, Germany But [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to know the location of a server connected to the Internet, you need a tiny, useful tool called geoiplookup. In Debian or Ubuntu the installation is quite easy:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> geoip-bin</pre></div></div>

<p>After installation you&#8217;re able to use geoiplookup from the command line:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>server:~$ geoiplookup www.heise.de
GeoIP Country Edition: DE, Germany</pre></div></div>

<p>But that&#8217;ll only show you the country of the server&#8217;s location. For more precise information <a title="MaxMind" href="http://www.maxmind.com/" target="_blank">MaxMind</a>&#8216;s <a title="MaxMind's LGPL GeoIP database license" href="http://geolite.maxmind.com/download/geoip/database/LICENSE.txt" target="_blank">LGPL version</a> of their GeoIP database comes in handy. It&#8217;s being updated at the beginning of each month and available via <a title="MaxMind's LGPL GeoIP database" href="http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz" target="_blank">this link</a> (approx. 30 MB).</p>
<p>Simply download the archive, gunzip it and move it to the proper location:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">gunzip</span> GeoLiteCity.dat.gz
<span style="color: #c20cb9; font-weight: bold;">mv</span> GeoLiteCity.dat <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>GeoIP<span style="color: #000000; font-weight: bold;">/</span>GeoIPCity.dat</pre></div></div>

<p>After that, geoiplookup returns more accurate location details on a city-level:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>server:~$ geoiplookup www.heise.de
GeoIP Country Edition: DE, Germany
GeoIP City Edition, Rev <span style="color: #000000;">1</span>: DE, 06, Hanover, <span style="color: #7a0874; font-weight: bold;">&#40;</span>null<span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">52.366699</span>, <span style="color: #000000;">9.716700</span>, <span style="color: #000000;">0</span>, <span style="color: #000000;">0</span>
GeoIP City Edition, Rev <span style="color: #000000;">0</span>: DE, 06, Hanover, <span style="color: #7a0874; font-weight: bold;">&#40;</span>null<span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">52.366699</span>, <span style="color: #000000;">9.716700</span></pre></div></div>

<p>Tossing longitude and latitude to Google Maps it&#8217;ll show the location of the Heise Verlag&#8217;s office, although the servers are running in Frankfurt/Main 350 kilometers south of Hannover.</p>
<div align="center"><iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=52.366699,+9.716700&amp;sll=51.206883,9.519653&amp;sspn=2.557072,4.053955&amp;ie=UTF8&amp;t=h&amp;s=AARTsJqtAGWWoTH8WVT5d-7AcAk-mwScew&amp;ll=52.372036,9.723501&amp;spn=0.018341,0.036478&amp;z=14&amp;iwloc=addr&amp;output=embed"></iframe><br /><small><a href="http://maps.google.com/maps?f=q&amp;source=embed&amp;hl=en&amp;geocode=&amp;q=52.366699,+9.716700&amp;sll=51.206883,9.519653&amp;sspn=2.557072,4.053955&amp;ie=UTF8&amp;t=h&amp;ll=52.372036,9.723501&amp;spn=0.018341,0.036478&amp;z=14&amp;iwloc=addr" style="color:#0000FF;text-align:left">View Larger Map</a></small></div>
<p>If you want to keep the information up to date you should create a small script, triggered by a cronjob running at 1:30am on the third day of each month.</p>
<p>The cronjob, assuming you define cronjobs via /etc/crontab:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000;">30</span> <span style="color: #000000;">1</span> <span style="color: #000000;">3</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> root <span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>scripts<span style="color: #000000; font-weight: bold;">/</span>update_geoip_db.sh</pre></div></div>

<p>The &#8220;script&#8221;:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #660033;">-t</span> <span style="color: #000000;">5</span> <span style="color: #ff0000;">&quot;http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">gunzip</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>scripts<span style="color: #000000; font-weight: bold;">/</span>GeoLiteCity.dat.gz
<span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>scripts<span style="color: #000000; font-weight: bold;">/</span>GeoLiteCity.dat <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>GeoIP<span style="color: #000000; font-weight: bold;">/</span>GeoIPCity.dat</pre></div></div>

<p>On the console you usually won&#8217;t get more detailed information, because MaxMind doesn&#8217;t include all their knowledge in the LGPL version of their GeoIP databases. In case you need additional information you might want to use MaxMind&#8217;s freely accessible <a title="GeoIP lookup web-interface" href="http://www.maxmind.com/app/locate_ip" target="_blank">web-interface</a> which uses some of the purchasable databases as its backend.</p>
<p>But don&#8217;t expect to get information on a district, street or even house number level. That&#8217;s simply not possible due to the common IP address block allocation and the fact that most of the information is gathered from whois data, which mostly doesn&#8217;t include the &#8220;end user&#8217;s&#8221; location rather than the ISP&#8217;s office address.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matejunkie.com/geoip-lookups/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
