<?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>No pain no gain</title>
	<atom:link href="http://www.dikant.de/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dikant.de</link>
	<description>Personal blog of Peter Dikant</description>
	<lastBuildDate>Sun, 23 May 2010 20:57:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Prevent Time Machine Backup Resizing</title>
		<link>http://www.dikant.de/2010/05/23/prevent-time-machine-backup-resizing/</link>
		<comments>http://www.dikant.de/2010/05/23/prevent-time-machine-backup-resizing/#comments</comments>
		<pubDate>Sun, 23 May 2010 20:57:46 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[TimeMachine]]></category>

		<guid isPermaLink="false">http://www.dikant.de/?p=118</guid>
		<description><![CDATA[If you are using Time Machine to backup your Mac onto a network share, you might have noticed, that since the Snow Leopard 10.6.3 update the sparsebundle image used by Time Machine has been resized to use the whole capacity &#8230; <a href="http://www.dikant.de/2010/05/23/prevent-time-machine-backup-resizing/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you are using Time Machine to backup your Mac onto a network share, you might have noticed, that since the Snow Leopard 10.6.3 update the sparsebundle image used by Time Machine has been resized to use the whole capacity of your network share.</p>
<p>I use a Qnap NAS as a central network storage for backing up mulitple Macs and therefore I want to define strict limits for the maximum size of each Time Machine backup. So after noticing the new image sizes, I tried to resize them with hdiutil:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">hdiutil resize <span style="color: #660033;">-size</span> 500g MYBUNDLENAME.sparsebundle</pre></div></div>

<p>Unfortunately Time Machine resizes the image size every time it runs, so it is necessary to prevent it from resizing the image. </p>
<p>The image size of a sparsebundle is stored in the Info.plist file inside the bundle directory, so I tried to remove write permissions to that file from the terminal:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>Volumes<span style="color: #000000; font-weight: bold;">/</span>MYSHARE<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">chmod</span> a-w MYBUNDLENAME.sparsebundle<span style="color: #000000; font-weight: bold;">/</span>Info.<span style="color: #000000; font-weight: bold;">*</span></pre></div></div>

<p>This wasn&#8217;t working either, because OSX seems to reset the permissions to Info.plist automatically.</p>
<p>The solution which is finally working for me was to login to my Qnap box via SSH and change the permissions there via chmod:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chmod</span> a-w MYBUNDLENAME.sparsebundle<span style="color: #000000; font-weight: bold;">/</span>Info.<span style="color: #000000; font-weight: bold;">*</span></pre></div></div>

<p>Now, when Time Machine starts, it tries to resize the image but fails, as the Qnap server is preventing any changes to the Info.plist file. You can see this behavior in the system.log:</p>

<div class="wp_syntax"><div class="code"><pre class="log" style="font-family:monospace;">23.05.10 22:29:13	com.apple.backupd[378] Resizing backup disk image from 500.0 GB to 989.8 GB
23.05.10 22:29:13	com.apple.backupd[378] Could not resize backup disk image (DIHLResizeImage returned 35)</pre></div></div>

<p>After this logging message, the rest of the backup runs fine. For me this is a nice workaround until there is an official way to limit the backup size.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dikant.de/2010/05/23/prevent-time-machine-backup-resizing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>High Scalability with Hadoop</title>
		<link>http://www.dikant.de/2010/04/02/high-scalability-with-hadoop/</link>
		<comments>http://www.dikant.de/2010/04/02/high-scalability-with-hadoop/#comments</comments>
		<pubDate>Fri, 02 Apr 2010 18:29:45 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Hadoop]]></category>

		<guid isPermaLink="false">http://www.dikant.de/?p=113</guid>
		<description><![CDATA[Currently I am involved in building a highly scalable logging infrastructure which is based on Apache Hadoop. Hadoop is a system to store and process huge amounts of data. I started writing up an article series about this topic on &#8230; <a href="http://www.dikant.de/2010/04/02/high-scalability-with-hadoop/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Currently I am involved in building a highly scalable logging infrastructure which is based on <a href="http://hadoop.apache.org/">Apache Hadoop</a>. Hadoop is a system to store and process huge amounts of data. I started writing up an article series about this topic on my companies blog.</p>
<p>Please take a look: <a href="http://blog.mgm-tp.com/2010/03/hadoop-log-management-part1/">See You, SQL &#8211; Hello Hadoop</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dikant.de/2010/04/02/high-scalability-with-hadoop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Running Mercurial with FastCGI in nginx</title>
		<link>http://www.dikant.de/2009/07/29/running-mercurial-with-fastcgi-in-nginx/</link>
		<comments>http://www.dikant.de/2009/07/29/running-mercurial-with-fastcgi-in-nginx/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 19:07:45 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[nginx]]></category>
		<category><![CDATA[FastCGI]]></category>
		<category><![CDATA[Mercurial]]></category>

		<guid isPermaLink="false">http://www.dikant.de/?p=88</guid>
		<description><![CDATA[Mercurial is a so called DRCS (Distributed Revision Control System). I have been using Subversion for a couple of years, both at work and for my own projects. Now I thought it was about time to try something different. But &#8230; <a href="http://www.dikant.de/2009/07/29/running-mercurial-with-fastcgi-in-nginx/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.selenic.com/mercurial/"><img src="http://www.dikant.de/wp-content/uploads/2009/07/logo-droplets-200.png" alt="logo-droplets-200" title="logo-droplets-200" width="100" height="120" class="alignleft size-thumbnail wp-image-91" /></a> <a href="http://www.selenic.com/mercurial/">Mercurial</a> is a so called DRCS (Distributed Revision Control System). I have been using <a href="http://subversion.tigris.org/">Subversion</a> for a couple of years, both at work and for my own projects. Now I thought it was about time to try something different.</p>
<p>But first, why do I want to switch from SVN to Mercurial? Basically the most appealing argument for me was the fact, that with Mercurial I am able to work offline with my repository. Besides that, I always had issues with the way SVN was handling tags and branches. Especially merging changes from a branch back into the trunk was always a pain. I did not need to use that functionality often but when I did, I always ended up doing it twice, because I could not remember which way to do it right.</p>
<p><span id="more-88"></span></p>
<p>So, in this article I will describe my setup of Mercurial served via FastCGI behind the nginx webserver. The approach is similar to the integration of PHP into nginx. You need the spawn-fcgi tool from the <a href="http://www.lighttpd.net/">lighttpd</a> distribution. The following steps should work on a recent Debian or Ubuntu distribution.</p>
<p>The first step is to install Mercurial and some necessary libraries to create the fcgi-wrapper for Mercurial:</p>

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

<p>Now you can already start defining your Mercurial repositories. Here are some steps to create a small example repository:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>tmp
hg init hgtest
<span style="color: #7a0874; font-weight: bold;">cd</span> hgtest
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Hello world.&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> readme.txt
hg add readme.txt
hg commit <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;Initial commit&quot;</span></pre></div></div>

<p>You now have a Mercurial repository with a single file. The command <code>hg log</code> should show you a single changeset with our commit comment.</p>
<p>Now, let&#8217;s start configuring nginx to integrate Mercurial. We will use FastCGI talk connect Mercurial to nginx. User authentication will be done via nginx. It is a good idea to use HTTPS for communication with Mercurial, but we will focus on a standard HTTP setup.</p>
<p>Let&#8217;s setup a virtual host for Mercurial. Open <code>/etc/nginx/sites-available/your_domain_name</code> and add the following server definition:</p>

<div class="wp_syntax"><div class="code"><pre class="nginx" style="font-family:monospace;">server {
        listen 80;
        server_name YOUR_MERCURIAL_DOMAIN;
&nbsp;
        location / {
                auth_basic &quot;Secure Login&quot;;
                auth_basic_user_file /tmp/mercurial_users;
                fastcgi_pass 127.0.0.1:9001;
                fastcgi_param SCRIPT_FILENAME /tmp$fastcgi_script_name;
                fastcgi_param PATH_INFO $uri;
                fastcgi_param REMOTE_USER $remote_user;
                include fastcgi_params;
        }       
}</pre></div></div>

<p>The above settings will setup a new virtual host, where all traffic is redirected to the Mercurial FastCGI wrapper. It is important that you forward the <code>PATH_INFO</code> and <code>REMOTE_USER</code> variables. Mercurial will not work correctly without these.</p>
<p>Now reload the nginx configuration:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><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 reload</pre></div></div>

<p>And create the password file:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">htpasswd <span style="color: #660033;">-c</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>mercurial_users MYLOGIN</pre></div></div>

<p>Mercurial uses a central configuration file. In this file we can specify locations for our mercurial repositories. The following file will enable all mercurial repositories found in the <code>/tmp</code> directory. It also changes the theme to <code>gitweb</code> which is a bit clearer than the default theme. Create the file <code>/tmp/hgweb.config</code> with the following contents:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;"><span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>collections<span style="">&#93;</span></span>
/tmp <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> /tmp</span>
&nbsp;
<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>web<span style="">&#93;</span></span>
<span style="color: #000099;">style</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> gitweb</span>
<span style="color: #000099;">baseurl</span> <span style="color: #000066; font-weight:bold;">=</span></pre></div></div>

<p>Mercurial uses a second configuration file for each repository where you may specify details about the repository and security settings like who may push changes into the repository. The configuration should be placed into the file <code>/tmp/hgtest/.hg/hgrc</code> and could look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>web<span style="color: #7a0874; font-weight: bold;">&#93;</span>
contact = YOUR NAME
description = DESCRIPTION OF PROJECT
style = gitweb
push_ssl = <span style="color: #c20cb9; font-weight: bold;">false</span>
allow_archive = bz2 gz <span style="color: #c20cb9; font-weight: bold;">zip</span>
allow_push = LOGIN_NAME</pre></div></div>

<p>Now we need to grab the following script from the Mercurial repository and place it into the <code>/tmp</code> directory: <a href="http://selenic.com/repo/hg/raw-file/tip/contrib/hgwebdir.fcgi">http://selenic.com/repo/hg/raw-file/tip/contrib/hgwebdir.fcgi</a>. Now edit this file and replace the line <code>WSGIServer(hgwebdir('hgweb.config')).run()</code> with <code>WSGIServer(hgwebdir('/tmp/hgweb.config')).run()</code>.</p>
<p>The last step is to set the correct filesystem rights for your repository:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #660033;">-R</span> www-data.www-data <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>hgtest</pre></div></div>

<p>That&#8217;s it. Now we can start the FastCGI process via:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">spawn-fcgi <span style="color: #660033;">-a</span> 127.0.0.1 <span style="color: #660033;">-p</span> <span style="color: #000000;">9001</span> <span style="color: #660033;">-u</span> www-data <span style="color: #660033;">-g</span> www-data <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>hgwebdir.fcgi <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-mercurial.pid <span style="color: #660033;">-C</span> <span style="color: #000000;">1</span></pre></div></div>

<p>It makes sense to write the above line into <code>/etc/rc.local</code> so that it will start up automatically when you reboot the server.</p>
<p>Further information about configuring your Mercurial server can be found in the <a href="http://mercurial.selenic.com/wiki/PublishingRepositories">Mercurial Wiki</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dikant.de/2009/07/29/running-mercurial-with-fastcgi-in-nginx/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Nginx rewrite rules for SilverStripe CMS</title>
		<link>http://www.dikant.de/2009/06/20/nginx-rewrite-rules-for-silverstripe-cms/</link>
		<comments>http://www.dikant.de/2009/06/20/nginx-rewrite-rules-for-silverstripe-cms/#comments</comments>
		<pubDate>Sat, 20 Jun 2009 14:07:32 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://www.dikant.de/?p=85</guid>
		<description><![CDATA[If you are using Nginx with a configuration that is directly serving php pages via FastCGI, you need to adapt the rewrite rules to Nginx. In the case of the CMS-system SilverStripe this is not really straight forward. The original &#8230; <a href="http://www.dikant.de/2009/06/20/nginx-rewrite-rules-for-silverstripe-cms/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you are using Nginx with a configuration that is directly serving php pages via FastCGI, you need to adapt the rewrite rules to Nginx. In the case of the CMS-system <a href="http://www.silverstripe.org/">SilverStripe</a> this is not  really straight forward. The original rewrite definition in the <code>.htaccess</code> file looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;">&lt;<span style="color: #000000; font-weight:bold;">IfModule</span> mod_rewrite.c&gt;
<span style="color: #00007f;">RewriteEngine</span> <span style="color: #0000ff;">On</span>
<span style="color: #00007f;">RewriteBase</span> /
&nbsp;
<span style="color: #00007f;">RewriteCond</span> %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)$
&nbsp;
<span style="color: #00007f;">RewriteCond</span> %{REQUEST_URI} ^(.*)$
<span style="color: #00007f;">RewriteCond</span> %{REQUEST_FILENAME} !-f
<span style="color: #00007f;">RewriteRule</span> .* sapphire/main.php?url=%1&amp;%{QUERY_STRING} [L]
&lt;/<span style="color: #000000; font-weight:bold;">IfModule</span>&gt;</pre></div></div>

<p>So every file which does not end in .gif, .jpg, .png, .css, .js and .php and where the file does not exist will be rewritten.</p>
<p>I chose a somehow stripped down version of these rules which looks in Nginx notation like this:</p>

<div class="wp_syntax"><div class="code"><pre class="nginx" style="font-family:monospace;">if (!-f $request_filename) {
    rewrite ^/(.*?)(\?|$)(.*)$ /sapphire/main.php?url=$1&amp;$3 last;
}</pre></div></div>

<p>If a requested file is not found, the rewriting engine will parse the request string for all elements before a &#8216;?&#8217;. This substring will be pasted as the url parameter to main.php. Everything after &#8216;?&#8217; will be added as additional parameters. This rewrite rule seems to be working and I haven&#8217;t encountered any problems so far.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dikant.de/2009/06/20/nginx-rewrite-rules-for-silverstripe-cms/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Securing SSH server with fail2ban</title>
		<link>http://www.dikant.de/2009/06/19/securing-ssh-server-with-fail2ban/</link>
		<comments>http://www.dikant.de/2009/06/19/securing-ssh-server-with-fail2ban/#comments</comments>
		<pubDate>Fri, 19 Jun 2009 17:06:02 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.dikant.de/?p=76</guid>
		<description><![CDATA[When you are running your SSH server on the standard port 22, you likely see brute force login attempts multiple times a day. The SSH server does not limit unsuccessfull login attempts by itself. So there are multiple ways to &#8230; <a href="http://www.dikant.de/2009/06/19/securing-ssh-server-with-fail2ban/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When you are running your SSH server on the standard port 22, you likely see brute force login attempts multiple times a day. The SSH server does not limit unsuccessfull login attempts by itself. So there are multiple ways to deal with this problem.</p>
<p>One option is to move the SSH daemon to a non-standard port. But this means that you might get problems connecting yourself to the server if you are working from a restricted network. So another solution would be to use certificates for login. But then you need to make sure that you carry the certificates with you when you want to login to your server.</p>
<p>Now a good solution is to limit access to the SSH server. One way would be to use the so called port-knocking approach. Here the access to the SSH port is blocked until you use some kind of secret knock-sequence. Then the port will be unblocked for your IP for a certain time. This is very effective but has the downside that you always need to use this knock mechanism before connecting to your server.</p>
<p><span id="more-76"></span></p>
<p>What I prefer is a mechanism which works the other way around. The access to the SSH port is open until there are a number of failed login attempts detected. If this is the case, the IP address these login attempts came from will be blocked for a couple of hours. This approach is less secure then the port knocking approach but is a lot more convenient for me. As long is I don&#8217;t mess up multiple times with the login, I do not even notice any security restrictions. Brute force attacks on the other hand are blocked right away.</p>
<p>The most common tool for this task is the excellent <a href="http://www.fail2ban.org">fail2ban</a>. On a Debian system it can be installed via <code>aptitude</code>:</p>

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

<p>The default configuration is already useful. It will secure the SSH daemon with a blocking time of 10 minutes after 6 failed login attempts. The configuration files can be found in the directory <code>/etc/fail2ban</code>.</p>
<p>You can change the blocking time in the file <code>/etc/fail2ban/jail.conf</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="config" style="font-family:monospace;">[DEFAULT]
bantime  = 7200
maxretry = 4</pre></div></div>

<p>This will change the default settings which apply if not specified otherwise in the application settings. The setting <code>bantime</code> is specified in seconds and defines how long the blocked IP will not be able to connect to the blocked service. <code>maxretry</code> is the number of failed login attempts.</p>
<p>Lets take a look at the ssh setting:</p>

<div class="wp_syntax"><div class="code"><pre class="config" style="font-family:monospace;">[ssh]
enabled = true
port    = ssh
filter  = sshd
logpath  = /var/log/auth.log
maxretry = 3</pre></div></div>

<p>You can enable or disable the monitoring of specific services (ports). The ssh monitoring uses the <code>auth.log</code> file to detect failed login attempts.</p>
<p>To activate changed configuration settings, just reload the service:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><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>fail2ban force-reload</pre></div></div>

<p>So what happens when an IP is blocked? Once the login attempt limit has been reached, the IP address will be blocked via iptables. Here is the output of iptables on my system:</p>

<div class="wp_syntax"><div class="code"><pre class="config" style="font-family:monospace;">Chain INPUT (policy ACCEPT)
target     prot opt source               destination
fail2ban-ssh  tcp  --  0.0.0.0/0            0.0.0.0/0           multiport dports 22
&nbsp;
Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
&nbsp;
Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
&nbsp;
Chain fail2ban-ssh (1 references)
target     prot opt source               destination
DROP       all  --  123.456.789.012        0.0.0.0/0
RETURN     all  --  0.0.0.0/0            0.0.0.0/0</pre></div></div>

<p>I have replaced the blocked IP address with some default numbers, but you can see that all traffic from this IP address to the port 22 will be blocked. This iptables rule will be automatically removed after the specified blockout time.</p>
<p>fail2ban is an effective tool to lock out brute force login attempts. It is really easy to setup and can be used to monitor multiple services besides SSH.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dikant.de/2009/06/19/securing-ssh-server-with-fail2ban/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Setting up PureFTPD on a virtual server</title>
		<link>http://www.dikant.de/2009/01/22/setting-up-pureftpd-on-a-virtual-server/</link>
		<comments>http://www.dikant.de/2009/01/22/setting-up-pureftpd-on-a-virtual-server/#comments</comments>
		<pubDate>Thu, 22 Jan 2009 19:21:46 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[FTP]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PureFTP]]></category>

		<guid isPermaLink="false">http://www.dikant.de/?p=56</guid>
		<description><![CDATA[PureFTPD is a secure and easy to configure FTP server. It has all the features you usually need, like TLS encryption, virtual users, quotas and limits. The only downside is that PureFTPD is not easy to install on a virtual &#8230; <a href="http://www.dikant.de/2009/01/22/setting-up-pureftpd-on-a-virtual-server/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.dikant.de/wp-content/uploads/2009/01/pure-ftpd.png" alt="PureFTPD Logo" title="PureFTPD Logo" width="224" height="64" class="alignleft size-full wp-image-55" /> <a href="http://www.pureftpd.org">PureFTPD</a> is a secure and easy to configure FTP server. It has all the features you usually need, like TLS encryption, virtual users, quotas and limits. The only downside is that PureFTPD is not easy to install on a virtual server because the default Debian package is compiled with some options that are not supported by the standard OpenVZ and Virtuozzo kernels. Therefore you need to recompile PureFTPD with some reasonable settings. In This post I will explain how to do that and do a basic service setup.</p>
<p><span id="more-56"></span></p>
<p>First you could try to install the default Debian package to check whether you need to recompile PureFTPD. This can be done via:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> pure-ftpd-common pure-ftpd</pre></div></div>

<p>The following steps are needed to recompile the package with the necessary options to make it run on a virtual server. You only need to do these steps if you find the following message in your syslog when trying to connect to the ftp server:</p>

<div class="wp_syntax"><div class="code"><pre class="syslog" style="font-family:monospace;"> pure-ftpd: (?@?) [ERROR] Unable to switch capabilities : Operation not permitted</pre></div></div>

<p>In that case, make sure that you have enabled the Debian source repositories in your <code>/etc/apt/sources.list</code> and fetch the source files via:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #7a0874; font-weight: bold;">source</span> pure-ftpd</pre></div></div>

<p>The source files have now been downloaded to your current directory. There should now some new files and a directory <code>pure-ftpd-1.0.21</code>. Enter this directory and edit the file <code>debian/rules</code> you should change the line starting with <code>optflags</code> and add <code>--without-capabilities</code> to that line, so that it looks like:</p>

<div class="wp_syntax"><div class="code"><pre class="make" style="font-family:monospace;">optflags<span style="color: #004400;">=--</span>with<span style="color: #004400;">-</span>everything <span style="color: #004400;">--</span>with<span style="color: #004400;">-</span>largefile <span style="color: #004400;">--</span>with<span style="color: #004400;">-</span>pam <span style="color: #004400;">--</span>with<span style="color: #004400;">-</span>privsep <span style="color: #004400;">--</span>with<span style="color: #004400;">-</span>tls <span style="color: #004400;">--</span>without<span style="color: #004400;">-</span>capabilities</pre></div></div>

<p>Now grab the dependencies needed to build the source and compile the Debian installation package:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> build-dep pure-ftpd
dpkg-buildpackage <span style="color: #660033;">-uc</span> <span style="color: #660033;">-b</span></pre></div></div>

<p>The resulting Debian package should now have been built without errors and you can install it via:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">dpkg</span> <span style="color: #660033;">-i</span> ..<span style="color: #000000; font-weight: bold;">/</span>pure-ftpd_1.0.1-<span style="color: #000000;">8</span>_i386.deb</pre></div></div>

<p>The filename of the package might vary depending on the current patch level in the Debian repository.</p>
<p>When installing the package you will be asked whether to use a chrooted setup which you should do and if you prefer a standalone installation or inetd-based operation. For low volume sites I would prefer the inetd installation.</p>
<p>Now let&#8217;s get on to the configuration of PureFTPD. I prefer a setup using virtual users which are mapped to a central user account on the server. So I usually create a new account without a shell or home directory which belongs to the Apache user group to have access to hosted webs:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">useradd <span style="color: #660033;">-g</span> www-data <span style="color: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">false</span> ftpuser</pre></div></div>

<p>The configuration of PureFTP is done via distinct files in the directory <code>/etc/pure-ftpd/conf</code>. Each file contains a single configuration setting and we can setup a decent configuration with the following commands:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>pure-ftpd<span style="color: #000000; font-weight: bold;">/</span>conf
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #c20cb9; font-weight: bold;">yes</span> <span style="color: #000000; font-weight: bold;">&gt;</span> ChrootEveryone
<span style="color: #7a0874; font-weight: bold;">echo</span> no <span style="color: #000000; font-weight: bold;">&gt;</span> PAMAuthentication
<span style="color: #7a0874; font-weight: bold;">echo</span> no <span style="color: #000000; font-weight: bold;">&gt;</span> UnixAuthentication
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">&gt;</span> TLS
<span style="color: #7a0874; font-weight: bold;">cd</span> ..<span style="color: #000000; font-weight: bold;">/</span>auth
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> ..<span style="color: #000000; font-weight: bold;">/</span>conf<span style="color: #000000; font-weight: bold;">/</span>PureDB 50pure</pre></div></div>

<p>With the above settings we disable all authentication methods except the internal PureFTPD user database. We also lock down each user into a chroot-environment and enable secure authentication via TLS. PureFTPD excepts a certificate in the file <code>/etc/ssl/private/pure-ftpd.pem</code>. You could copy your apache certificate to that file, or generate a new one via:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">openssl req <span style="color: #660033;">-new</span> <span style="color: #660033;">-x509</span> <span style="color: #660033;">-days</span> <span style="color: #000000;">4312</span> <span style="color: #660033;">-nodes</span> <span style="color: #660033;">-keyout</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ssl<span style="color: #000000; font-weight: bold;">/</span>private<span style="color: #000000; font-weight: bold;">/</span>pure-ftpd.pem <span style="color: #660033;">-out</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ssl<span style="color: #000000; font-weight: bold;">/</span>private<span style="color: #000000; font-weight: bold;">/</span>pure-ftpd.pem</pre></div></div>

<p>The user administration and setup is now done with the PureFTPD tool <code>pure-pw</code>. You can add a new user via:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">pure-pw useradd myusername <span style="color: #660033;">-u</span> ftpuser <span style="color: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>homedir</pre></div></div>

<p>The above command will ask you for a password and register the user which is mapped to the system user <code>ftpuser</code> within PureFTPD. Every time you modify the user database you need to rebuild the PureFTPD user configuration via:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">pure-pw mkdb</pre></div></div>

<p>Now you should be able to connect to your server with secure authorization with the newly created user.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dikant.de/2009/01/22/setting-up-pureftpd-on-a-virtual-server/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Setting up the OSX terminal application</title>
		<link>http://www.dikant.de/2009/01/17/setting-up-the-osx-terminal-application/</link>
		<comments>http://www.dikant.de/2009/01/17/setting-up-the-osx-terminal-application/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 23:02:54 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Mac]]></category>

		<guid isPermaLink="false">http://www.dikant.de/?p=50</guid>
		<description><![CDATA[By default the terminal app in OSX is not configured the way you are used to on a Linux system. There is no color output for ls and things like page up and page down are not working via SSH. &#8230; <a href="http://www.dikant.de/2009/01/17/setting-up-the-osx-terminal-application/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>By default the terminal app in OSX is not configured the way you are used to on a Linux system. There is no color output for <code>ls</code> and things like page up and page down are not working via SSH. Fortunately this can be corrected with some small configuration tweaks.</p>
<p>The first thing is to open the prefenreces panel and set the &#8220;Pro&#8221; theme as the standard theme. I also like to activate text antialiasing. My font of choice is &#8220;Monaco 12pt.&#8221;.</p>
<p>To enable the page down, page up, home and end keys you need to go to the keyboard tab and set the following key actions:</p>
<p>Home = \033[1~<br />
End = \033[4~<br />
Page Up = \033[5~<br />
Page Down = \033[6~</p>
<p>To activate colored output for ls with a decent color scheme that works well on a dark background, create a file <code>.profile</code> in your home directory with the following contents:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">CLICOLOR</span>=<span style="color: #000000;">1</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">LSCOLORS</span>=cxexcxdxbxfxfxbxbxcxcx</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.dikant.de/2009/01/17/setting-up-the-osx-terminal-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nginx as a reverse proxy for Apache</title>
		<link>http://www.dikant.de/2008/07/10/nginx-as-a-reverse-proxy-for-apache/</link>
		<comments>http://www.dikant.de/2008/07/10/nginx-as-a-reverse-proxy-for-apache/#comments</comments>
		<pubDate>Thu, 10 Jul 2008 20:56:27 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://www.dikant.de/?p=48</guid>
		<description><![CDATA[While Apache is a great server for delivering dynamic content and especially hosting PHP-based websites, it has a high memory footprint and a high overhead when forking new worker processes during high server load. In this article I will describe &#8230; <a href="http://www.dikant.de/2008/07/10/nginx-as-a-reverse-proxy-for-apache/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>While Apache is a great server for delivering dynamic content and especially hosting PHP-based websites, it has a high memory footprint and a high overhead when forking new worker processes during high server load. In this article I will describe how you can use the <a href="http://nginx.net">nginx</a> web server as a <a href="http://en.wikipedia.org/wiki/Reverse_proxy">reverse proxy</a> for your Apache to deliver static files instead of Apache. Nginx has a very small memory footprint and can deliver static files lightning fast.</p>
<p>The idea behind this setup is that nginx will listen on port 80 for incoming connections, identify whether the client requests a static file or a dynamic webpage. In case of a static file it will deliver the file itself. In case of a dynamic request it will forward that request to the Apache server. </p>
<p><span id="more-48"></span></p>
<p>So let&#8217;s get started. First we need to download and unzip the lates stabel version of nginx. Currently this is verions 0.6.32. Compilation and installation is a done with the usual steps:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>configure
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>This will install nginx in the directory <code>/usr/local/nginx</code>. I usually like to have all my configuration files under <code>/etc</code>, so let&#8217;s copy the configuration folder over:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-r</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>nginx<span style="color: #000000; font-weight: bold;">/</span>conf <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx</pre></div></div>

<p>The sample configuration file <code>nginx.conf</code> is well suited as a starting point. I would recommend to uncomment / change the following settings in the main section:</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">user</span> www-data www-data;
worker_processes <span style="color: #ff0000;">2</span>;
pid /var/run/nginx.pid;</pre></div></div>

<p>In the http-section you could alter the following settings:</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;">tcp_noauth <span style="color: #0000ff;">on</span>;
gzip <span style="color: #0000ff;">on</span>;</pre></div></div>

<p>The English nginx wiki contains a very good <a href="http://wiki.codemongers.com/NginxModules">documentation</a> on these settings.</p>
<p>Nginx has full support for name based virtual hosts and you need to create a server-section in the config for every virtual host that is configured in Apache. But first create a new configuration file <code>/etc/nginx/proxy.conf</code> which contains the basic proxy settings as found in the nginx wiki:</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;">proxy_redirect          <span style="color: #0000ff;">off</span>;
proxy_set_header        Host            $host;
proxy_set_header        X-Real-IP       $remote_addr;
proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size    10m;
client_body_buffer_size 128k;
proxy_connect_timeout   <span style="color: #ff0000;">90</span>;
proxy_send_timeout      <span style="color: #ff0000;">90</span>;
proxy_read_timeout      <span style="color: #ff0000;">90</span>;
proxy_buffers           <span style="color: #ff0000;">32</span> 4k;</pre></div></div>

<p>These settings will be reused in every virtual host. The default virtual host is used as fallback in case no specific configuration for that virtual host can be found. To configure this default host, replace the server-section in the file <code>/etc/nginx.conf</code> with the following block:</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;">server {
    <span style="color: #00007f;">listen</span>       XXX.XXX.XXX.XXX:<span style="color: #ff0000;">80</span> default;
    server_name  _;
    access_log /var/log/nginx/default.access.log main;
&nbsp;
    <span style="color: #00007f;">location</span> / {
        proxy_pass http://127.0.0.1:<span style="color: #ff0000;">80</span>;
        <span style="color: #00007f;">include</span> /etc/nginx/proxy.conf;
   }
}</pre></div></div>

<p>Replace <code>XXX.XXX.XXX.XXX</code> with the extern IP address of the server. The above configuration is a pure proxy configuration which will pass all the traffic to the Apache server that is listening on <code>127.0.0.1:80</code>.</p>
<p>To be flexible in the virtual host configuration, I like to maintain one configuration file per virtual host in a separate directory. We can include all configuration files from a certain directory into the nginx configuration by adding the following line after the server-section:</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">include</span> /etc/nginx/sites-enabled/*;</pre></div></div>

<p>So every time you want to setup a new virtual host, you just need to add a new configuration file to the directory <code>/etc/nginx/sites-enabled</code>. Here is a template for that file:</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;">server {
    <span style="color: #00007f;">listen</span> XXX.XXX.XXX.XXX:<span style="color: #ff0000;">80</span>;
    server_name foobar.com www.foobar.com;
&nbsp;
    <span style="color: #00007f;">location</span> / {
        proxy_pass http://127.0.0.1:<span style="color: #ff0000;">80</span>;
        <span style="color: #00007f;">include</span> /etc/nginx/proxy.conf;
    }
&nbsp;
    <span style="color: #00007f;">location</span> ~* ^.+.(jpe?g|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|swf|avi|mp3)$ {
        expires 30d;
        root /var/www/foobar.com/htdocs;
    }
}</pre></div></div>

<p>This configuration will setup the virtual host <code>foobar.com</code>. You can define all alias addresses with the configuration directive <code>server_name</code>. All requests that match one of the above file extensions will be delivered directly by nginx from the directory <code>/var/www/foobar.com/htdocs</code>. All other requests are forwarded to the Apache server.</p>
<p>Before nginx can be started we need to make sure that Apache only listens on the address <code>127.0.0.1</code> for requests and not on the external IP address. In Debian this is done in <code>/etc/apache2/ports.conf</code>. Change this file to:</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">Listen</span> 127.0.0.1:<span style="color: #ff0000;">80</span></pre></div></div>

<p>Also make sure, that the VirtualHost directives in the Apache configuration files do not include an IP address. They should look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;">&lt;<span style="color: #000000; font-weight:bold;">VirtualHost</span> *:<span style="color: #ff0000;">80</span>&gt;
    <span style="color: #00007f;">ServerName</span> foobar.com
...
&lt;/<span style="color: #000000; font-weight:bold;">VirtualHost</span>&gt;</pre></div></div>

<p>The directive NameVirtualHost should look like this (also without an IP address):</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">NameVirtualHost</span> *:<span style="color: #ff0000;">80</span></pre></div></div>

<p>Now you can restart Apache:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><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>apache2 restart</pre></div></div>

<p>And start 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<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>nginx <span style="color: #660033;">-c</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</pre></div></div>

<p>You can reload the nginx configuration without stopping nginx:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><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: #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: #000000; font-weight: bold;">`</span></pre></div></div>

<p>On my server some quick benchmarks have shown that nginx can deliver static content up to 10 times faster than Apache. The amazing thing is that not only did it deliver the content faster, there was nearly no impact on CPU or memory. With combining Apache and nginx we can have the best of both worlds, nginx for static files and Apache for dynamic content.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dikant.de/2008/07/10/nginx-as-a-reverse-proxy-for-apache/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Running Django 0.96.2 in Leopard</title>
		<link>http://www.dikant.de/2008/06/29/running-django-0962-in-leopard/</link>
		<comments>http://www.dikant.de/2008/06/29/running-django-0962-in-leopard/#comments</comments>
		<pubDate>Sun, 29 Jun 2008 10:01:06 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.dikant.de/?p=47</guid>
		<description><![CDATA[The installer script for the Python based web development framework Django contains a bug on OSX 10.5 which leads to problems with the default applications &#8220;admin&#8221;, &#8220;comments&#8221; and &#8220;sitemaps&#8221;. The template and media files of these applications are copied to &#8230; <a href="http://www.dikant.de/2008/06/29/running-django-0962-in-leopard/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The installer script for the <a href="http://www.python.org">Python</a> based web development framework <a href="http://www.djangoproject.com">Django</a> contains a bug on OSX 10.5 which leads to problems with the default applications &#8220;admin&#8221;, &#8220;comments&#8221; and &#8220;sitemaps&#8221;. The template and media files of these applications are copied to a wrong directory.</p>
<p>As a workaround for this bug, you can copy the files manually to the correct location:</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;">cp</span> <span style="color: #660033;">-r</span> <span style="color: #000000; font-weight: bold;">/</span>System<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>Frameworks<span style="color: #000000; font-weight: bold;">/</span>Python.framework<span style="color: #000000; font-weight: bold;">/</span>Versions<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2.5</span><span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>python2.5<span style="color: #000000; font-weight: bold;">/</span>site-packages<span style="color: #000000; font-weight: bold;">/</span>django<span style="color: #000000; font-weight: bold;">/</span>contrib<span style="color: #000000; font-weight: bold;">/*</span> <span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>Python<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2.5</span><span style="color: #000000; font-weight: bold;">/</span>site-packages<span style="color: #000000; font-weight: bold;">/</span>django<span style="color: #000000; font-weight: bold;">/</span>contrib<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.dikant.de/2008/06/29/running-django-0962-in-leopard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hosting OpenVZ on Ubuntu 8.04</title>
		<link>http://www.dikant.de/2008/06/15/hosting-openvz-on-ubuntu-804/</link>
		<comments>http://www.dikant.de/2008/06/15/hosting-openvz-on-ubuntu-804/#comments</comments>
		<pubDate>Sun, 15 Jun 2008 18:10:49 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.dikant.de/?p=46</guid>
		<description><![CDATA[The long term support edition 8.04 of Ubuntu Linux will provide security updates until 2013. Therefore it is an ideal distribution for building the base of a secure hosting solution. In this article I will describe how you can setup &#8230; <a href="http://www.dikant.de/2008/06/15/hosting-openvz-on-ubuntu-804/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The long term support edition 8.04 of <a href="http://www.ubuntu.com/">Ubuntu Linux</a> will provide security updates until 2013. Therefore it is an ideal distribution for building the base of a secure hosting solution. In this article I will describe how you can setup the virtualization software <a href="http://wiki.openvz.org/">OpenVZ</a> on Ubuntu 8.04. OpenVZ allows you to run multiple virtual Linux servers on top of your Ubuntu system. It is extremely performant and OpenVZ is also the base of the well known <a href="http://www.parallels.com/en/products/virtuozzo/">Virtuozzo</a> solution which is widely used in the web hosting market. Compared to <a href="http://xen.org/">Xen</a>, OpenVZ is more limited in regards to different operating system you can run, but on the other hand it has a lower overhead and is therefore more performant. It is also possible to run OpenVZ inside of <a href="http://www.virtualbox.org/">VirtualBox</a> which is not possible with Xen.</p>
<p><span id="more-46"></span></p>
<p>The first step in setting up an OpenVZ server is to install a minimal setup of Ubuntu server 8.04. When installing Ubuntu you should select LVM in the partitioning options as this will enable backups of your OpenVZ containers without downtime while they are running. The only service that we will install is OpenSSH to access the installation remotely.</p>
<p>Once the base system is setup and you can login remotely via SSH you could update the whole system to make sure you have the latest versions of all installed applications:</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;">apt-get</span> update
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> dist-upgrade</pre></div></div>

<p>The OpenVZ-Kernel does not work well with the AppArmor package, which is installed by default, so disable it:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> update-rc.d <span style="color: #660033;">-f</span> apparmor remove</pre></div></div>

<p>Now it is time to install the OpenVZ-kernel:</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;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> linux-openvz</pre></div></div>

<p>The above package is a meta package which will install the kernel, the kernel modules and any required header-files and libraries. Now take a look at the file <code>/boot/grub/menu.lst</code> and make sure that the new OpenVZ kernel is the default kernel when booting. Now reboot and check that the correct kernel is loaded:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">uname</span> <span style="color: #660033;">-r</span></pre></div></div>

<p>If you can see something like <code>2.6.24-18-openvz</code> when running the above command, the correct kernel has been booted. If not, check your boot config.</p>
<p>The next step is to install the OpenVZ tools:</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;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> vzctl vzquota</pre></div></div>

<p>Now you can run the OpenVZ daemon:</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: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>vz start</pre></div></div>

<p>Basically that&#8217;s it. OpenVZ is now running and you can setup your VZ containers. The OpenVZ project page has a lot of different container templates you can use as a starting point. Take a look at the list on <a href="http://wiki.openvz.org/Download/template/precreated">http://wiki.openvz.org/Download/template/precreated</a> and download all templates you want to use to <code>/var/lib/vz/template/cache</code>. You can choose from a wide selection of Linux distributions.</p>
<p>You can now start creating your virtual machine containers and run them:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> vzctl create <span style="color: #000000;">101</span> <span style="color: #660033;">--ostemplate</span> ubuntu-<span style="color: #000000;">8.04</span>-i386-minimal
<span style="color: #c20cb9; font-weight: bold;">sudo</span> vzctl start <span style="color: #000000;">101</span></pre></div></div>

<p>Of course you need to configure your containers, but this is a different topic which I will describe in a followup to this article.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dikant.de/2008/06/15/hosting-openvz-on-ubuntu-804/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
