<?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>johker's blog &#187; Howto</title>
	<atom:link href="http://johker.ibutho.de/category/howto/feed/" rel="self" type="application/rss+xml" />
	<link>http://johker.ibutho.de</link>
	<description>stories about me, my life, science and my trips</description>
	<lastBuildDate>Sat, 29 May 2010 10:00:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Der neue Server: Teil X Sonstiges</title>
		<link>http://johker.ibutho.de/2010/01/13/der-neue-server-teil-x-sonstiges/</link>
		<comments>http://johker.ibutho.de/2010/01/13/der-neue-server-teil-x-sonstiges/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 18:33:15 +0000</pubDate>
		<dc:creator>johker</dc:creator>
				<category><![CDATA[Howto]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[a2ensite]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[chroot]]></category>
		<category><![CDATA[chrooted]]></category>
		<category><![CDATA[csr]]></category>
		<category><![CDATA[diffie-hellman]]></category>
		<category><![CDATA[guest]]></category>
		<category><![CDATA[root]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[sed]]></category>
		<category><![CDATA[sftp]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[tausch]]></category>
		<category><![CDATA[vHost]]></category>
		<category><![CDATA[vhost automation]]></category>

		<guid isPermaLink="false">http://johker.ibutho.de/?p=159</guid>
		<description><![CDATA[Der Entwurf zu diesem Beitrag ist schon fast ein Jahr alt. Ich will ihn nun endlich mal veröffentlichen in der Hoffnung, dass er einigen Leuten hilft und ihnen Arbeit abnimmt.
------------------
In diesem Beitrag sind alle Dinge zusammengefasst, die thematisch nicht direkt zusammenpassen oder nicht direkt in einen einzigen Beitrag passen, da sie mehrere Themen streifen.
ssl-Zertifikat erstellen
Jetzt [...]]]></description>
			<content:encoded><![CDATA[<p>Der Entwurf zu diesem Beitrag ist schon fast ein Jahr alt. Ich will ihn nun endlich mal veröffentlichen in der Hoffnung, dass er einigen Leuten hilft und ihnen Arbeit abnimmt.</p>
<p>------------------</p>
<p>In diesem Beitrag sind alle Dinge zusammengefasst, die thematisch nicht direkt zusammenpassen oder nicht direkt in einen einzigen Beitrag passen, da sie mehrere Themen streifen.</p>
<h1>ssl-Zertifikat erstellen</h1>
<p>Jetzt erstellen wir ein <em>ssl</em>-Zertifikat, welches wir bei <a href="http://cacert.org/" target="_blank">cacert.org</a> signieren lassen. Dies bietet einige Vorteile gegenüber dem Selbst-Signieren (self-signing). Leider ist das <em>cacert.org</em> Root-Zertifikat noch nicht in Firefox aufgenommen und somit erhält man immer diese lästige Warnung, wenn man eine cacert-zertifizierte Webseite aufruft, bis man deren Root-Zertifikat in Firefox importiert.<br />
Am Besten geht man nach dieser Anleitung vor zum Erstellen eines Zertifikats: <a href="http://wiki.cacert.org/wiki/CSRGenerator" target="_blank">http://wiki.cacert.org/wiki/CSRGenerator</a>. Danach verschiebt man den Private-Key nach "<em>/etc/ssl/private</em>" und den Public-Key nach "<em>/etc/ssl/certs</em>". Nun kann man das Zertifikat z.B. in Apache verwenden, aber auch für den Mailserver, IMAP-/POP-Server, svn, ... Sollte eine Applikation nicht auf den Private-Key zugreifen können, benötigt aber Zugriff darauf, so muss man den Benutzer unter der die Applikation läuft in die Gruppe "<em>ssl-cert</em>" aufnehmen (<strong>ACHTUNG:</strong> Dies könnte ein Sicherheitsrisiko darstellen!).</p>
<h2>Diffie-Hellman-Code erzeugen</h2>
<p>Dies wird z.B. für postfix gebraucht, aber auch für einige IMAP-Server, deshalb erzeugen wir hier diesen Code und speichern ihn unter "/etc/ssl/private/":</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">openssl gendh <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>dh_1024.pem <span style="color: #660033;">-2</span> <span style="color: #660033;">-rand</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>urandom <span style="color: #000000;">1024</span>
openssl gendh <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>dh_512.pem <span style="color: #660033;">-2</span> <span style="color: #660033;">-rand</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>urandom <span style="color: #000000;">512</span></pre></div></div>

<h2>SSL-vHost in apache erstellen</h2>
<p>Um in <em>apache</em> einen SSL-vHost erstellen kann, muss man die Datei <em>ports.conf</em> unter "<em>/etc/apache2</em>" ändern und die folgende Zeilen hinzufügen/ergänzen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;</span>IfModule mod_ssl.c<span style="color: #000000; font-weight: bold;">&gt;</span>
    <span style="color: #666666; font-style: italic;"># SSL name based virtual hosts are not yet supported, therefore no</span>
    <span style="color: #666666; font-style: italic;"># NameVirtualHost statement here</span>
    NameVirtualHost <span style="color: #000000; font-weight: bold;">*</span>:<span style="color: #000000;">443</span>
    Listen <span style="color: #000000;">443</span>
<span style="color: #000000; font-weight: bold;">&lt;/</span>IfModule<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>Danach können wie gehabt vHosts erstellt werden, mit dem Unterschied, dass die Zeile "<VirtualHost *:80>" in "<VirtualHost *:443>" geändert werden und folgende Zeilen hinzugefügt werden:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">        SSLEngine on
        SSLCertificateFile <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>certs<span style="color: #000000; font-weight: bold;">/</span>server.pem
        SSLCertificateKeyFile <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>privatekey.pem
        SSLCipherSuite HIGH
        SSLProtocol all <span style="color: #660033;">-SSLv2</span></pre></div></div>

<p>Weiter unten stelle ich ein Skript vor, mit welchem man bequem vHosts (sowohl mit und ohne SSL) erstellen kann und automatisch von Port 80 auf Port 443 weiterleiten, wenn der vHost SSL unterstützt.</p>
<p>Quellen:<br />
<a href="http://wiki.cacert.org/wiki/CSRGenerator" target="_blank">http://wiki.cacert.org/wiki/CSRGenerator</a><br />
<a href="http://cacert.org/" target="_blank">http://cacert.org/</a></p>
<h1>sftp-Gastzugang</h1>
<p>Oft möchte man Leuten einen Zuganz zu seinem Server verschaffen, damit man etwas in ein bestimmtes Verzeichnis hochladen, bzw. daraus herunterladen darf, aber nicht aus diesem Verzeichnis herausnavigieren darf und evtl. Schaden anrichten kann. Dies kann man mit openSSH 5.0 sehr einfach lösen, da es eingebaute chroot-Mechanismen hat. So kann man z.B. eine ganze Gruppe auf ihr Home-Laufwerk oder einen anderen Ordner beschränken oder aber auch nur einen einzigen Benutzer. Im Folgenden legen wir eine Gruppe "<em>chrooted</em>" an, welche auf ihr Home-Laufwerk beschränkt sein wird. Alle Home-Laufwerke dieser Gruppe werden standardmäßig unter "<em>/home/chrooted</em>" liegen. Für unseren Gastbenutzer legen wir darunter ein Verzeichnis "<em>upload</em>" an und ändern die Rechte entsprechend:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> upload
<span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #000000; font-weight: bold;">&lt;</span>uploaduser<span style="color: #000000; font-weight: bold;">&gt;</span>:<span style="color: #c20cb9; font-weight: bold;">users</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>chrooted<span style="color: #000000; font-weight: bold;">/</span>upload
<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">775</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>chrooted<span style="color: #000000; font-weight: bold;">/</span>upload</pre></div></div>

<p>Will man Ordner außerhalb des Home-Laufwerks zugänglich machen, kann man diese mit "<em>mount -o bind</em>" temporär einbinden, bzw. über die "<em>/etc/fstab</em>" dauerhaft:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>pfad<span style="color: #000000; font-weight: bold;">/</span>zum<span style="color: #000000; font-weight: bold;">/</span>quellverzeichnis <span style="color: #000000; font-weight: bold;">/</span>pfad<span style="color: #000000; font-weight: bold;">/</span>zum<span style="color: #000000; font-weight: bold;">/</span>zielverzeichnis none rw,<span style="color: #7a0874; font-weight: bold;">bind</span> <span style="color: #000000;">0</span> <span style="color: #000000;">0</span></pre></div></div>

<p>Gruppe "<em>chrooted</em>" anlegen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">addgroup <span style="color: #660033;">--system</span> chrooted</pre></div></div>

<p>Um einen Benutzer in die Gruppe "<em>chrooted</em>" aufzunehmen, führt man folgenden Befehl aus:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">adduser <span style="color: #000000; font-weight: bold;">&lt;</span>uploaduser<span style="color: #000000; font-weight: bold;">&gt;</span> chrooted</pre></div></div>

<p>Danach muss man die <em>sshd_config</em> anpassen, bzw. erweitern:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#Subsystem sftp /usr/lib/openssh/sftp-server</span>
Subsystem sftp internal-sftp
&nbsp;
Match group chrooted
        <span style="color: #666666; font-style: italic;"># chroot all users of these group to their homes</span>
        <span style="color: #666666; font-style: italic;"># %h will be substituted by the user's home</span>
        <span style="color: #666666; font-style: italic;"># %u will be substituted with the user's user name</span>
        ChrootDirectory <span style="color: #000000; font-weight: bold;">%</span>h
        AllowTcpForwarding no
        ForceCommand internal-sftp</pre></div></div>

<p>Wichtig ist, dass das Home-Verzeichnis des Benutzers <strong>root</strong> gehören muss ("chown root: /pfad/zu/home"). Die Unterordner sollten dann wieder dem Benutzer gehören, damit das ganze auch Sinn macht und er Dateien hoch-/runterladen kann. In unserem Beispiel bedeutet das, dass "<em>/home/chrooted</em>" root gehören muss und "<em>/home/chrooted/upload</em>" dem <uploaduser>.<br />
Zusätzlich kann man nun noch unter "/etc/passwd" die Standardkonsole des <uploadusers> auf "<em>/bin/false</em>" setzen, denn der Benutzer darf sich nur via <em>sftp</em> anmelden und nicht über die Konsole:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;</span>uploaduser<span style="color: #000000; font-weight: bold;">&gt;</span>:x:<span style="color: #000000;">1666</span>:<span style="color: #000000;">1666</span>:Guest upload-account,,,:<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>chrooted:<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></pre></div></div>

<p>Quellen:<br />
<a href="http://binblog.wordpress.com/2008/04/06/openssh-chrooted-sftp-eg-for-webhosting/" target="_blank">http://binblog.wordpress.com/2008/04/06/openssh-chrooted-sftp-eg-for-webhosting/</a><br />
<a href="http://www.debian-administration.org/articles/590" target="_blank">http://www.debian-administration.org/articles/590</a></p>
<h1>Tauschverzeichnis anlegen</h1>
<p>Da alle Konsolenbenutzer auch Mitglied in der Gruppe "<em>users</em>" sind, ist es ein leichtes ein Tausch-Verzeichnis unter "<em>/home/shared</em>" anzulegen. Darunter legen wir - der Benutzerfreundlichkeit zuliebe - einen Symlink nach "/home/chrooted/upload" an (siehe vorheriges Kapitel):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>shared
<span style="color: #c20cb9; font-weight: bold;">chown</span> root:<span style="color: #c20cb9; font-weight: bold;">users</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>shared
<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">775</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>shared
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>chrooted<span style="color: #000000; font-weight: bold;">/</span>upload upload</pre></div></div>

<p>Nun können sich alle Konsolenbenutzer über dieses Verzeichnis austauschen und auf die Dateien des Gast-Accounts zugreifen, welche für ihn bereitstellen bzw. je nach Rechten auch welche löschen.</p>
<h1>vHosts-Skript</h1>
<p>Um einem die Arbeit etwas zu erleichtern habe ich schnell ein kleines <em>bash</em>-Skript runtergehackt, mit welchem man bequem vHosts unter <em>apache2</em> anlegen kann. Ist man nach <a href="http://johker.ibutho.de/2009/03/22/der-neue-server-teil-4-apache/">Der neue Server: Teil 4 apache</a> vorgegangen, so müssen im Skript normalerweise keine Änderungen vorgenommen werden, anderfalls braucht das Skript evtl. ein paar Anpassungen.</p>
<p>Hier das Skript:</p>
<p><i>createVhost.sh:</i></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># createVhost.sh - Creates an Apache2 vHost configuration</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Copyright (C) 2009 johker</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License v2 as published by the Free Software Foundation</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License v2 for more details.</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">### CHANGE ME! ###</span>
&nbsp;
<span style="color: #007800;">WWW_ROOT</span>=<span style="color: #ff0000;">&quot;/var/www&quot;</span>
<span style="color: #007800;">SITES_ROOT</span>=<span style="color: #ff0000;">&quot;/etc/apache2/sites-available&quot;</span>
&nbsp;
<span style="color: #007800;">CHANGE_PHP_INI</span>=<span style="color: #ff0000;">&quot;no&quot;</span>
&nbsp;
<span style="color: #007800;">EXAMPLE_ROOT</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$WWW_ROOT</span>/example&quot;</span>
<span style="color: #007800;">SITES_EXAMPLE</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$SITES_ROOT</span>/example&quot;</span>
<span style="color: #007800;">SITES_EXAMPLE_SSL</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$SITES_EXAMPLE</span>-ssl&quot;</span>
&nbsp;
<span style="color: #007800;">SSL_PRIV_DEFAULT</span>=<span style="color: #ff0000;">&quot;/etc/ssl/private/privatekey.pem&quot;</span>
<span style="color: #007800;">SSL_PUB_DEFAULT</span>=<span style="color: #ff0000;">&quot;/etc/ssl/certs/publickey.pem&quot;</span>
&nbsp;
<span style="color: #007800;">PHP_INI_TEMPLATE</span>=<span style="color: #ff0000;">&quot;/etc/php5/cgi/php.ini&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">### END CHANGE ME! ###</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#############################################################</span>
<span style="color: #666666; font-style: italic;">########## DO NOT CHANGE ANYTHING BELOW THIS LINE! ##########</span>
<span style="color: #666666; font-style: italic;">#############################################################</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Make sure only root can run our script</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$(id -u)</span>&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;ERROR: This script must be run as root!&quot;</span> <span style="color: #000000;">1</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;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Query the user for some details</span>
<span style="color: #c20cb9; font-weight: bold;">read</span> <span style="color: #660033;">-p</span> <span style="color: #ff0000;">&quot;Domain name: &quot;</span> SRV_NAME
<span style="color: #c20cb9; font-weight: bold;">read</span> <span style="color: #660033;">-p</span> <span style="color: #ff0000;">&quot;Domain aliases (leave blank if no aliases available, separated by blank): &quot;</span> SRV_ALIAS
<span style="color: #c20cb9; font-weight: bold;">read</span> <span style="color: #660033;">-p</span> <span style="color: #ff0000;">&quot;Admin e-mail address: &quot;</span> SRV_ADMIN
<span style="color: #c20cb9; font-weight: bold;">read</span> <span style="color: #660033;">-p</span> <span style="color: #ff0000;">&quot;vHost owner (system user): &quot;</span> USER
<span style="color: #c20cb9; font-weight: bold;">read</span> <span style="color: #660033;">-p</span>  <span style="color: #ff0000;">&quot;Use SSL (yes/no)[no]: &quot;</span> SSL
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #007800;">$SSL</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #666666; font-style: italic;"># set default value</span>
	<span style="color: #007800;">SSL</span>=<span style="color: #ff0000;">&quot;no&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$SSL</span> == <span style="color: #ff0000;">&quot;yes&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #c20cb9; font-weight: bold;">read</span> <span style="color: #660033;">-p</span> <span style="color: #ff0000;">&quot;SSL private key[<span style="color: #007800;">$SSL_PRIV_DEFAULT</span>]: &quot;</span> CERT_PRIV
	<span style="color: #c20cb9; font-weight: bold;">read</span> <span style="color: #660033;">-p</span> <span style="color: #ff0000;">&quot;SSL public key[<span style="color: #007800;">$SSL_PUB_DEFAULT</span>]: &quot;</span> CERT_PUB
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #007800;">$CERT_PRIV</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #666666; font-style: italic;"># set default value</span>
		<span style="color: #007800;">CERT_PRIV</span>=<span style="color: #007800;">$SSL_PRIV_DEFAULT</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #007800;">$CERT_PUB</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #666666; font-style: italic;"># set default value</span>
		<span style="color: #007800;">CERT_PUB</span>=<span style="color: #007800;">$SSL_PUB_DEFAULT</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #007800;">VHOST_ROOT</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$WWW_ROOT</span>/<span style="color: #007800;">$SRV_NAME</span>&quot;</span>
<span style="color: #007800;">DOC_ROOT</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$VHOST_ROOT</span>/docs&quot;</span>
<span style="color: #007800;">CONF_ROOT</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$VHOST_ROOT</span>/conf&quot;</span>
<span style="color: #007800;">LOG_ROOT</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$VHOST_ROOT</span>/logs&quot;</span>
<span style="color: #007800;">TMP_ROOT</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$VHOST_ROOT</span>/tmp&quot;</span>
&nbsp;
<span style="color: #007800;">PHP_FCGI</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$CONF_ROOT</span>/php-fcgi.conf&quot;</span>
<span style="color: #007800;">PHP_INI</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$CONF_ROOT</span>/php.ini&quot;</span>
&nbsp;
<span style="color: #007800;">VHOST_CONF</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$SITES_ROOT</span>/<span style="color: #007800;">$SRV_NAME</span>&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># GROUP equals USER</span>
<span style="color: #007800;">GROUP</span>=<span style="color: #007800;">$USER</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> changeFcgiConfig <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #666666; font-style: italic;"># adjust fcgi config</span>
	<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">&quot;s!{SRV_NAME}!<span style="color: #007800;">$SRV_NAME</span>!g&quot;</span> <span style="color: #660033;">-i</span> <span style="color: #007800;">$PHP_FCGI</span>
	<span style="color: #666666; font-style: italic;"># ... php.ini</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$CHANGE_PHP_INI</span> == <span style="color: #ff0000;">&quot;yes&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">&quot;s!;upload_tmp_dir =!upload_tmp_dir = <span style="color: #007800;">$TMP_ROOT</span>!g&quot;</span> <span style="color: #660033;">-i</span> <span style="color: #007800;">$PHP_INI</span>
		<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">&quot;s!;open_basedir =!open_basedir = <span style="color: #007800;">$DOC_ROOT</span>:<span style="color: #007800;">$TMP_ROOT</span>!g&quot;</span> <span style="color: #660033;">-i</span> <span style="color: #007800;">$PHP_INI</span>
		<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">&quot;s!;session.save_path = /var/lib/php5!session.save_path = <span style="color: #007800;">$TMP_ROOT</span>!g&quot;</span> <span style="color: #660033;">-i</span> <span style="color: #007800;">$PHP_INI</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> createDirs <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #666666; font-style: italic;"># create the directory structure</span>
&nbsp;
	<span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-R</span> <span style="color: #007800;">$EXAMPLE_ROOT</span> <span style="color: #007800;">$VHOST_ROOT</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$CHANGE_PHP_INI</span> == <span style="color: #ff0000;">&quot;yes&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #666666; font-style: italic;"># don't put a symlink to php.ini in $CONF_ROOT, but copy it there</span>
		<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #007800;">$CONF_ROOT</span><span style="color: #000000; font-weight: bold;">/</span>php.ini
		<span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #007800;">$PHP_INI_TEMPLATE</span> <span style="color: #007800;">$CONF_ROOT</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
	changeFcgiConfig
&nbsp;
	<span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #007800;">$USER</span>:<span style="color: #007800;">$GROUP</span> <span style="color: #660033;">-R</span> <span style="color: #007800;">$VHOST_ROOT</span>
&nbsp;
	<span style="color: #c20cb9; font-weight: bold;">chattr</span> +i <span style="color: #007800;">$CONF_ROOT</span><span style="color: #000000; font-weight: bold;">/</span>php-fcgi.conf
	<span style="color: #666666; font-style: italic;"># as $CONF_ROOT/php.ini is just a symlink most of the time, chattr will usually fail</span>
	<span style="color: #c20cb9; font-weight: bold;">chattr</span> +i <span style="color: #007800;">$CONF_ROOT</span><span style="color: #000000; font-weight: bold;">/</span>php.ini <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> createApacheConfig <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #666666; font-style: italic;"># now let's adjust the apache vHost-configuration</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$SSL</span> == <span style="color: #ff0000;">&quot;yes&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #007800;">$SITES_EXAMPLE_SSL</span> <span style="color: #007800;">$VHOST_CONF</span>
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #007800;">$SITES_EXAMPLE</span> <span style="color: #007800;">$VHOST_CONF</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
	<span style="color: #666666; font-style: italic;"># now do sed operations on $VHOST_CONF</span>
	<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">&quot;s!{SRV_NAME}!<span style="color: #007800;">$SRV_NAME</span>!g&quot;</span> <span style="color: #660033;">-i</span> <span style="color: #007800;">$VHOST_CONF</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$SRV_ALIAS</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">&quot;s!{SRV_ALIAS}!!g&quot;</span> <span style="color: #660033;">-i</span> <span style="color: #007800;">$VHOST_CONF</span>
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">&quot;s!{SRV_ALIAS}!<span style="color: #007800;">$SRV_ALIAS</span>!g&quot;</span> <span style="color: #660033;">-i</span> <span style="color: #007800;">$VHOST_CONF</span>
		<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">&quot;s!#	ServerAlias!	ServerAlias!g&quot;</span> <span style="color: #660033;">-i</span> <span style="color: #007800;">$VHOST_CONF</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">&quot;s!{SRV_ADMIN}!<span style="color: #007800;">$SRV_ADMIN</span>!g&quot;</span> <span style="color: #660033;">-i</span> <span style="color: #007800;">$VHOST_CONF</span>
	<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">&quot;s!{USER}!<span style="color: #007800;">$USER</span>!g&quot;</span> <span style="color: #660033;">-i</span> <span style="color: #007800;">$VHOST_CONF</span>
	<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">&quot;s!{GROUP}!<span style="color: #007800;">$GROUP</span>!g&quot;</span> <span style="color: #660033;">-i</span> <span style="color: #007800;">$VHOST_CONF</span>
&nbsp;
	<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">&quot;s!{DOC_ROOT}!<span style="color: #007800;">$DOC_ROOT</span>!g&quot;</span> <span style="color: #660033;">-i</span> <span style="color: #007800;">$VHOST_CONF</span>
	<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">&quot;s!{CONF_ROOT}!<span style="color: #007800;">$CONF_ROOT</span>!g&quot;</span> <span style="color: #660033;">-i</span> <span style="color: #007800;">$VHOST_CONF</span>
	<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">&quot;s!{LOG_ROOT}!<span style="color: #007800;">$LOG_ROOT</span>!g&quot;</span> <span style="color: #660033;">-i</span> <span style="color: #007800;">$VHOST_CONF</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$SSL</span> == <span style="color: #ff0000;">&quot;yes&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">&quot;s!{CERT_PUB}!<span style="color: #007800;">$CERT_PUB</span>!g&quot;</span> <span style="color: #660033;">-i</span> <span style="color: #007800;">$VHOST_CONF</span>
		<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">&quot;s!{CERT_PRIV}!<span style="color: #007800;">$CERT_PRIV</span>!g&quot;</span> <span style="color: #660033;">-i</span> <span style="color: #007800;">$VHOST_CONF</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
createDirs
createApacheConfig
&nbsp;
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></pre></td></tr></table></div>

<p>Die dazugehörenden Ordnerstruktur unter "<em>/var/www/example</em>":</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><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>www<span style="color: #000000; font-weight: bold;">/</span>example
<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>www<span style="color: #000000; font-weight: bold;">/</span>example<span style="color: #000000; font-weight: bold;">/</span>conf
<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>www<span style="color: #000000; font-weight: bold;">/</span>example<span style="color: #000000; font-weight: bold;">/</span>docs
<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>www<span style="color: #000000; font-weight: bold;">/</span>example<span style="color: #000000; font-weight: bold;">/</span>tmp
<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>www<span style="color: #000000; font-weight: bold;">/</span>example<span style="color: #000000; font-weight: bold;">/</span>logs
<span style="color: #c20cb9; font-weight: bold;">touch</span> <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<span style="color: #000000; font-weight: bold;">/</span>logs<span style="color: #000000; font-weight: bold;">/</span>access.log
<span style="color: #c20cb9; font-weight: bold;">touch</span> <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<span style="color: #000000; font-weight: bold;">/</span>logs<span style="color: #000000; font-weight: bold;">/</span>error.log
<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>php5<span style="color: #000000; font-weight: bold;">/</span>cgi<span style="color: #000000; font-weight: bold;">/</span>php.ini <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<span style="color: #000000; font-weight: bold;">/</span>conf<span style="color: #000000; font-weight: bold;">/</span>php.ini</pre></div></div>

<p>Hier noch die Datei "<em>php-fcgi.conf</em>", welche nach "<em>/var/www/example/conf/</em>" gehört: </p>
<p><i>php-fcgi.conf:</i></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>
<span style="color: #007800;">PHPRC</span>=<span style="color: #ff0000;">&quot;/var/www/{SRV_NAME}/conf&quot;</span>
<span style="color: #7a0874; font-weight: bold;">export</span> PHPRC
<span style="color: #007800;">PHP_FCGI_CHILDREN</span>=<span style="color: #000000;">3</span>
<span style="color: #7a0874; font-weight: bold;">export</span> PHP_FCGI_CHILDREN
<span style="color: #7a0874; font-weight: bold;">exec</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-cgi</pre></div></div>

<p>Dazu noch die vHost-configs "example", sowie "example-ssl" unter /etc/apache2/sites-available":</p>
<ul>
<li><i>example</i>:

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;</span>VirtualHost <span style="color: #000000; font-weight: bold;">*</span>:<span style="color: #000000;">80</span><span style="color: #000000; font-weight: bold;">&gt;</span>
        SuExecUserGroup <span style="color: #7a0874; font-weight: bold;">&#123;</span>USER<span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>GROUP<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
        ServerName <span style="color: #7a0874; font-weight: bold;">&#123;</span>SRV_NAME<span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #666666; font-style: italic;">#	ServerAlias {SRV_ALIAS}</span>
        ServerAdmin <span style="color: #7a0874; font-weight: bold;">&#123;</span>SRV_ADMIN<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
        DocumentRoot <span style="color: #7a0874; font-weight: bold;">&#123;</span>DOC_ROOT<span style="color: #7a0874; font-weight: bold;">&#125;</span>
        AddHandler fcgid-script .php
        <span style="color: #000000; font-weight: bold;">&lt;</span>Directory <span style="color: #7a0874; font-weight: bold;">&#123;</span>DOC_ROOT<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
                FCGIWrapper <span style="color: #7a0874; font-weight: bold;">&#123;</span>CONF_ROOT<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">/</span>php-fcgi.conf .php
                Options +SymLinksIfOwnerMatch +MultiViews +ExecCGI <span style="color: #660033;">-Indexes</span>
                AllowOverride FileInfo AuthConfig
                Order allow,deny
                allow from all
        <span style="color: #000000; font-weight: bold;">&lt;/</span>Directory<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
        ErrorLog <span style="color: #7a0874; font-weight: bold;">&#123;</span>LOG_ROOT<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">/</span>error.log
        CustomLog <span style="color: #7a0874; font-weight: bold;">&#123;</span>LOG_ROOT<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">/</span>access.log combined
        LogLevel warn
        ServerSignature Off
<span style="color: #000000; font-weight: bold;">&lt;/</span>VirtualHost<span style="color: #000000; font-weight: bold;">&gt;</span></pre></td></tr></table></div>

</li>
<li><i>example-ssl</i>:

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;</span>VirtualHost <span style="color: #000000; font-weight: bold;">*</span>:<span style="color: #000000;">80</span><span style="color: #000000; font-weight: bold;">&gt;</span>
        ServerName <span style="color: #7a0874; font-weight: bold;">&#123;</span>SRV_NAME<span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #666666; font-style: italic;">#	ServerAlias {SRV_ALIAS}</span>
        ServerAdmin <span style="color: #7a0874; font-weight: bold;">&#123;</span>SRV_ADMIN<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">&lt;</span>IfModule mod_ssl.c<span style="color: #000000; font-weight: bold;">&gt;</span>
          RewriteEngine   on
	  RewriteCond     <span style="color: #000000; font-weight: bold;">%</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>SERVER_PORT<span style="color: #7a0874; font-weight: bold;">&#125;</span> ^<span style="color: #000000;">80</span>$
          RewriteRule     ^<span style="color: #7a0874; font-weight: bold;">&#40;</span>.<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>$ https:<span style="color: #000000; font-weight: bold;">//%</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>SERVER_NAME<span style="color: #7a0874; font-weight: bold;">&#125;</span>$<span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>L,R<span style="color: #7a0874; font-weight: bold;">&#93;</span>
&nbsp;
	  RewriteLog      <span style="color: #7a0874; font-weight: bold;">&#123;</span>LOG_ROOT<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">/</span>rewrite.log
          RewriteLogLevel <span style="color: #000000;">2</span>
	<span style="color: #000000; font-weight: bold;">&lt;/</span>IfModule<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
        ErrorLog <span style="color: #7a0874; font-weight: bold;">&#123;</span>LOG_ROOT<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">/</span>error.log
        CustomLog <span style="color: #7a0874; font-weight: bold;">&#123;</span>LOG_ROOT<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">/</span>access.log combined
        LogLevel warn
&nbsp;
        ServerSignature Off
<span style="color: #000000; font-weight: bold;">&lt;/</span>VirtualHost<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;</span>VirtualHost <span style="color: #000000; font-weight: bold;">*</span>:<span style="color: #000000;">443</span><span style="color: #000000; font-weight: bold;">&gt;</span>
        SuExecUserGroup <span style="color: #7a0874; font-weight: bold;">&#123;</span>USER<span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>GROUP<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
        ServerName <span style="color: #7a0874; font-weight: bold;">&#123;</span>SRV_NAME<span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #666666; font-style: italic;">#	ServerAlias {SRV_ALIAS}</span>
        ServerAdmin <span style="color: #7a0874; font-weight: bold;">&#123;</span>SRV_ADMIN<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
        SSLEngine on
        SSLCertificateFile <span style="color: #7a0874; font-weight: bold;">&#123;</span>CERT_PUB<span style="color: #7a0874; font-weight: bold;">&#125;</span>
        SSLCertificateKeyFile <span style="color: #7a0874; font-weight: bold;">&#123;</span>CERT_PRIV<span style="color: #7a0874; font-weight: bold;">&#125;</span>
        SSLCipherSuite HIGH
        SSLProtocol all <span style="color: #660033;">-SSLv2</span>
&nbsp;
        DocumentRoot <span style="color: #7a0874; font-weight: bold;">&#123;</span>DOC_ROOT<span style="color: #7a0874; font-weight: bold;">&#125;</span>
        AddHandler fcgid-script .php
        <span style="color: #000000; font-weight: bold;">&lt;</span>Directory <span style="color: #7a0874; font-weight: bold;">&#123;</span>DOC_ROOT<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
                FCGIWrapper <span style="color: #7a0874; font-weight: bold;">&#123;</span>CONF_ROOT<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">/</span>php-fcgi.conf .php
                Options +SymLinksIfOwnerMatch +MultiViews +ExecCGI <span style="color: #660033;">-Indexes</span>
                AllowOverride FileInfo
                Order allow,deny
                allow from all
        <span style="color: #000000; font-weight: bold;">&lt;/</span>Directory<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
        ErrorLog <span style="color: #7a0874; font-weight: bold;">&#123;</span>LOG_ROOT<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">/</span>error.log
        CustomLog <span style="color: #7a0874; font-weight: bold;">&#123;</span>LOG_ROOT<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">/</span>access.log combined
        LogLevel warn
&nbsp;
        ServerSignature Off
<span style="color: #000000; font-weight: bold;">&lt;/</span>VirtualHost<span style="color: #000000; font-weight: bold;">&gt;</span></pre></td></tr></table></div>

</li>
</ul>
<p>Das Skript kann als Benutzer <strong>root</strong> ausgeführt werden. Es fragt nach ein paar Parametern (default-Werte stehen in eckigen Klammern und können durch Drücken der Eingabetaste übernommen werden) und erstellt dann den vHost und die dazugehörige Konfiguration. Nach Ausführen des Skripts muss der vHost noch mittels des "<em>a2ensite</em>"-Befehls aktiviert werden und die <em>apache</em>-Konfiguration muss neu eingelesen werden.</p>
]]></content:encoded>
			<wfw:commentRss>http://johker.ibutho.de/2010/01/13/der-neue-server-teil-x-sonstiges/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Funambol Installation</title>
		<link>http://johker.ibutho.de/2009/08/09/funambol-installation/</link>
		<comments>http://johker.ibutho.de/2009/08/09/funambol-installation/#comments</comments>
		<pubDate>Sun, 09 Aug 2009 15:18:46 +0000</pubDate>
		<dc:creator>johker</dc:creator>
				<category><![CDATA[Howto]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[funambol]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[synchronisierung]]></category>
		<category><![CDATA[synchronization]]></category>
		<category><![CDATA[syncml]]></category>

		<guid isPermaLink="false">http://johker.ibutho.de/?p=269</guid>
		<description><![CDATA[Heute geht's um Funambol - einen Synchronisationsserver für Mobiltelefone, PIM Programme, ... Funambol bietet unter anderem auch Unterstützung für Push-Mail, Kalender-, Aufgaben- und Kontaktsynchronisation für viel Plattformen. Mehr Informationen gibts unter http://www.funambol.com/opensource.
Dieses Howto beschreibt die Installation von Funambol mit postgres als Datenbank-Backend.
Installation
Als Erstes laden wir den JDBC Treiber für postgres herunter: http://jdbc.postgresql.org/download/postgresql-8.3-605.jdbc3.jar
Danach das Funambol Installationspackage: [...]]]></description>
			<content:encoded><![CDATA[<p>Heute geht's um Funambol - einen Synchronisationsserver für Mobiltelefone, PIM Programme, ... Funambol bietet unter anderem auch Unterstützung für Push-Mail, Kalender-, Aufgaben- und Kontaktsynchronisation für viel Plattformen. Mehr Informationen gibts unter <a href="http://www.funambol.com/opensource" target="_blank">http://www.funambol.com/opensource</a>.<br />
Dieses Howto beschreibt die Installation von Funambol mit postgres als Datenbank-Backend.</p>
<h1>Installation</h1>
<p>Als Erstes laden wir den JDBC Treiber für postgres herunter: <a href="http://jdbc.postgresql.org/download/postgresql-8.3-605.jdbc3.jar">http://jdbc.postgresql.org/download/postgresql-8.3-605.jdbc3.jar</a><br />
Danach das Funambol Installationspackage: <a href="http://funambol.com/opensource/download.php?file_id=funambol-7.1.1.bin&#038;_=d">http://funambol.com/opensource/download.php?file_id=funambol-7.1.1.bin&#038;_=d</a><br />
Danach führen wir das Funambol Paket mit folgendem Befehl aus:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sh</span> funambol-7.1.1.bin</pre></td></tr></table></div>

<p>Wir wählen den Standard-Installationspfad, verneinen aber die Frage, ob wir den Server starten wollen.</p>
<h1>Konfiguration</h1>
<p>Danach kopieren wir den postgres JDBC-Treiber nach "<em>/opt/Funambol/tools/jre-1.5.0/jre/lib/ext/</em>" und legen einen postgres-Benutzer für Funambol an:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">su</span> - postgres
createuser <span style="color: #660033;">-P</span>
createdb funambol</pre></td></tr></table></div>

<p>Bei "<em>createuser</em>" geben wir als Namen "funambol" an und verneinen alle drei Fragen.<br />
Nun müssen die Datenbank-Einstellungen von Funambol geändert werden. Dazu editieren wir "<em>/opt/Funambol/ds-server/install.properties</em>":</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">jdbc.classpath=..<span style="color: #000000; font-weight: bold;">/</span>tools<span style="color: #000000; font-weight: bold;">/</span>jre-1.5.0<span style="color: #000000; font-weight: bold;">/</span>jre<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ext<span style="color: #000000; font-weight: bold;">/</span>postgresql-<span style="color: #000000;">8.3</span>-605.jdbc3.jar
jdbc.driver=org.postgresql.Driver
jdbc.url=jdbc:postgresql:funambol
jdbc.user=funambol
jdbc.password=<span style="color: #000000; font-weight: bold;">&lt;</span>PASSWORD<span style="color: #000000; font-weight: bold;">&gt;</span></pre></td></tr></table></div>

<p>Die Datei "<em>com/funambol/server/db/db.xml</em>" wird nach dem gleichen Schema bearbeitet. Danach muss "<em>/opt/Funambol/bin/install</em>" ausgeführt werden (ggf. zuvor die Umgebungsvariable JAVA_HOME setzen). Jetzt kann funambol per "<em>/opt/Funambol/bin/funambol start</em>" gestartet werden.</p>
<h2>Funambol in runlevel eintragen</h2>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>Funambol<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>funambol <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>
update-rc.d funambol defaults</pre></td></tr></table></div>

<h2>Funambol Admin-Tool</h2>
<p>Das Funambol Admin-Tool kann von der Funambol-Homepage heruntergeladen werden. Hier kann man das initiale Admin-Passwort ändern.<br />
Des Weiteren muss man im "Server Settings"-Tab die Server URI ändern. Sie sollte dieses Format haben:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">http:<span style="color: #000000; font-weight: bold;">//&lt;</span>SERVER<span style="color: #000000; font-weight: bold;">&gt;</span>:<span style="color: #000000; font-weight: bold;">&lt;</span>PORT<span style="color: #000000; font-weight: bold;">&gt;/</span>funambol<span style="color: #000000; font-weight: bold;">/</span>ds</pre></td></tr></table></div>

<h1>Testen</h1>
<p>Nun kann man sich mit URL, Benutzername und Passwort am Server anmelden und synchronisieren. Da Autoprovisioning aktiviert ist, kann man Benutzername und Passwort frei wählen. Dies sollte jedoch in einem Produktivsystem geändert werden, da sich sonst jeder am Server anmelden kann. Dazu muss man den Officer im "Server Settings"-Tab ändern.</p>
]]></content:encoded>
			<wfw:commentRss>http://johker.ibutho.de/2009/08/09/funambol-installation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Der neue Server: Teil 9 Backup</title>
		<link>http://johker.ibutho.de/2009/08/02/der-neue-server-teil-9-backup/</link>
		<comments>http://johker.ibutho.de/2009/08/02/der-neue-server-teil-9-backup/#comments</comments>
		<pubDate>Sun, 02 Aug 2009 15:05:25 +0000</pubDate>
		<dc:creator>johker</dc:creator>
				<category><![CDATA[Howto]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[c't]]></category>
		<category><![CDATA[duplicity]]></category>
		<category><![CDATA[ftp]]></category>
		<category><![CDATA[ftplicity]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[rsync]]></category>

		<guid isPermaLink="false">http://johker.ibutho.de/?p=261</guid>
		<description><![CDATA[Der Server ist zwar nicht mehr neu, aber dieser Beitrag ist evtl. dennoch für einige hilfreich. Deshalb: Viel Spaß!
Heute widme ich mich dem Thema Backup. Das habe ich viel zu stark vernachlässigt und will das jetzt nachholen. Das Tool der Wahl ist duplicity mit dem c't Wrapper-Skript ftplicity. Duplicity benutzt unter der Decke rsync zur [...]]]></description>
			<content:encoded><![CDATA[<p>Der Server ist zwar nicht mehr neu, aber dieser Beitrag ist evtl. dennoch für einige hilfreich. Deshalb: Viel Spaß!</p>
<p>Heute widme ich mich dem Thema Backup. Das habe ich viel zu stark vernachlässigt und will das jetzt nachholen. Das Tool der Wahl ist <strong><em>duplicity</em></strong> mit dem c't Wrapper-Skript <strong><em>ftplicity</em></strong>. Duplicity benutzt unter der Decke <em>rsync</em> zur Erkennung der Deltas. Das Skript wird so konfiguriert, dass es täglich ein inkrementelles Backup macht und monatlich ein volles Backup und dabei die alten Backups löscht. Während des Backup-Prozesses werden auch Backups der MySQL- und postgreSQL-Datenbanken mit den mitgelieferten Tools erstellt (nicht einfach durch Kopieren der Datenbankdateien, da man dabei einen inkonsistenten Zustand erwischen könnte und die Datenbank unbrauchbar ist).</p>
<h1>Installation</h1>
<p>Zuerst die Installation der benötigten Pakete:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td 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> duplicity ncftp
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>downloads.sourceforge.net<span style="color: #000000; font-weight: bold;">/</span>project<span style="color: #000000; font-weight: bold;">/</span>ftplicity<span style="color: #000000; font-weight: bold;">/</span>ftplicity<span style="color: #000000; font-weight: bold;">/</span>1.5.0.2<span style="color: #000000; font-weight: bold;">/</span>ftplicity_1.5.0.2.tgz?<span style="color: #007800;">use_mirror</span>=switch
<span style="color: #c20cb9; font-weight: bold;">tar</span> xvfz ftplicity_1.5.0.2.tgz
<span style="color: #c20cb9; font-weight: bold;">mv</span> ftplicity_1.5.0.2<span style="color: #000000; font-weight: bold;">/</span>ftplicity <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>
<span style="color: #c20cb9; font-weight: bold;">chown</span> root: <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>ftplicity
<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">755</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>bin<span style="color: #000000; font-weight: bold;">/</span>ftplicity</pre></td></tr></table></div>

<h1>Konfiguration</h1>
<h2>Erstellung eines GPG-Schlüssel für Backups</h2>
<p>Da <em>ftplicity</em> Backups automatisch verschlüsselt ablegt, ist es nötig einen GPG-Schlüssel zu erstellen:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">gpg <span style="color: #660033;">--gen-key</span></pre></td></tr></table></div>

<p><code><br />
root@domain.tld:~# gpg --gen-key<br />
gpg (GnuPG) 1.4.9; Copyright (C) 2008 Free Software Foundation, Inc.<br />
This is free software: you are free to change and redistribute it.<br />
There is NO WARRANTY, to the extent permitted by law.</p>
<p>gpg: keyring `/root/.gnupg/secring.gpg' created<br />
Please select what kind of key you want:<br />
   (1) DSA and Elgamal (default)<br />
   (2) DSA (sign only)<br />
   (5) RSA (sign only)<br />
Your selection? <-- ENTER<br />
DSA keypair will have 1024 bits.<br />
ELG-E keys may be between 1024 and 4096 bits long.<br />
What keysize do you want? (2048) <-- ENTER<br />
Requested keysize is 2048 bits<br />
Please specify how long the key should be valid.<br />
         0 = key does not expire<br />
      <n>  = key expires in n days<br />
      <n>w = key expires in n weeks<br />
      <n>m = key expires in n months<br />
      <n>y = key expires in n years<br />
Key is valid for? (0) <-- ENTER<br />
Key does not expire at all<br />
Is this correct? (y/N) <-- y</p>
<p>You need a user ID to identify your key; the software constructs the user ID<br />
from the Real Name, Comment and Email Address in this form:<br />
    "Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>"</p>
<p>Real name: Musterserver Backup<br />
Email address: backup@domain.tld<br />
Comment: Key for System Backups on domain.tld<br />
You selected this USER-ID:<br />
    "domain.tld Backup (Key for System Backups on domain.tld) <backup@domain.tld>"</p>
<p>Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? <-- O<br />
You need a Passphrase to protect your secret key.</p>
<p>Enter passphrase: <-- Passwort eingeben<br />
We need to generate a lot of random bytes. It is a good idea to perform<br />
some other action (type on the keyboard, move the mouse, utilize the<br />
disks) during the prime generation; this gives the random number<br />
generator a better chance to gain enough entropy.<br />
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++.+++++++++++++++.++++++++++++++++++++.+++++..+++++++++++++++>++++++++++>.+++++...........<+++++>+++++..<.+++++.....................................................>.+++++.....+++++</p>
<p>gpg: /root/.gnupg/trustdb.gpg: trustdb created<br />
gpg: key 123ABC45 marked as ultimately trusted<br />
public and secret key created and signed.</p>
<p>...<br />
</code></p>
<p>Die achtstellige ID (im Beispiel <strong>123ABC45</strong>) bitte merken, da diese später benötigt wird. Ebenso das Passwort.</p>
<p>Danach legen exportieren wir noch unsere Schlüssel (public/private), damit wir diese an einem sicheren Ort speichern können, damit unsere Daten nicht verloren gehen, sollte die Festplatte sich verabschieden:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">root<span style="color: #000000; font-weight: bold;">@</span>domain.tld:~<span style="color: #000000; font-weight: bold;">/</span>gpg-key<span style="color: #666666; font-style: italic;"># gpg --output backup_pub.gpg --armor --export 123ABC45</span>
root<span style="color: #000000; font-weight: bold;">@</span>domain.tld:~<span style="color: #000000; font-weight: bold;">/</span>gpg-key<span style="color: #666666; font-style: italic;"># gpg --output backup_sec.gpg --armor --export-secret-key 123ABC45</span></pre></td></tr></table></div>

<h2>ftplicity</h2>
<p>Nun starten wir ftplicity einmal, damit eine Standardkonfiguration angelegt wird, die wir an unsere Wünsche anpassen können:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">ftplicity system create</pre></td></tr></table></div>

<p>Nun editieren wir die Datei "<em>/root/.ftplicity/system/conf</em>":</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># gpg key data (for symmetric encryption comment out GPG_KEY)</span>
<span style="color: #007800;">GPG_KEY</span>=<span style="color: #ff0000;">'123ABC45'</span>
<span style="color: #007800;">GPG_PW</span>=<span style="color: #ff0000;">'PASSWORD'</span>
<span style="color: #666666; font-style: italic;"># gpg options passed from duplicity to gpg process (default='')</span>
<span style="color: #666666; font-style: italic;"># e.g. &quot;--trust-model pgp|classic|direct|always&quot; </span>
<span style="color: #666666; font-style: italic;">#   or &quot;--compress-algo=bzip2 --bzip2-compress-level=9&quot;</span>
<span style="color: #666666; font-style: italic;">#GPG_OPTS=''</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># credentials &amp; server address of the backup target (URL-Format)</span>
<span style="color: #666666; font-style: italic;"># syntax is</span>
<span style="color: #666666; font-style: italic;">#   scheme://user[:password]@host[:port]/[/]path</span>
<span style="color: #666666; font-style: italic;"># probably one out of</span>
<span style="color: #666666; font-style: italic;">#   file:///some_dir</span>
<span style="color: #666666; font-style: italic;">#   ftp://user[:password]@other.host[:port]/some_dir</span>
<span style="color: #666666; font-style: italic;">#   hsi://user[:password]@other.host/some_dir</span>
<span style="color: #666666; font-style: italic;">#   cf+http://container_name</span>
<span style="color: #666666; font-style: italic;">#   imap://user[:password]@host.com[/from_address_prefix]</span>
<span style="color: #666666; font-style: italic;">#   imaps://user[:password]@host.com[/from_address_prefix]</span>
<span style="color: #666666; font-style: italic;">#   rsync://user[:password]@other.host[:port]::/module/some_dir</span>
<span style="color: #666666; font-style: italic;">#   rsync://user[:password]@other.host[:port]/relative_path</span>
<span style="color: #666666; font-style: italic;">#   rsync://user[:password]@other.host[:port]//absolute_path</span>
<span style="color: #666666; font-style: italic;">#   s3://host/bucket_name[/prefix]</span>
<span style="color: #666666; font-style: italic;">#   s3+http://bucket_name[/prefix]</span>
<span style="color: #666666; font-style: italic;">#   scp://user[:password]@other.host[:port]/some_dir</span>
<span style="color: #666666; font-style: italic;">#   ssh://user[:password]@other.host[:port]/some_dir</span>
<span style="color: #666666; font-style: italic;">#   tahoe://alias/directory</span>
<span style="color: #666666; font-style: italic;">#   webdav://user[:password]@other.host/some_dir</span>
<span style="color: #666666; font-style: italic;">#   webdavs://user[:password]@other.host/some_dir </span>
<span style="color: #666666; font-style: italic;">###</span>
<span style="color: #666666; font-style: italic;"># TARGET='scheme://user[:password]@host[:port]/[/]path'</span>
<span style="color: #007800;">TARGET</span>=<span style="color: #ff0000;">'ftp://&lt;USER&gt;:&lt;PASS&gt;@&lt;HOST&gt;/&lt;DIR&gt;'</span>
<span style="color: #666666; font-style: italic;"># optionally the password can be defined as extra variable</span>
<span style="color: #666666; font-style: italic;"># if password is set already in TARGET, this setting replaces it</span>
<span style="color: #666666; font-style: italic;">#TARGET_PW='_backend_password_'</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># base directory to backup</span>
<span style="color: #007800;">SOURCE</span>=<span style="color: #ff0000;">'/'</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Time frame for old backups to keep, Used for the &quot;purge&quot; command.  </span>
<span style="color: #666666; font-style: italic;"># see duplicity man page, chapter TIME_FORMATS)</span>
<span style="color: #666666; font-style: italic;"># defaults to 1M, if not set</span>
<span style="color: #666666; font-style: italic;">#MAX_AGE=1M</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Number of full backups to keep. Used for the &quot;purge-full&quot; command. </span>
<span style="color: #666666; font-style: italic;"># See duplicity man page, action &quot;remove-all-but-n-full&quot;.</span>
<span style="color: #666666; font-style: italic;"># defaults to 1, if not set </span>
<span style="color: #666666; font-style: italic;">#MAX_FULL_BACKUPS=1</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># verbosity of output (5 for gpg errors, 9 for bug fixing)</span>
<span style="color: #666666; font-style: italic;"># default is 4, if not set</span>
<span style="color: #666666; font-style: italic;">#VERBOSITY=5</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># temporary file space. at least the size of the biggest file in backup</span>
<span style="color: #666666; font-style: italic;"># for a successful restoration process. (default is '/tmp', if not set)</span>
<span style="color: #666666; font-style: italic;">#TEMP_DIR=/tmp</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># sets duplicity --time-separator option (since v0.4.4.RC2) to allow users </span>
<span style="color: #666666; font-style: italic;"># to change the time separator from ':' to another character that will work </span>
<span style="color: #666666; font-style: italic;"># on their system.  HINT: For Windows SMB shares, use --time-separator='_'.</span>
<span style="color: #666666; font-style: italic;"># NOTE: '-' is not valid as it conflicts with date separator.</span>
<span style="color: #666666; font-style: italic;"># ATTENTION: only use this with duplicity &lt; 0.5.10, since then default file </span>
<span style="color: #666666; font-style: italic;">#            naming is compatible and this option is pending depreciation </span>
<span style="color: #666666; font-style: italic;">#DUPL_PARAMS=&quot;$DUPL_PARAMS --time-separator _ &quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># activates duplicity --short-filenames option, when uploading to a file</span>
<span style="color: #666666; font-style: italic;"># system that can't have filenames longer than 30 characters (e.g. Mac OS 8)</span>
<span style="color: #666666; font-style: italic;"># or have problems with ':' as part of the filename (e.g. Microsoft Windows)</span>
<span style="color: #666666; font-style: italic;"># ATTENTION: only use this with duplicity &lt; 0.5.10, since then default file </span>
<span style="color: #666666; font-style: italic;">#            naming is compatible and this option is pending depreciation  </span>
<span style="color: #666666; font-style: italic;">#DUPL_PARAMS=&quot;$DUPL_PARAMS --short-filenames &quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># activates duplicity --full-if-older-than option (since duplicity v0.4.4.RC3) </span>
<span style="color: #666666; font-style: italic;"># forces a full backup if last full backup reaches a specified age, for the </span>
<span style="color: #666666; font-style: italic;"># format of MAX_FULLBKP_AGE see duplicity man page, chapter TIME_FORMATS</span>
<span style="color: #666666; font-style: italic;">#MAX_FULLBKP_AGE=1M</span>
<span style="color: #666666; font-style: italic;">#DUPL_PARAMS=&quot;$DUPL_PARAMS --full-if-older-than $MAX_FULLBKP_AGE &quot; </span>
&nbsp;
<span style="color: #666666; font-style: italic;"># sets duplicity --volsize option (available since v0.4.3.RC7)</span>
<span style="color: #666666; font-style: italic;"># set the size of backup chunks to VOLSIZE MB instead of the default 5MB.</span>
<span style="color: #666666; font-style: italic;"># VOLSIZE must be number of MB's to set the volume size to. </span>
<span style="color: #666666; font-style: italic;">#VOLSIZE=50</span>
<span style="color: #666666; font-style: italic;">#DUPL_PARAMS=&quot;$DUPL_PARAMS --volsize $VOLSIZE &quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># more duplicity command line options can be added in the following way</span>
<span style="color: #666666; font-style: italic;"># don't forget to leave a separating space char at the end</span>
<span style="color: #666666; font-style: italic;">#DUPL_PARAMS=&quot;$DUPL_PARAMS --put_your_options_here &quot;</span></pre></td></tr></table></div>

<p>Und nun noch die Datei "<em>/root/.ftplicity/system/exclude</em>":</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>dev
<span style="color: #000000; font-weight: bold;">/</span>proc
<span style="color: #000000; font-weight: bold;">/</span>sys
<span style="color: #000000; font-weight: bold;">/</span>tmp
<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>cache
<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>tmp
<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run</pre></td></tr></table></div>

<p>Danach erstellen wir unter "<em>/usr/local/sbin/</em>" die Datei <strong>db_backup</strong> mit Rechten "700":</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Script to backup MySQL and postgreSQL databases</span>
<span style="color: #666666; font-style: italic;"># author: johker</span>
&nbsp;
<span style="color: #666666; font-style: italic;">############### CHANGE THESE VARIABLE IF NECESSARY ####################</span>
&nbsp;
<span style="color: #007800;">MYSQL_USER</span>=<span style="color: #ff0000;">&quot;MYSQL_USER&quot;</span>
<span style="color: #007800;">MYSQL_PW</span>=<span style="color: #ff0000;">&quot;MYSQL_PASSWORD&quot;</span>
<span style="color: #007800;">POSTGRES_USER</span>=<span style="color: #ff0000;">&quot;POSTGRES_USER&quot;</span>
<span style="color: #007800;">POSTGRES_PW</span>=<span style="color: #ff0000;">&quot;POSTGRES_PASSWORD&quot;</span>
<span style="color: #007800;">TMP</span>=<span style="color: #ff0000;">&quot;/tmp/&quot;</span>
<span style="color: #007800;">FINAL_LOC</span>=<span style="color: #ff0000;">&quot;/var/backups/&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">################ DON'T CHANGE ANYTHING BELOW THIS LINE ################</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Creating backup of MySQL databases&quot;</span>
mysqldump -u<span style="color: #007800;">$MYSQL_USER</span> -p<span style="color: #007800;">$MYSQL_PW</span> <span style="color: #660033;">--all-databases</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$FINAL_LOC</span><span style="color: #ff0000;">&quot;mysql.sql&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">gzip</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$FINAL_LOC</span><span style="color: #ff0000;">&quot;mysql.sql&quot;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Creating backup of postgreSQL databases&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">su</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;cd <span style="color: #007800;">$TMP</span> &amp;&amp; pg_dumpall &gt; <span style="color: #007800;">$TMP</span>'postgres.out'&quot;</span> <span style="color: #007800;">$POSTGRES_USER</span>
<span style="color: #c20cb9; font-weight: bold;">gzip</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$TMP</span><span style="color: #ff0000;">'postgres.out'</span> 
<span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$TMP</span><span style="color: #ff0000;">'postgres.out.gz'</span> <span style="color: #007800;">$FINAL_LOC</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">640</span> <span style="color: #007800;">$FINAL_LOC</span><span style="color: #ff0000;">&quot;mysql.sql.gz&quot;</span> <span style="color: #007800;">$FINAL_LOC</span><span style="color: #ff0000;">&quot;postgres.out.gz&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">chown</span> root: <span style="color: #007800;">$FINAL_LOC</span><span style="color: #ff0000;">&quot;mysql.sql.gz&quot;</span> <span style="color: #007800;">$FINAL_LOC</span><span style="color: #ff0000;">&quot;postgres.out.gz&quot;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></pre></td></tr></table></div>

<p>Und in die Datei "<em>/root/.ftplicity/system/pre</em>" fügen wir folgende Zeile ein:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<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>db_backup</pre></td></tr></table></div>

<h2>Testen</h2>
<p>Mit folgendem Befehl kann man die ftplicity-Konfiguration testen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ftplicity system status</pre></div></div>

<p>Wenn alles o.k. ist, kann man mit folgedem Befehl ein initiales Backup anlegen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ftplicity system backup</pre></div></div>

<h2>Erstellen eines Cronjobs</h2>
<p>Da wir das Backup nicht jedes mal händisch anstoßen wollen, hier einträge für die crontab von root (editierbar per "<em>crontab -e</em>" als Benutzer <em>root</em>):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># run the (incremental) backup each night at 03:23h</span>
<span style="color: #000000;">23</span> <span style="color: #000000;">3</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</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>bin<span style="color: #000000; font-weight: bold;">/</span>ftplicity system backup
<span style="color: #666666; font-style: italic;"># do a full backup once per month &amp; delete old backups at 04:47h</span>
<span style="color: #000000;">47</span> <span style="color: #000000;">4</span> <span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</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>bin<span style="color: #000000; font-weight: bold;">/</span>ftplicity system purge <span style="color: #660033;">--force</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</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>bin<span style="color: #000000; font-weight: bold;">/</span>ftplicity system purge-full <span style="color: #660033;">--force</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</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>bin<span style="color: #000000; font-weight: bold;">/</span>ftplicity system full</pre></td></tr></table></div>

<h1>Quellen</h1>
<p>http://www.howtoforge.com/ftp-backups-with-duplicity-ftplicity-debian-etch</p>
<p>http://maff.ailoo.net/2009/07/backup-virtual-machines-lvm-snapshots-ftplicity-duplicity/</p>
<p>http://robert.penz.name/161/howto-backup-your-dedicated-server-to-a-foreign-ftp-server/</p>
]]></content:encoded>
			<wfw:commentRss>http://johker.ibutho.de/2009/08/02/der-neue-server-teil-9-backup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Der neue Server: Teil 8 Monitoring mit munin</title>
		<link>http://johker.ibutho.de/2009/04/04/der-neue-server-teil-8-monitoring-mit-munin/</link>
		<comments>http://johker.ibutho.de/2009/04/04/der-neue-server-teil-8-monitoring-mit-munin/#comments</comments>
		<pubDate>Sat, 04 Apr 2009 14:29:17 +0000</pubDate>
		<dc:creator>johker</dc:creator>
				<category><![CDATA[Howto]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[client]]></category>
		<category><![CDATA[konfiguration]]></category>
		<category><![CDATA[mod_status]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[munin]]></category>
		<category><![CDATA[node]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[server-status]]></category>
		<category><![CDATA[system monitoring]]></category>

		<guid isPermaLink="false">http://johker.ibutho.de/?p=222</guid>
		<description><![CDATA[Munin ist ein Tool zum System-Monitoring, ist einfach in der Konfiguration, bietet eine Vielfalt an Plugins und stellt die Ergebnisse über ein Webinterface grafisch dar. Im folgenden wird die Installation und eine beispielhafte Basiskonfiguration geschildert. Munin hat die Möglichkeit Daten von mehreren Systemen zu sammeln und diese alle zentral zugänglich zu machen. Hier wird nur [...]]]></description>
			<content:encoded><![CDATA[<p><em>Munin</em> ist ein Tool zum System-Monitoring, ist einfach in der Konfiguration, bietet eine Vielfalt an Plugins und stellt die Ergebnisse über ein Webinterface grafisch dar. Im folgenden wird die Installation und eine beispielhafte Basiskonfiguration geschildert. <em>Munin</em> hat die Möglichkeit Daten von mehreren Systemen zu sammeln und diese alle zentral zugänglich zu machen. Hier wird nur darauf eingegangen Server und Client auf dem gleichen System zu installieren, doch die Erweiterung gestaltet sich sehr einfach und die Projekthomepage bietet mit ihrem Wiki eine gute Anlaufstelle für Fragen.</p>
<p>Installation:</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> munin munin-node munin-plugins-extra</pre></div></div>

<p>Konfiguration:<br />
<em>/etc/munin/munin.conf</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>domain.tld<span style="color: #7a0874; font-weight: bold;">&#93;</span>
    address 127.0.0.1
    use_node_name <span style="color: #c20cb9; font-weight: bold;">yes</span></pre></div></div>

<p>Evtl. muss man auch die Variable "<em>htmldir</em>" anpassen.</p>
<p><em>/etc/munin/munin.conf</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#host *</span>
host 127.0.0.1</pre></div></div>

<p><em>Munin</em> aktualisiert die Daten in der Standardkonfiguration alle 5 Minuten, d.h. man muss evtl. etwas warten, bis die ersten Daten über die Weboberfläche verfügbar sind. Die Weboberfläche kann über die Adresse, die man in "<em>htmldir</em>" in der Datei <em>munin.conf</em> definiert hat, aufgerufen werden. Man kann/sollte dieses Verzeichnis passwortschützen, damit nicht jeder darauf zugreifen kann.</p>
<p>Falls man Ausschau nach weiteren Plugins hält, dann ist <a href="http://muninexchange.projects.linpro.no/?about" target="_blank">http://muninexchange.projects.linpro.no/?about</a> eine gute Anlaufstelle. Des Weiteren liegen unter "<em>/usr/share/munin/plugins/</em>" weitere Plugins, die man einfach nach "<em>/etc/munin/plugins</em>" linken kann und danach noch in "<em>/etc/munin/plugin-conf.d/munin-node</em>" konfigurieren kann.</p>
<h1>apache Plugin</h1>
<p>Damit das apache-Plugin funktioniert, muss <em>mod_status</em> aktiviert werden:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">a2enmod status</pre></div></div>

<p>Danach muss der Zugriff auf die Status-Seite aktiviert und geregelt werden:<br />
<em>/etc/apache2/mods-enabled/status.conf</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;</span>IfModule mod_status.c<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Allow server status reports generated by mod_status,</span>
<span style="color: #666666; font-style: italic;"># with the URL of http://servername/server-status</span>
<span style="color: #666666; font-style: italic;"># Uncomment and change the &quot;.example.com&quot; to allow</span>
<span style="color: #666666; font-style: italic;"># access from other hosts.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #000000; font-weight: bold;">&lt;</span>Location <span style="color: #000000; font-weight: bold;">/</span>server-status<span style="color: #000000; font-weight: bold;">&gt;</span>
    SetHandler server-status
    Order deny,allow
    Deny from all
    Allow from localhost ip6-localhost
<span style="color: #666666; font-style: italic;">#    Allow from .example.com</span>
<span style="color: #000000; font-weight: bold;">&lt;/</span>Location<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;/</span>IfModule<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>Quellen:</p>
<p>http://www.debuntu.org/how-to-monitoring-a-server-with-munin</p>
<p>http://munin.projects.linpro.no/wiki/plugin-conf.d</p>
]]></content:encoded>
			<wfw:commentRss>http://johker.ibutho.de/2009/04/04/der-neue-server-teil-8-monitoring-mit-munin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Der neue Server: Teil 7 roundcube</title>
		<link>http://johker.ibutho.de/2009/04/04/der-neue-server-teil-7-roundcube/</link>
		<comments>http://johker.ibutho.de/2009/04/04/der-neue-server-teil-7-roundcube/#comments</comments>
		<pubDate>Sat, 04 Apr 2009 10:29:57 +0000</pubDate>
		<dc:creator>johker</dc:creator>
				<category><![CDATA[Howto]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[imap]]></category>
		<category><![CDATA[imapproxy]]></category>
		<category><![CDATA[installer]]></category>
		<category><![CDATA[konfiguration]]></category>
		<category><![CDATA[mailclient]]></category>
		<category><![CDATA[mua]]></category>
		<category><![CDATA[mutt]]></category>
		<category><![CDATA[postfixadmin]]></category>
		<category><![CDATA[postfixadmin bridge]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[rcpfa]]></category>
		<category><![CDATA[rcube]]></category>
		<category><![CDATA[roundcube]]></category>
		<category><![CDATA[sieve]]></category>
		<category><![CDATA[webmail]]></category>

		<guid isPermaLink="false">http://johker.ibutho.de/?p=199</guid>
		<description><![CDATA[Oft hat man nicht die Möglichkeit mit einen E-Mail Client - wie z.B. Evolution oder Thunderbird - arbeiten zu können, deshalb wird hier darauf eingegangen wie man einen Webmailer - in diesem Fall roundcube - inkl. postfixadmin-Integration und Sieve-Plugin installiert.
imapproxy
Da http ein "stateless"-Protokoll ist, kann es - anders als IMAP-Clients - keine Verbindungen offen halten [...]]]></description>
			<content:encoded><![CDATA[<p>Oft hat man nicht die Möglichkeit mit einen E-Mail Client - wie z.B. Evolution oder Thunderbird - arbeiten zu können, deshalb wird hier darauf eingegangen wie man einen Webmailer - in diesem Fall <em><a href="http://roundcube.net/" target="_blank">roundcube</a></em> - inkl. <em>postfixadmin</em>-Integration und Sieve-Plugin installiert.</p>
<h1>imapproxy</h1>
<p>Da http ein "stateless"-Protokoll ist, kann es - anders als IMAP-Clients - keine Verbindungen offen halten und stellt deshalb sehr viele unnötige "LOGIN"-Anfragen. Um dies zu verhindern wird ein imapproxy installiert. Dieser wird dem Webmailer vorgeschaltet und hält die Verbindungen geöffnet. Stellt der Webmailer nun eine Anfrage an den Proxy, sucht dieser die Verbindung raus und benutzt die bestehende Verbindung anstatt eine neue aufzubauen. Der Proxy hält die Verbindung nicht für eine unbestimmte Zeit offen, sondern schließt sie nachdem ein Timeout abgelaufen ist.</p>
<p>Installation:</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> imapproxy</pre></div></div>

<p>Konfiguration:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">listen_address 127.0.0.1</pre></div></div>

<p>Wir ändern nur die oben genannte Zeile, den Rest belassen wir wie er ist. Da der IMAP-Proxy auf dem gleichen System wie der Mailserver läuft, lassen wir nur lokale Verbindungen zu.<br />
Wenn nun ein Programm/Skript den IMAP-Proxy nutzen soll, gibt man Port 1143 an, anstatt Port 143.</p>
<h1>roundcube</h1>
<p>Für <em>roundcube</em> brauchen wir zunächst einen vHost. Im Weiteren wird davon ausgegangen, dass <em>roundcube</em> unter <em>https://webmail.domain.tld/</em> verfügbar ist.<br />
Zunächst muss die neueste <em>roundcube</em> Version von <a href="http://roundcube.net/" target="_blank">http://roundcube.net/</a> heruntergeladen und in den vHost entpackt werden, damit es über <em>https://webmail.domain.tld/</em> verfügbar ist.<br />
Nun legen wir eine Datenbank inkl. Benutzer für <em>roundcube</em> an und importieren das postgres-Schema:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">su</span> - postgres
psql template1
CREATE USER roundcube WITH PASSWORD <span style="color: #ff0000;">'password'</span>;
CREATE DATABASE roundcube WITH OWNER roundcube ENCODING <span style="color: #ff0000;">'UNICODE'</span>;
\c - roundcube
\i <span style="color: #000000; font-weight: bold;">/</span>PFAD<span style="color: #000000; font-weight: bold;">/</span>ZU<span style="color: #000000; font-weight: bold;">/</span>ROUNDCUBE<span style="color: #000000; font-weight: bold;">/</span>SQL<span style="color: #000000; font-weight: bold;">/</span>postgres.initial.sql
\q</pre></div></div>

<p>Nun rufen wir im Browser roundcube auf, hängen der URL aber noch "<em>/installer</em>" an und folgen danach den Anweisungen. Nachden wir die Konfigurationsdateien kopiert und am aufgeforderten Ort gespeichert haben, können wir <em>roundcube</em> über den Browser aufrufen und uns mit unserem IMAP-Benutzernamen und -passwort anmelden. <strong>Jedoch</strong> sollte man damit noch warten, bis <em>postfixadmin-bridge</em> installiert ist, denn dann wird automatisch der vollständige Name aus den <em>postfixadmin</em>-Tabellen übernommen.</p>
<h2>postfixadmin-bridge</h2>
<p>Zur Installation von <em><a href="http://nejc.skoberne.net/projects/rcpfa/" target="_blank">rcpfa</a></em> (= <em>postfixadmin-bridge</em>) wird <em>patch</em> benötigt:</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> <span style="color: #c20cb9; font-weight: bold;">patch</span></pre></div></div>

<p>Danach entpackt man <em>rcpfa</em> in den <em>roundcube</em> Ordner, wechselt in das neue Unterverzeichnis und führt folgenden Befehl aus:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sh</span> INSTALL.TXT</pre></div></div>

<p>Sollten während des Patch-Vorgangs Probleme auftreten, kann man sich die *.rej-Dateien anschauen und die Probleme ggf. händisch lösen. Nach der Installation muss noch die <em>roundcube</em>-Konfiguration angepasst werden (beim Patchen wurden neue Variablen in der Konfiguration hinzugefügt) und danach kann man im Einstellungs-Tab von <em>roundcube</em> Einstellungen aus <em>postfixadmin</em> ändern.</p>
<h2>sieve rules</h2>
<p>Das sieve-Plugin für roundcube kann man hier herunterladen: <a href="http://www.tehinterweb.co.uk/roundcube/#ptsieverules" target="_blank">http://www.tehinterweb.co.uk/roundcube/#ptsieverules</a> und anschließend mit</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">patch</span> <span style="color: #660033;">-ul</span> <span style="color: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">/</span>PFAD<span style="color: #000000; font-weight: bold;">/</span>ZU<span style="color: #000000; font-weight: bold;">/</span>ROUNDCUBE<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-p1</span> <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">/</span>PFAD<span style="color: #000000; font-weight: bold;">/</span>ZUM<span style="color: #000000; font-weight: bold;">/</span>PATCH</pre></div></div>

<p>installieren.<br />
Die parallele Installation von <em>rcpfa</em> und <em>sieve rules</em> ist problematisch, da der Patch-Vorgang sehr wahrscheinlich an einer Stelle fehlschlägt und man selbst Hand anlegen muss.<br />
Auch dieses Plugin hat Variablen zur <em>roundcube</em>-Konfiguration hinzugefügt, die angepasst werden müssen, bevor das Plugin benutzt werden kann.</p>
<h1>mutt</h1>
<p>Um auch über die Konsole auf E-Mails zugreifen kann, installieren wir zusätzlich noch <em>mutt</em>. Manche Leute fragen sich vielleicht, wozu man einen Konsolenmailer braucht, bzw. brauchen könnte. Ein interessanter Punkt ist, dass <em>mutt</em> einen weitaus größeren Funktionsumfang als ein Webmailer bietet und außerdem sieht es auch schick aus, wenn man seine Mails auf der Konsole liest.</p>
<p>Installation:</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> mutt</pre></div></div>

<p>Eine einfache Konfiguration ("<em>~/.muttrc</em>"):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">set</span> <span style="color: #007800;">folder</span>=<span style="color: #ff0000;">&quot;imap://localhost&quot;</span>
<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #007800;">spoolfile</span>=<span style="color: #ff0000;">&quot;imap://localhost/INBOX&quot;</span>
<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #007800;">imap_authenticators</span>=<span style="color: #ff0000;">&quot;LOGIN&quot;</span>
<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #007800;">imap_user</span>=<span style="color: #ff0000;">&quot;username&quot;</span>
<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #007800;">imap_pass</span>=<span style="color: #ff0000;">&quot;password&quot;</span>
<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #007800;">move</span>=no
&nbsp;
<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #007800;">editor</span>=<span style="color: #ff0000;">'vim -c &quot;set t_Co=8&quot; -c &quot;syntax on&quot; -c &quot;/^$&quot; -c &quot;set tw=72&quot; -c &quot;set number&quot;'</span>
<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #007800;">header_cache</span>=~<span style="color: #000000; font-weight: bold;">/</span>.mutt_header</pre></div></div>

<p>Die <em>mutt</em>-Konfiguration ist sehr rudimentär und sollte zusätzlich noch an die eigenen Bedürfnisse angepasst werden, z.B. Sent-Ordner definieren, GPG-Schlüssel definieren, ...</p>
<p>Quellen:</p>
<p>http://roundcube.net/</p>
<p>http://nejc.skoberne.net/projects/rcpfa/</p>
<p>http://www.tehinterweb.co.uk/roundcube/#ptsieverules</p>
]]></content:encoded>
			<wfw:commentRss>http://johker.ibutho.de/2009/04/04/der-neue-server-teil-7-roundcube/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Der neue Server: Teil 6 Spambekämpfung</title>
		<link>http://johker.ibutho.de/2009/04/01/der-neue-server-teil-6-spambekampfung/</link>
		<comments>http://johker.ibutho.de/2009/04/01/der-neue-server-teil-6-spambekampfung/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 15:55:25 +0000</pubDate>
		<dc:creator>johker</dc:creator>
				<category><![CDATA[Howto]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[amavis]]></category>
		<category><![CDATA[amavisd-new]]></category>
		<category><![CDATA[anti-spam]]></category>
		<category><![CDATA[bash script]]></category>
		<category><![CDATA[bayes]]></category>
		<category><![CDATA[clamav]]></category>
		<category><![CDATA[content filter]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[cronjob]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[detect virus]]></category>
		<category><![CDATA[dkim]]></category>
		<category><![CDATA[dspam]]></category>
		<category><![CDATA[fight junk]]></category>
		<category><![CDATA[fight spam]]></category>
		<category><![CDATA[fight virus]]></category>
		<category><![CDATA[gateway]]></category>
		<category><![CDATA[konfiguration]]></category>
		<category><![CDATA[lmtp]]></category>
		<category><![CDATA[mta]]></category>
		<category><![CDATA[policyd-weight]]></category>
		<category><![CDATA[postfix]]></category>
		<category><![CDATA[pyzor]]></category>
		<category><![CDATA[razor]]></category>
		<category><![CDATA[sa-compile]]></category>
		<category><![CDATA[sa-learn]]></category>
		<category><![CDATA[sa-update]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[sieve]]></category>
		<category><![CDATA[smtp]]></category>
		<category><![CDATA[spamassassin]]></category>
		<category><![CDATA[Spambekämpfung]]></category>
		<category><![CDATA[test]]></category>
		<category><![CDATA[Virenfilter]]></category>
		<category><![CDATA[volatile]]></category>

		<guid isPermaLink="false">http://johker.ibutho.de/?p=192</guid>
		<description><![CDATA[Nachfolgend wird erklärt, wie man policyd-weight, amavisd-new, clamav, spamassassin, dspam installiert, konfiguriert und in das bestehende Setup integriert.
policyd-weight
policyd-weight ist ein effektives Tool zur Spambekämpfung schon vor der Annahme einer E-Mail. Es überprüft das "Envelope" und gleicht die Absenderadresse gegen mehrere DNS-Blacklists ab.

aptitude install policyd-weight

Danach erstellen wir noch eine Standardkonfiguration für policyd-weight:

policyd-weight defaults &#62; /etc/policyd-weight.conf

Folgende Zeile [...]]]></description>
			<content:encoded><![CDATA[<p>Nachfolgend wird erklärt, wie man <em>policyd-weight</em>, <em>amavisd-new</em>, <em>clamav</em>, <em>spamassassin</em>, <em>dspam</em> installiert, konfiguriert und in das bestehende Setup integriert.</p>
<h1>policyd-weight</h1>
<p><em>policyd-weight</em> ist ein effektives Tool zur Spambekämpfung schon vor der Annahme einer E-Mail. Es überprüft das "Envelope" und gleicht die Absenderadresse gegen mehrere DNS-Blacklists ab.</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> policyd-weight</pre></div></div>

<p>Danach erstellen wir noch eine Standardkonfiguration für <em>policyd-weight</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">policyd-weight defaults <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>policyd-weight.conf</pre></div></div>

<p>Folgende Zeile in "<em>/etc/postfix/main.cf</em>" ändern:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">###  check_policy_service inet:127.0.0.1:12525,</span></pre></div></div>

<p>... zu:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">check_policy_service inet:127.0.0.1:<span style="color: #000000;">12525</span>,</pre></div></div>

<p>Jetzt muss die <em>postfix</em>-Konfiguration neu geladen werden und <em>policyd-weight</em> neu gestartet werden:</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>policyd-weight restart
postfix reload</pre></div></div>

<h1>amavisd-new</h1>
<p><em>Amavisd-new</em> ist ein Content-Filter, der sich in fast jeden MTA integrieren lässt. Über <em>amavisd-new</em> lassen sich viele verschiedene Tools, wie z.B. <em>ClamAV</em> zur Virenprüfung, <em>Spamassassin</em> zur Spamfilterung oder <em>dspam</em> - ebenfalls zu Spamfilterung - integrieren.<br />
Wenn eine E-Mail in <em>postfix</em> ankommt, wird diese an <em>amavis</em> weitergeleitet, überprüft und wieder - mit zusätzlichen Headern - an <em>postfix</em> zur Auslieferung zurückgesendet. Natürlich kann man <em>amavis</em> auch so konfigurieren, dass bestimmte Nachrichtentypen, z.B. Virusmails oder Spammails, sofort geblockt werden. Sobald die Nachricht von <em>amavis</em> an postfix zurückgegeben wurde, kann eine automatische Einsortierung in Ordner über <em>sieve</em> folgen (z.B. Spam-Mails nach Junk).</p>
<p>Installation:<br />
Zu "<em>/etc/apt/sources.list</em>" hinzufügen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># volatile repository (e.g. for clamav)</span>
deb http:<span style="color: #000000; font-weight: bold;">//</span>volatile.debian.org<span style="color: #000000; font-weight: bold;">/</span>debian-volatile lenny<span style="color: #000000; font-weight: bold;">/</span>volatile main contrib non-free</pre></div></div>


<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> amavisd-new spamassassin clamav clamav-daemon clamav-freshclam pax lha arj <span style="color: #c20cb9; font-weight: bold;">bzip2</span> unrar zoo nomarch <span style="color: #c20cb9; font-weight: bold;">cpio</span> lzop cabextract apt-listchanges libauthen-sasl-perl libdbi-perl dspam libmail-dkim-perl razor pyzor dcc-client libdbd-pg-perl</pre></div></div>

<p>Nun folgt die Konfiguration von <em>amavis</em> (Konfigurationsdateien sind unter "<em>/etc/amavis/conf.d/</em>" zu finden). Ich führe jeweils nur geänderte Zeilen auf:</p>
<p><em>01-debian</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$unrar</span>      = <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">'rar'</span>, <span style="color: #ff0000;">'unrar'</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #666666; font-style: italic;">#disabled (non-free, no security support)</span>
<span style="color: #666666; font-style: italic;">#$unrar         = undef;</span>
<span style="color: #007800;">$lha</span>    = <span style="color: #ff0000;">'lha'</span>; <span style="color: #666666; font-style: italic;">#disabled (non-free, no security support)</span>
<span style="color: #666666; font-style: italic;">#$lha   = undef;</span></pre></div></div>

<p><em>05-domain_id</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">@</span>local_domains_acl = <span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #ff0000;">&quot;.&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>;</pre></div></div>

<p><em>05-node_id</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$myhostname</span> = <span style="color: #ff0000;">&quot;mail.domain.tld&quot;</span>;</pre></div></div>

<p><em>15-content_filter_mode</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">@</span>bypass_virus_checks_maps = <span style="color: #7a0874; font-weight: bold;">&#40;</span> 
   \<span style="color: #000000; font-weight: bold;">%</span>bypass_virus_checks, \<span style="color: #000000; font-weight: bold;">@</span>bypass_virus_checks_acl, \<span style="color: #007800;">$bypass_virus_checks_re</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">@</span>bypass_spam_checks_maps = <span style="color: #7a0874; font-weight: bold;">&#40;</span>
   \<span style="color: #000000; font-weight: bold;">%</span>bypass_spam_checks, \<span style="color: #000000; font-weight: bold;">@</span>bypass_spam_checks_acl, \<span style="color: #007800;">$bypass_spam_checks_re</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>;</pre></div></div>

<p><em>20-debian_defaults</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$final_virus_destiny</span>      = D_DISCARD;  <span style="color: #666666; font-style: italic;"># (data not lost, see virus quarantine)</span>
<span style="color: #007800;">$final_banned_destiny</span>     = D_PASS;   <span style="color: #666666; font-style: italic;"># D_REJECT when front-end MTA</span>
<span style="color: #007800;">$final_spam_destiny</span>       = D_PASS;
<span style="color: #007800;">$final_bad_header_destiny</span> = D_PASS;     <span style="color: #666666; font-style: italic;"># False-positive prone (for spam)</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># $sa_spam_subject_tag = '***SPAM*** ';</span>
<span style="color: #007800;">$sa_tag_level_deflt</span>  = undef;</pre></div></div>

<p><em>50-user</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$max_servers</span> = <span style="color: #000000;">2</span>;
&nbsp;
<span style="color: #007800;">$policy_bank</span><span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #ff0000;">'MYNETS'</span><span style="color: #7a0874; font-weight: bold;">&#125;</span> = <span style="color: #7a0874; font-weight: bold;">&#123;</span>   <span style="color: #666666; font-style: italic;"># mail originating from @mynetworks</span>
  originating =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000;">1</span>,  <span style="color: #666666; font-style: italic;"># is true in MYNETS by default, but let's make it explicit</span>
  os_fingerprint_method =<span style="color: #000000; font-weight: bold;">&gt;</span> undef,  <span style="color: #666666; font-style: italic;"># don't query p0f for internal clients</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>;
&nbsp;
<span style="color: #007800;">$recipient_delimiter</span> = <span style="color: #ff0000;">'+'</span>;
&nbsp;
<span style="color: #007800;">$warnvirusrecip</span> = <span style="color: #000000;">1</span>;
&nbsp;
<span style="color: #007800;">$mailfrom_notify_admin</span> = <span style="color: #ff0000;">&quot;postmaster\@<span style="color: #007800;">$mydomain</span>&quot;</span>;
<span style="color: #007800;">$mailfrom_notify_recip</span> = <span style="color: #ff0000;">&quot;postmaster\@<span style="color: #007800;">$mydomain</span>&quot;</span>;
<span style="color: #007800;">$mailfrom_notify_spamadmin</span> = <span style="color: #ff0000;">&quot;postmaster\@<span style="color: #007800;">$mydomain</span>&quot;</span>;</pre></div></div>

<p>Jetzt fügen wir noch den <em>clamav</em>-Nutzer der <em>amavis</em>-Gruppe hinzu:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">adduser clamav amavis</pre></div></div>

<p>Danach müssen wir Änderungen an der <em>postfix</em>-Konfiguration vornehmen:</p>
<p><em>Zu <em>main.cf</em> hinzufügen</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">content_filter = amavis:<span style="color: #7a0874; font-weight: bold;">&#91;</span>127.0.0.1<span style="color: #7a0874; font-weight: bold;">&#93;</span>:<span style="color: #000000;">10024</span>
receive_override_options = no_address_mappings</pre></div></div>

<p><em>Zu <em>master.cf</em> hinzufügen</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">amavis       unix  -       -       n       -       <span style="color: #000000;">2</span>       lmtp 
    <span style="color: #660033;">-o</span> <span style="color: #007800;">lmtp_data_done_timeout</span>=<span style="color: #000000;">1200</span>
    <span style="color: #660033;">-o</span> <span style="color: #007800;">lmtp_send_xforward_command</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span>
    <span style="color: #660033;">-o</span> <span style="color: #007800;">disable_dns_lookups</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span>
    <span style="color: #660033;">-o</span> <span style="color: #007800;">max_use</span>=<span style="color: #000000;">20</span>
127.0.0.1:<span style="color: #000000;">10025</span> inet n  -       n       -       -       smtpd
    <span style="color: #660033;">-o</span> <span style="color: #007800;">content_filter</span>=
    <span style="color: #660033;">-o</span> <span style="color: #007800;">local_recipient_maps</span>=
    <span style="color: #660033;">-o</span> <span style="color: #007800;">relay_recipient_maps</span>=
    <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_delay_reject</span>=no
    <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_restriction_classes</span>=
    <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_client_restrictions</span>=
    <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_helo_restrictions</span>=
    <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_sender_restrictions</span>=
    <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_recipient_restrictions</span>=permit_mynetworks,reject
    <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_data_restrictions</span>=reject_unauth_pipelining
    <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_end_of_data_restrictions</span>=
    <span style="color: #660033;">-o</span> <span style="color: #007800;">mynetworks</span>=127.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8</span>    <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_error_sleep_time</span>=<span style="color: #000000;">0</span>
    <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_soft_error_limit</span>=<span style="color: #000000;">1001</span>
    <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_hard_error_limit</span>=<span style="color: #000000;">1000</span>
    <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_client_connection_count_limit</span>=<span style="color: #000000;">0</span>
    <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_client_connection_rate_limit</span>=<span style="color: #000000;">0</span>
    <span style="color: #660033;">-o</span> <span style="color: #007800;">receive_override_options</span>=no_header_body_checks,no_unknown_recipient_checks</pre></div></div>

<p>Zuletzt werden <em>postfix</em>, <em>amavis</em> und <em>clamav</em> neu gestartet:</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>postfix restart
<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>amavis restart
<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>clamav-daemon restart</pre></div></div>

<h2>Testen der Konfiguration</h2>
<p>Zum Testen genügt es eine Mail an den Mailserver zu schicken und sich danach die Header-Informationen anzuschauen. Finden sich ähnliche Header wie die folgenden in der Mail wieder, so wird amavis aufgerufen.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">X-virus-scanned: Debian amavisd-new at domain.tld
X-spam-flag: NO
X-spam-score: <span style="color: #000000;">2.898</span>
X-spam-level: <span style="color: #000000; font-weight: bold;">**</span>
X-spam-status: No, <span style="color: #007800;">score</span>=<span style="color: #000000;">2.898</span> <span style="color: #007800;">required</span>=<span style="color: #000000;">6.31</span> <span style="color: #007800;">tests</span>=<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #007800;">SPF_PASS</span>=-<span style="color: #000000;">0.001</span>, <span style="color: #007800;">TVD_SPACE_RATIO</span>=<span style="color: #000000;">2.899</span><span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div>

<p>Des Weiteren kann man mit folgendem Befehl testen, ob Spam erkannt wird:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sendmail</span> john<span style="color: #000000; font-weight: bold;">@</span>example.com <span style="color: #000000; font-weight: bold;">&lt;</span> <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>doc<span style="color: #000000; font-weight: bold;">/</span>spamassassin<span style="color: #000000; font-weight: bold;">/</span>examples<span style="color: #000000; font-weight: bold;">/</span>sample-spam.txt</pre></div></div>

<p>... oder Viren:</p>

<div class="wp_syntax"><div class="code"><pre class="test" style="font-family:monospace;">telnet localhost 25
HELO localhost
MAIL FROM: &lt;user@change_to_my_domain.tld&gt;
RCPT TO: &lt;user@change_to_my_domain.tld&gt;
DATA
From: virus-tester
To: undisclosed-recipients:;
Subject: amavisd test - simple - spam test pattern
X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*
.
&nbsp;
quit</pre></div></div>

<h1>Spamassassin Konfiguration</h1>
<p>Ans Ende der Datei "/etc/spamassassin/local.cf" anfügen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">use_bayes <span style="color: #000000;">1</span>
use_bayes_rules <span style="color: #000000;">1</span>
bayes_auto_learn <span style="color: #000000;">1</span>
bayes_auto_expire <span style="color: #000000;">0</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># pyzor</span>
use_pyzor <span style="color: #000000;">1</span>
pyzor_path <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>pyzor
&nbsp;
<span style="color: #666666; font-style: italic;"># razor</span>
use_razor2 <span style="color: #000000;">1</span>
razor_config <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>razor<span style="color: #000000; font-weight: bold;">/</span>razor-agent.conf</pre></div></div>

<p><em>/etc/spamassassin/v312.pre</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">loadplugin Mail::SpamAssassin::Plugin::DKIM</pre></div></div>

<p><em>/etc/spamassassin/v320.pre</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">loadplugin Mail::SpamAssassin::Plugin::Shortcircuit
loadplugin Mail::SpamAssassin::Plugin::Rule2XSBody</pre></div></div>

<p>Razor konfigurieren:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">su</span> - amavis
razor-admin <span style="color: #660033;">-create</span></pre></div></div>

<p>Spamassassin-Regeln neu laden:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">sa-update</pre></div></div>

<h2>Automatische Updates</h2>
<p>Um <em>spamassassin</em> voll auszureizen, richten wir einen <em>cronjob</em> ein über welchen jede Nacht die Regeln auf den neuesten Stand gebracht werden (als <strong>root</strong> ausführen!):</p>
<p><em>/usr/local/sbin/updateSpamassassin</em>:</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;
sa-update <span style="color: #000000; font-weight: bold;">&amp;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
sa-compile <span style="color: #000000; font-weight: bold;">&amp;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
&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;">crontab <span style="color: #660033;">-e</span>
<span style="color: #000000;">42</span> <span style="color: #000000;">3</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</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>updateSpamassassin <span style="color: #000000; font-weight: bold;">&amp;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null</pre></div></div>

<h2>Ham/Spam aus /var/vmail lernen</h2>
<p>Nun erstellen wir noch ein Skript, welches Spam, bzw. Ham aus den Mailboxen der Benutzer lernt (aus den Ordnern "INBOX" und "Junk"). Dieses Skript rufen wir wöchentlich über einen Cronjob auf.</p>
<p><em>/usr/local/sbin/trainSpamassassin</em>:</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: #007800;">VMAILDIR</span>=<span style="color: #ff0000;">&quot;/var/vmail&quot;</span>
<span style="color: #007800;">SADIR</span>=<span style="color: #ff0000;">&quot;/var/lib/amavis/.spamassassin&quot;</span>
<span style="color: #007800;">DBPATH</span>=<span style="color: #ff0000;">&quot;/var/lib/amavis/.spamassassin/bayes&quot;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #007800;">$VMAILDIR</span>
<span style="color: #000000; font-weight: bold;">for</span> domain <span style="color: #000000; font-weight: bold;">in</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">find</span> .<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-maxdepth</span> <span style="color: #000000;">1</span> <span style="color: #660033;">-not</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">&quot;.&quot;</span> <span style="color: #660033;">-type</span> d<span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #000000; font-weight: bold;">do</span>
        <span style="color: #007800;">domaindir</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$VMAILDIR</span>/<span style="color: #007800;">$domain</span>&quot;</span>
        <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #007800;">$domaindir</span>
        <span style="color: #000000; font-weight: bold;">for</span> user <span style="color: #000000; font-weight: bold;">in</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">find</span> .<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-maxdepth</span> <span style="color: #000000;">1</span> <span style="color: #660033;">-not</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">&quot;.&quot;</span> <span style="color: #660033;">-type</span> d<span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #000000; font-weight: bold;">do</span>
                <span style="color: #007800;">maildir</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$domaindir</span>/<span style="color: #007800;">$user</span>/maildir&quot;</span>
                <span style="color: #007800;">inbox</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$maildir</span>/cur&quot;</span>
                <span style="color: #007800;">junk</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$maildir</span>/.Junk/cur&quot;</span>
&nbsp;
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Learning ham from <span style="color: #007800;">$inbox</span>&quot;</span>
                sa-learn <span style="color: #660033;">--ham</span> <span style="color: #660033;">--showdots</span> <span style="color: #660033;">--dbpath</span> <span style="color: #007800;">$DBPATH</span> <span style="color: #007800;">$inbox</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Learning junk from <span style="color: #007800;">$junk</span>&quot;</span>
                sa-learn <span style="color: #660033;">--spam</span> <span style="color: #660033;">--showdots</span> <span style="color: #660033;">--dbpath</span> <span style="color: #007800;">$DBPATH</span> <span style="color: #007800;">$junk</span>
        <span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #660033;">-R</span> amavis:amavis <span style="color: #007800;">$SADIR</span></pre></div></div>

<p>Nun noch das Skript in die <em>crontab</em> aufnehmen (als <strong>root</strong> ausführen!):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">crontab <span style="color: #660033;">-e</span>
<span style="color: #000000;">33</span> <span style="color: #000000;">4</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000;">0</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>trainSpamassassin <span style="color: #000000; font-weight: bold;">&amp;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null</pre></div></div>

<h1>Globale sieve-Regeln</h1>
<p>Um dem Benutzer das Erstellen von <em>sieve</em>-Regeln für Spam zu ersparen, fügen wir in die Datei "/var/vmail/default.sieve" folgende Zeile ein, um Spam-Mails automatisch in den Ordner "Junk" zu verschieben (<em>sieve</em> wurde schon in Teil 5 dieser Serie konfiguriert):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">require <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;fileinto&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>;
<span style="color: #666666; font-style: italic;"># Move spam to spam folder</span>
<span style="color: #000000; font-weight: bold;">if</span> header :contains <span style="color: #ff0000;">&quot;X-Spam-Flag&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;YES&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  fileinto <span style="color: #ff0000;">&quot;Junk&quot;</span>;
  stop;
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<h1>dspam</h1>
<p>Die Konfiguration von <em>dspam</em> wird nachgereicht.</p>
<p>Quellen:</p>
<p>http://workaround.org/articles/ispmail-etch/#step-5-deliver-emails-through-the-dovecot-lda</p>
<p>http://www200.pair.com/mecham/spam/spamfilter20090215.html#amavisconfig</p>
<p>http://wiki.rootforum.de/mailserver/postfix/clamav_amavisd</p>
<p>http://www.howtoforge.com/virtual-users-domains-postfix-courier-mysql-squirrelmail-debian-lenny-p3</p>
<p>http://www.tuxj0b.de/HOWTO_Mailserver_mit_Postfix_Dovecot_Antispam_und_PostgreSQL_Backend</p>
]]></content:encoded>
			<wfw:commentRss>http://johker.ibutho.de/2009/04/01/der-neue-server-teil-6-spambekampfung/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Der neue Server: Teil 5 postfix</title>
		<link>http://johker.ibutho.de/2009/03/29/der-neue-server-teil-5-postfix/</link>
		<comments>http://johker.ibutho.de/2009/03/29/der-neue-server-teil-5-postfix/#comments</comments>
		<pubDate>Sun, 29 Mar 2009 21:41:30 +0000</pubDate>
		<dc:creator>johker</dc:creator>
				<category><![CDATA[Howto]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[110]]></category>
		<category><![CDATA[143]]></category>
		<category><![CDATA[2000]]></category>
		<category><![CDATA[993]]></category>
		<category><![CDATA[995]]></category>
		<category><![CDATA[abuse.net]]></category>
		<category><![CDATA[anti-stasi]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[create role]]></category>
		<category><![CDATA[create user]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[deliver]]></category>
		<category><![CDATA[dovecot]]></category>
		<category><![CDATA[dovecot postgres integration]]></category>
		<category><![CDATA[dovecot-deliver.log]]></category>
		<category><![CDATA[dovecot-imapd]]></category>
		<category><![CDATA[dovecot-pop3d]]></category>
		<category><![CDATA[imap]]></category>
		<category><![CDATA[imaps]]></category>
		<category><![CDATA[lda]]></category>
		<category><![CDATA[mail server]]></category>
		<category><![CDATA[maildir]]></category>
		<category><![CDATA[main.cf]]></category>
		<category><![CDATA[managesieve]]></category>
		<category><![CDATA[master.cf]]></category>
		<category><![CDATA[mda]]></category>
		<category><![CDATA[microsoft sucks]]></category>
		<category><![CDATA[mta]]></category>
		<category><![CDATA[mx_access]]></category>
		<category><![CDATA[outlook]]></category>
		<category><![CDATA[pcre]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[pop3]]></category>
		<category><![CDATA[pop3s]]></category>
		<category><![CDATA[postfix]]></category>
		<category><![CDATA[postfixadmin]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[quota]]></category>
		<category><![CDATA[recipient_checks]]></category>
		<category><![CDATA[relay_domains]]></category>
		<category><![CDATA[restrictions]]></category>
		<category><![CDATA[sasl]]></category>
		<category><![CDATA[sieve]]></category>
		<category><![CDATA[smtp]]></category>
		<category><![CDATA[smtps]]></category>
		<category><![CDATA[sql queries]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[test]]></category>
		<category><![CDATA[tls]]></category>
		<category><![CDATA[virtual]]></category>
		<category><![CDATA[virtual hosting]]></category>
		<category><![CDATA[virtual_alias_maps]]></category>
		<category><![CDATA[virtual_mailbox_domains]]></category>
		<category><![CDATA[virtual_mailbox_maps]]></category>
		<category><![CDATA[virtual_transport]]></category>
		<category><![CDATA[webinterface]]></category>
		<category><![CDATA[workarounds]]></category>

		<guid isPermaLink="false">http://johker.ibutho.de/?p=165</guid>
		<description><![CDATA[Hier wird erklärt wie man postfix mit postgreSQL-Backend installiert, dovecot inkl. sieve konfiguriert, sowie postfixadmin einrichtet, um postfix bequem über ein Webinterface verwalten zu können.
Datenbank anlegen
Als Erstes legen wir einen Datenbankbenutzer inkl. Datenbank für postfix an:

su - postgres
psql template1
CREATE USER postfix WITH PASSWORD 'password';
CREATE DATABASE postfix WITH OWNER postfix ENCODING 'UNICODE';
\q

Verzeichnis anlegen
Später werden alle Mailboxen [...]]]></description>
			<content:encoded><![CDATA[<p>Hier wird erklärt wie man <em>postfix</em> mit postgreSQL-Backend installiert, <em>dovecot</em> inkl. <em>sieve</em> konfiguriert, sowie <em>postfixadmin</em> einrichtet, um <em>postfix</em> bequem über ein Webinterface verwalten zu können.</p>
<h1>Datenbank anlegen</h1>
<p>Als Erstes legen wir einen Datenbankbenutzer inkl. Datenbank für <em>postfix</em> an:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">su</span> - postgres
psql template1
CREATE USER postfix WITH PASSWORD <span style="color: #ff0000;">'password'</span>;
CREATE DATABASE postfix WITH OWNER postfix ENCODING <span style="color: #ff0000;">'UNICODE'</span>;
\q</pre></div></div>

<h1>Verzeichnis anlegen</h1>
<p>Später werden alle Mailboxen unter "<em>/var/vmail/DOMAIN/BENUTZERNAME/maildir/</em>" liegen, deshalb erstellen wir nun den Ordner "<em>/var/vmail</em>" und vergeben entsprechende Rechte. Die Einsortierung nach "<em>/var/vmail/DOMAIN/BENUTZERNAME/maildir/</em>" geschieht später über SQL-Queries automatisch.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">useradd <span style="color: #660033;">-r</span> <span style="color: #660033;">-u</span> <span style="color: #000000;">150</span> <span style="color: #660033;">-g</span> mail <span style="color: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>vmail <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>nologin <span style="color: #660033;">-c</span> <span style="color: #ff0000;">'Virtual mailbox'</span> vmail
<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>vmail
<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">770</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>vmail<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">chown</span> vmail:mail <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>vmail<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<h1>postfixadmin</h1>
<p><em>postfixadmin</em> installieren wir direkt aus deren <em>svn</em>-Repository, um mit der aktuellste Version zu arbeiten. Sollte es zu Problemen kommen, kann man über <a href="http://postfixadmin.sourceforge.net/" target="_blank">http://postfixadmin.sourceforge.net/</a> die neueste stabile Version herunterladen.</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>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">svn</span> <span style="color: #c20cb9; font-weight: bold;">co</span> https:<span style="color: #000000; font-weight: bold;">//</span>postfixadmin.svn.sourceforge.net<span style="color: #000000; font-weight: bold;">/</span>svnroot<span style="color: #000000; font-weight: bold;">/</span>postfixadmin<span style="color: #000000; font-weight: bold;">/</span>trunk postfixadmin-svn
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> postfixadmin-svn postfixadmin</pre></div></div>

<p>Danach passt man die Konfigurationsdatei "<em>/var/www/postfixadmin/config.inc.php</em>" an seine Wünsche und Anforderungen an. Nach Ausführen des "setup.php"-Skripts im Browser (und anschließendem Löschen/Umbenennen) ist <em>postfixadmin</em> einsatzbereit.</p>
<h1>postfix</h1>
<p><em>postfix</em> installieren:</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> postfix postfix-pgsql postfix-pcre</pre></div></div>

<p>Während der Installation von <em>postfix</em> wird man gefragt, wie man <em>postfix</em> konfigurieren will, dort wählt man "<strong>Internet Site</strong>" aus (wobei dies später irrelevant ist, da wir die Konfiguration komplett selbst schreiben).</p>
<h2>Datenbankverbindung konfigurieren</h2>
<p>Damit <em>postfix</em> mit den Accounts, die in <em>postfixadmin</em> angelegt werden zusammenarbeitet, müssen wir verschiedene SQL-Queries anlegen:</p>
<p><em>relay-domains.cf</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user            = postfix
password        = xxxxxxx
dbname          = postfix
hosts           = localhost
query = SELECT domain FROM domain WHERE domain = <span style="color: #ff0000;">'%s'</span> AND backupmx = <span style="color: #c20cb9; font-weight: bold;">true</span></pre></div></div>

<p><em>virtual-alias-maps.cf</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user             = postfix
password         = xxxxxxxx
dbname           = postfix
hosts            = localhost
query = SELECT goto FROM <span style="color: #7a0874; font-weight: bold;">alias</span> WHERE <span style="color: #007800;">address</span>=<span style="color: #ff0000;">'%s'</span> AND active = <span style="color: #c20cb9; font-weight: bold;">true</span></pre></div></div>

<p><em>virtual-domain-maps.cf</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user             = postfix
password         = xxxxxxxx
dbname           = postfix
hosts            = localhost
query = SELECT domain FROM domain WHERE <span style="color: #007800;">domain</span>=<span style="color: #ff0000;">'%s'</span> AND backupmx = <span style="color: #c20cb9; font-weight: bold;">false</span> AND active = <span style="color: #c20cb9; font-weight: bold;">true</span></pre></div></div>

<p><em>virtual-mailbox-limit-maps.cf</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user             = postfix
password         = xxxxxxxx
dbname           = postfix
hosts            = localhost
query = SELECT quota FROM mailbox WHERE username = <span style="color: #ff0000;">'%s'</span> AND active = <span style="color: #c20cb9; font-weight: bold;">true</span></pre></div></div>

<p><em>virtual-mailbox-maps.cf</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user             = postfix
password         = xxxxxxxx
dbname           = postfix
hosts            = localhost
query = SELECT maildir <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #ff0000;">'maildir'</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #ff0000;">'/'</span> FROM mailbox WHERE <span style="color: #007800;">username</span>=<span style="color: #ff0000;">'%s'</span> AND active = <span style="color: #c20cb9; font-weight: bold;">true</span></pre></div></div>

<h2>recipient checks</h2>
<p>Mit <em>recipient checks</em> kann man E-Mailadressen anhand von regulären Ausdrücken prüfen und dadurch Mails entweder annehmen oder ablehnen. Hier werden invalide E-Mailadressen, bzw. welche mit "seltsamer" Syntax abgewiesen und E-Mails an postmaster, hostmaster, webmaster und abuse immer angenommen.</p>
<p><em>/etc/postfix/recipient_checks.pcre</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>^\<span style="color: #000000; font-weight: bold;">@/</span>             <span style="color: #000000;">550</span> Invalid address format.
<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000; font-weight: bold;">!%</span>\<span style="color: #000000; font-weight: bold;">@</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>.<span style="color: #000000; font-weight: bold;">*</span>\<span style="color: #000000; font-weight: bold;">@/</span>      <span style="color: #000000;">550</span> This server disallows weird address syntax.
<span style="color: #000000; font-weight: bold;">/</span>^postmaster\<span style="color: #000000; font-weight: bold;">@/</span>   OK
<span style="color: #000000; font-weight: bold;">/</span>^hostmaster\<span style="color: #000000; font-weight: bold;">@/</span>   OK
<span style="color: #000000; font-weight: bold;">/</span>^webmaster\<span style="color: #000000; font-weight: bold;">@/</span>    OK
<span style="color: #000000; font-weight: bold;">/</span>^abuse\<span style="color: #000000; font-weight: bold;">@/</span>        OK</pre></div></div>

<h2>mx access</h2>
<p>Über diese Datei werden E-Mails von Gegenstellen aus privaten IP-Blöcken, bzw. von Broadcast- und Multicast-Netzen von vorneherein abgewiesen, da diese im Internet prinzipiell nicht geroutet werden und es sich dabei mit extrem hoher Wahrscheinlichkeit um Spam handelt.</p>
<p><em>/etc/postfix/mx_access</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">0.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8</span>         REJECT Domain MX <span style="color: #000000; font-weight: bold;">in</span> broadcast network
10.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8</span>        REJECT Domain MX <span style="color: #000000; font-weight: bold;">in</span> RFC <span style="color: #000000;">1918</span> private network
127.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8</span>       REJECT Domain MX <span style="color: #000000; font-weight: bold;">in</span> loopback network
169.254.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">16</span>    REJECT Domain MX <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #c20cb9; font-weight: bold;">link</span> <span style="color: #7a0874; font-weight: bold;">local</span> network
172.16.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">12</span>     REJECT Domain MX <span style="color: #000000; font-weight: bold;">in</span> RFC <span style="color: #000000;">1918</span> private network
192.0.2.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">24</span>      REJECT Domain MX <span style="color: #000000; font-weight: bold;">in</span> TEST-NET network
192.168.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">16</span>    REJECT Domain MX <span style="color: #000000; font-weight: bold;">in</span> RFC <span style="color: #000000;">1918</span> private network
224.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">4</span>       REJECT Domain MX <span style="color: #000000; font-weight: bold;">in</span> class D multicast network
240.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">5</span>       REJECT Domain MX <span style="color: #000000; font-weight: bold;">in</span> class E reserved network
248.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">5</span>       REJECT Domain MX <span style="color: #000000; font-weight: bold;">in</span> reserved network</pre></div></div>

<p>Nun muss daraus noch eine <em>postfix-lookup table</em> erstellt werden:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">postmap <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>mx_access</pre></div></div>

<h2>main.cf</h2>
<p>Nun müssen wir noch <em>postfix</em> konfigurieren und alle Teilkonfigurationen, die wir gerade erstellt haben zusammenfügen. Dies geschieht über die Datei "<em>/etc/postfix/main.cf</em>":</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># -------------------- GENERAL PART START --------------------</span>
allow_percent_hack = no
biff = no
disable_vrfy_command = <span style="color: #c20cb9; font-weight: bold;">yes</span>
&nbsp;
mydestination = <span style="color: #007800;">$myhostname</span>, <span style="color: #007800;">$mydomain</span>, localhost
mydomain = domain.tld
myhostname = mail.domain.tld
mynetworks_style = host
myorigin = <span style="color: #007800;">$mydomain</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#home_mailbox = Maildir/</span>
<span style="color: #666666; font-style: italic;">#mailbox_size_limit = 2147483648</span>
<span style="color: #666666; font-style: italic;">#message_size_limit = 209715200</span>
local_transport = dovecot
masquerade_exceptions = root
recipient_delimiter = +
<span style="color: #666666; font-style: italic;"># -------------------- GENERAL PART END --------------------</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># -------------------- VIRTUAL PART START --------------------</span>
virtual_mailbox_base = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>vmail
relay_domains = proxy:pgsql:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>relay-domain-maps.cf
virtual_mailbox_maps = proxy:pgsql:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>virtual-mailbox-maps.cf
virtual_mailbox_domains = proxy:pgsql:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>virtual-domain-maps.cf
virtual_alias_maps = proxy:pgsql:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>virtual-alias-maps.cf
virtual_minimum_uid = <span style="color: #000000;">150</span>
virtual_uid_maps = static:<span style="color: #000000;">150</span>
virtual_gid_maps = static:<span style="color: #000000;">8</span>
virtual_transport = dovecot
dovecot_destination_recipient_limit = <span style="color: #000000;">1</span>
unknown_local_recipient_reject_code = <span style="color: #000000;">550</span>
<span style="color: #666666; font-style: italic;"># -------------------- VIRTUAL PART END --------------------</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># -------------------- RESTRICTIONS PART START --------------------</span>
smtpd_delay_reject = <span style="color: #c20cb9; font-weight: bold;">yes</span>
smtpd_helo_required = <span style="color: #c20cb9; font-weight: bold;">yes</span>
&nbsp;
smtpd_client_restrictions =
  permit_mynetworks,
  permit_sasl_authenticated,
  reject_unknown_reverse_client_hostname,
  permit
smtpd_data_restrictions =
  permit_mynetworks,
  permit_sasl_authenticated,
  reject_unauth_pipelining,
  permit
smtpd_helo_restrictions =
  permit_mynetworks,
  permit_sasl_authenticated,
  reject_invalid_helo_hostname,
  reject_non_fqdn_helo_hostname,
  permit
smtpd_recipient_restrictions =
  permit_mynetworks,
  permit_sasl_authenticated,
  reject_non_fqdn_recipient,
  reject_unknown_recipient_domain,
  check_recipient_mx_access cidr:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>mx_access,
  reject_unauth_destination,
  check_recipient_access pcre:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>recipient_checks.pcre,
<span style="color: #666666; font-style: italic;">###  check_policy_service inet:127.0.0.1:12525,</span>
  permit
smtpd_sender_restrictions =
  permit_mynetworks,
  permit_sasl_authenticated,
  reject_non_fqdn_sender,
  reject_unknown_sender_domain,
  permit
<span style="color: #666666; font-style: italic;"># -------------------- RESTRICTIONS PART END --------------------</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># -------------------- SASL PART START --------------------</span>
broken_sasl_auth_clients = <span style="color: #c20cb9; font-weight: bold;">yes</span>
smtpd_sasl_auth_enable = <span style="color: #c20cb9; font-weight: bold;">yes</span>
smtpd_sasl2_auth_enable = <span style="color: #c20cb9; font-weight: bold;">yes</span>
smtpd_sasl_local_domain = 
smtpd_sasl_type = dovecot
smtpd_sasl_path = private<span style="color: #000000; font-weight: bold;">/</span>auth
<span style="color: #666666; font-style: italic;"># -------------------- SASL PART END --------------------</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># -------------------- TLS PART START --------------------</span>
smtpd_use_tls = <span style="color: #c20cb9; font-weight: bold;">yes</span>
smtpd_tls_security_level = may
<span style="color: #666666; font-style: italic;">#smtpd_tls_auth_only = yes</span>
smtpd_tls_CAfile = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>ssl<span style="color: #000000; font-weight: bold;">/</span>demoCA<span style="color: #000000; font-weight: bold;">/</span>cacert.pem
smtpd_tls_cert_file = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>ssl<span style="color: #000000; font-weight: bold;">/</span>server-crt.pem
smtpd_tls_dh1024_param_file = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>ssl<span style="color: #000000; font-weight: bold;">/</span>dh_1024.pem
smtpd_tls_dh512_param_file = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>ssl<span style="color: #000000; font-weight: bold;">/</span>dh_512.pem
smtpd_tls_key_file = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>ssl<span style="color: #000000; font-weight: bold;">/</span>server-key.pem
smtpd_tls_session_cache_database = btree:<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>postfix<span style="color: #000000; font-weight: bold;">/</span>smtpd_tls_session_cache
<span style="color: #666666; font-style: italic;"># -------------------- TLS PART END --------------------</span></pre></div></div>

<h2>master.cf</h2>
<p>Ans Ende der "<em>/etc/postfix/master.cf</em>" anhängen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Dovecot LDA</span>
dovecot unix - n n - - pipe
<span style="color: #007800;">flags</span>=DRhu <span style="color: #007800;">user</span>=vmail:mail <span style="color: #007800;">argv</span>=<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>dovecot<span style="color: #000000; font-weight: bold;">/</span>deliver <span style="color: #660033;">-d</span> <span style="color: #800000;">${recipient}</span></pre></div></div>

<p>Will man auch <em>smtps</em> (Port 465) zulassen, so entfernt man die Raute-Zeichen vor den untenstehenden Zeilen, damit sie wie folgt aussehen (die Leerzeichen vor der zweiten Zeile sind essentiell):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">smtps     inet  n       -       -       -       -       smtpd
  <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_tls_wrappermode</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span></pre></div></div>

<p><em>smpts</em> kann nützlich sein, wenn Port 25 aus irgend einem Grund gesperrt sein sollte, denn es operiert auf Port 465, welcher seltener gesperrt ist (zumindest in Studentenwohnheimen und Universitäten), zusätzlich bietet es einen höheren Schutz als plaintext-smtp (doch einen geringeren als smtp+tls).</p>
<h1>dovecot</h1>
<p>Nun folgt die Konfiguration des dovecot E-Mail-Servers. Zunächst wird dovecot über aptitude:</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> dovecot-imapd dovecot-pop3d</pre></div></div>

<p>Jetzt wird dovecot noch konfiguriert:</p>
<p><em>/etc/dovecot/dovecot.conf</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">## Dovecot configuration file</span>
&nbsp;
base_dir = <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>dovecot<span style="color: #000000; font-weight: bold;">/</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># imap imaps pop3 pop3s (use imaps and pop3s if configured for SSL)</span>
protocols = imaps imap pop3s pop3 managesieve
&nbsp;
<span style="color: #666666; font-style: italic;"># Uncomment the ssl_listen statements and comment out listen if using SSL</span>
protocol imap <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  listen = <span style="color: #000000; font-weight: bold;">*</span>:<span style="color: #000000;">143</span>
  ssl_listen = <span style="color: #000000; font-weight: bold;">*</span>:<span style="color: #000000;">993</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
protocol pop3 <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  listen = <span style="color: #000000; font-weight: bold;">*</span>:<span style="color: #000000;">110</span>
  ssl_listen = <span style="color: #000000; font-weight: bold;">*</span>:<span style="color: #000000;">995</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
protocol managesieve <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  listen = <span style="color: #000000; font-weight: bold;">*</span>:<span style="color: #000000;">2000</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
log_timestamp = “<span style="color: #000000; font-weight: bold;">%</span>Y-<span style="color: #000000; font-weight: bold;">%</span>m-<span style="color: #000000; font-weight: bold;">%</span>d <span style="color: #000000; font-weight: bold;">%</span>H:<span style="color: #000000; font-weight: bold;">%</span>M:<span style="color: #000000; font-weight: bold;">%</span>S ”
syslog_facility = mail
&nbsp;
<span style="color: #666666; font-style: italic;"># Where the mailboxes are located</span>
mail_location = maildir:<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>vmail<span style="color: #000000; font-weight: bold;">/%</span>d<span style="color: #000000; font-weight: bold;">/%</span>n<span style="color: #000000; font-weight: bold;">/</span>maildir
mail_access_groups = vmail
mail_debug = <span style="color: #c20cb9; font-weight: bold;">yes</span>
first_valid_uid = <span style="color: #000000;">150</span>
last_valid_uid = <span style="color: #000000;">150</span>
maildir_copy_with_hardlinks = <span style="color: #c20cb9; font-weight: bold;">yes</span>
&nbsp;
protocol imap <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  login_executable = <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>dovecot<span style="color: #000000; font-weight: bold;">/</span>imap-login
  mail_executable = <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>dovecot<span style="color: #000000; font-weight: bold;">/</span>imap
  imap_max_line_length = <span style="color: #000000;">65536</span>
  mail_plugins = quota imap_quota
  imap_client_workarounds = outlook-idle delay-newmail
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
protocol pop3 <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  login_executable = <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>dovecot<span style="color: #000000; font-weight: bold;">/</span>pop3-login
  mail_executable = <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>dovecot<span style="color: #000000; font-weight: bold;">/</span>pop3
  pop3_uidl_format = <span style="color: #000000; font-weight: bold;">%</span>08Xu<span style="color: #000000; font-weight: bold;">%</span>08Xv
  mail_plugins = quota
  pop3_client_workarounds = outlook-no-nuls oe-ns-eoh
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
protocol lda <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  postmaster_address = postmaster<span style="color: #000000; font-weight: bold;">@</span>ibutho.de
  sendmail_path = <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><span style="color: #c20cb9; font-weight: bold;">sendmail</span>
  auth_socket_path = <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>dovecot<span style="color: #000000; font-weight: bold;">/</span>auth-master
  mail_plugins = quota cmusieve
  sieve_global_path = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>vmail<span style="color: #000000; font-weight: bold;">/</span>default.sieve
  log_path = <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>dovecot-deliver.log
  info_log_path = <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>dovecot-deliver.log
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
protocol managesieve <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  sieve = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>vmail<span style="color: #000000; font-weight: bold;">/%</span>d<span style="color: #000000; font-weight: bold;">/%</span>n<span style="color: #000000; font-weight: bold;">/</span>dovecot.sieve
  sieve_storage = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>vmail<span style="color: #000000; font-weight: bold;">/%</span>d<span style="color: #000000; font-weight: bold;">/%</span>n<span style="color: #000000; font-weight: bold;">/</span>sieve
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
auth_verbose = no
auth_debug = <span style="color: #c20cb9; font-weight: bold;">yes</span>
<span style="color: #666666; font-style: italic;">#auth_debug_passwords = yes</span>
&nbsp;
auth default <span style="color: #7a0874; font-weight: bold;">&#123;</span>
 mechanisms = plain <span style="color: #c20cb9; font-weight: bold;">login</span>
&nbsp;
 passdb sql <span style="color: #7a0874; font-weight: bold;">&#123;</span>
   args = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>dovecot-sql.conf
 <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
 userdb sql <span style="color: #7a0874; font-weight: bold;">&#123;</span>
   args = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>dovecot-sql.conf
 <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
 userdb prefetch <span style="color: #7a0874; font-weight: bold;">&#123;</span>
 <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
 user = nobody
&nbsp;
 socket listen <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  master <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    path = <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>dovecot<span style="color: #000000; font-weight: bold;">/</span>auth-master
    mode = 0660
    user = vmail
    group = mail
  <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
  client <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    path = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>spool<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>private<span style="color: #000000; font-weight: bold;">/</span>auth
    mode = 0660
    user = postfix
    group = postfix
  <span style="color: #7a0874; font-weight: bold;">&#125;</span>
 <span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
dict <span style="color: #7a0874; font-weight: bold;">&#123;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
plugin <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  acl = vfile:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>acls
  sieve = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>vmail<span style="color: #000000; font-weight: bold;">/%</span>d<span style="color: #000000; font-weight: bold;">/%</span>n<span style="color: #000000; font-weight: bold;">/</span>dovecot.sieve
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Uncomment these if using SSL</span>
ssl_cert_file = <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>certs<span style="color: #000000; font-weight: bold;">/</span>ibutho_server.pem
ssl_key_file = <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>ibutho_privatekey.pem
ssl_ca_file = <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>certs<span style="color: #000000; font-weight: bold;">/</span>root.pem
ssl_parameters_regenerate = <span style="color: #000000;">168</span>
verbose_ssl = no
<span style="color: #666666; font-style: italic;"># If you want client certificates, use these lines</span>
<span style="color: #666666; font-style: italic;"># ssl_verify_client_cert = yes</span>
<span style="color: #666666; font-style: italic;"># ssl_require_client_cert = yes</span>
<span style="color: #666666; font-style: italic;"># ssl_username_from_cert = yes</span></pre></div></div>

<p>Damit das logging nach "<em>/var/log/dovecot-deliver.log</em>" funktioniert, muss die Datei mit entsprechenden Rechten ausgestattet sein:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">touch</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>dovecot-deliver.log
<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">640</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>dovecot-deliver.log
<span style="color: #c20cb9; font-weight: bold;">chown</span> vmail:mail <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>dovecot-deliver.log</pre></div></div>

<p><em>/etc/dovecot/dovecot-sql.conf</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">driver = pgsql
connect = <span style="color: #007800;">host</span>=localhost <span style="color: #007800;">dbname</span>=postfix <span style="color: #007800;">user</span>=postfix <span style="color: #007800;">password</span>=xxxxxxxx
default_pass_scheme = MD5
&nbsp;
user_query = SELECT <span style="color: #ff0000;">'/var/vmail/'</span> <span style="color: #000000; font-weight: bold;">||</span> maildir AS home, <span style="color: #ff0000;">'maildir:/var/vmail/'</span> <span style="color: #000000; font-weight: bold;">||</span> maildir <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #ff0000;">'maildir'</span> AS mail, <span style="color: #000000;">150</span> AS uid, <span style="color: #000000;">8</span> AS gid, <span style="color: #ff0000;">'maildir:storage='</span> <span style="color: #000000; font-weight: bold;">||</span> quota AS quota FROM mailbox WHERE local_part = split_part<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">'%n'</span>, <span style="color: #ff0000;">'+'</span>, <span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> AND domain = <span style="color: #ff0000;">'%d'</span>  AND active = <span style="color: #c20cb9; font-weight: bold;">true</span>
&nbsp;
password_query = SELECT username AS user, password, <span style="color: #ff0000;">'/var/vmail/'</span> <span style="color: #000000; font-weight: bold;">||</span> maildir AS userdb_home, <span style="color: #ff0000;">'maildir:/var/vmail/'</span> <span style="color: #000000; font-weight: bold;">||</span> maildir <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #ff0000;">'maildir'</span> AS userdb_mail, <span style="color: #000000;">150</span> <span style="color: #c20cb9; font-weight: bold;">as</span> userdb_uid, <span style="color: #000000;">8</span> <span style="color: #c20cb9; font-weight: bold;">as</span> userdb_gid FROM mailbox WHERE username = <span style="color: #ff0000;">'%u'</span> AND active = <span style="color: #c20cb9; font-weight: bold;">true</span></pre></div></div>

<h1>Testen der Konfiguration</h1>
<p>Zuerst kann man serverseitig mittels "<code>netstat -tulpen</code>" testen, ob der Server auf allen beabsichtigten Ports lauscht (110, 143, 993, 995, 2000). Danach kann man mittels "<code>telnet SERVER_IP 143</code>", bzw. "<code>telnet SERVER_IP 110</code>" testen, ob man eine Verbindung bekommt. Ist dies der Fall, bietet es sich an auszuprobieren, ob man mit einem Mailprogramm auf das Postfach zugreifen kann (es muss natürlich eins in <em>postfixadmin</em> angelegt sein), bzw. ob man auch Mails empfangen und versenden kann.<br />
Ein weiterer wichtiger Test, den man durchführen sollte, ist, ob der Mailserver als "open relay" missbraucht werden kann (kurz und knapp heißt das, ob der Server möglicherweise eine "Spam-Schleuder" ist). Dies kann man u.a. hier testen: <a href="http://www.abuse.net/relay.html" target="_blank">http://www.abuse.net/relay.html</a>. Sollten alle Tests Erfolg haben, hat man einen funktionsfähigen Mailserver.</p>
<p>Quellen:<br />
postfixadmin/DOCUMENTS/POSTFIX_CONF.txt</p>
<p>http://blog.schalanda.name/archives/178-EUserv-vServer-Active-Installation-des-Mailsystems.html</p>
<p>http://codepoets.co.uk/postfixadmin-postgresql-courier-squirrelmail-debian-etch-howto-tutorial</p>
<p>http://wiki.rootforum.de/mailserver/postfix</p>
<p>http://wiki.rootforum.de/mailserver/postfix/postfix-admin</p>
<p>http://forum.rootforum.de/viewtopic.php?f=111&#038;t=46643</p>
<p>http://www.postfix.org/postconf.5.html</p>
<p>http://wiki.dovecot.org/MainConfig</p>
<p>http://wiki.dovecot.org/ManageSieve</p>
<p>http://wiki.dovecot.org/LDA/Sieve</p>
<p>http://wiki.dovecot.org/HowTo/DovecotLDAPostfixAdminMySQL</p>
]]></content:encoded>
			<wfw:commentRss>http://johker.ibutho.de/2009/03/29/der-neue-server-teil-5-postfix/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>ASCII Star Wars</title>
		<link>http://johker.ibutho.de/2009/03/29/ascii-star-wars/</link>
		<comments>http://johker.ibutho.de/2009/03/29/ascii-star-wars/#comments</comments>
		<pubDate>Sun, 29 Mar 2009 16:03:01 +0000</pubDate>
		<dc:creator>johker</dc:creator>
				<category><![CDATA[Howto]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[Spaß]]></category>
		<category><![CDATA[ascii]]></category>
		<category><![CDATA[console]]></category>
		<category><![CDATA[star wars]]></category>
		<category><![CDATA[telnet]]></category>

		<guid isPermaLink="false">http://johker.ibutho.de/?p=186</guid>
		<description><![CDATA[Heute mal ein Beitrag in twitter-Manier (extra für isnochys):

telnet towel.blinkenlights.nl

Auf der Konsole ausführen und Spaß haben.
]]></description>
			<content:encoded><![CDATA[<p>Heute mal ein Beitrag in twitter-Manier (extra für isnochys):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">telnet towel.blinkenlights.nl</pre></div></div>

<p>Auf der Konsole ausführen und Spaß haben.</p>
]]></content:encoded>
			<wfw:commentRss>http://johker.ibutho.de/2009/03/29/ascii-star-wars/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Der neue Server: Teil 4 apache</title>
		<link>http://johker.ibutho.de/2009/03/22/der-neue-server-teil-4-apache/</link>
		<comments>http://johker.ibutho.de/2009/03/22/der-neue-server-teil-4-apache/#comments</comments>
		<pubDate>Sun, 22 Mar 2009 19:42:40 +0000</pubDate>
		<dc:creator>johker</dc:creator>
				<category><![CDATA[Howto]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[a2enmod]]></category>
		<category><![CDATA[a2ensite]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[apache2]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[fastcgi]]></category>
		<category><![CDATA[fcgi]]></category>
		<category><![CDATA[fcgid]]></category>
		<category><![CDATA[gd]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[imagick]]></category>
		<category><![CDATA[imap]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[konfiguration]]></category>
		<category><![CDATA[mcrypt]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[PATH]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php5]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[profile]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rewrite]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[suexec]]></category>
		<category><![CDATA[suhosin]]></category>
		<category><![CDATA[vHost]]></category>
		<category><![CDATA[webserver]]></category>

		<guid isPermaLink="false">http://johker.ibutho.de/?p=149</guid>
		<description><![CDATA[Nachfolgend stelle ich vor, wie man apache2 inkl. php, sowie ruby über fastcgi installiert. php, bzw. ruby über fastcgi einzubinden bietet den Vorteil, dass die Skripts immer mit Benutzerrechten und nicht mit den rechten des Webserver ausgeführt werden. Zudem kann man so für jeden vHost eine eigene php.ini anlegen.
Installation und Konfiguration

aptitude install apache2 apache2-suexec libapache2-mod-fcgid [...]]]></description>
			<content:encoded><![CDATA[<p>Nachfolgend stelle ich vor, wie man <em>apache2</em> inkl. <em>php</em>, sowie <em>ruby</em> über fastcgi installiert. <em>php</em>, bzw. <em>ruby</em> über fastcgi einzubinden bietet den Vorteil, dass die Skripts immer mit Benutzerrechten und nicht mit den rechten des Webserver ausgeführt werden. Zudem kann man so für jeden vHost eine eigene <em>php.ini</em> anlegen.</p>
<h1>Installation und Konfiguration</h1>

<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> apache2 apache2-suexec libapache2-mod-fcgid php5-cgi</pre></div></div>

<p>Dieser Befehl installiert das <em>apache2</em>- und <em>php5</em>-Grundsystem. <em>Ruby</em> werden wir später installieren, sobald <em>apache</em> und <em>php</em> funktionieren.<br />
Nun aktivieren wir einige apache2-mods:</p>

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

<p>Nun legen wir noch einen Benutzer an, unter dem Skripts ausgeführt werden, die nicht direkt einem bestimmten Benutzer zugeordnet werden können (wichtig ist, dass dieser Benutzer eine GID>100 hat):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">adduser <span style="color: #660033;">--system</span> <span style="color: #660033;">--group</span> <span style="color: #660033;">--no-create-home</span> www-user</pre></div></div>

<p>Jetzt ist es an der Zeit die vHost-Strukturen unter "<em>/var/www/</em>" anzulegen. Für jeden vHost wird ein eigener Ordner erstellt und enthält mehrere Unterordner:</p>
<ul>
<li>conf - enthält die php.ini, sowie die fcgi-Konfiguration</li>
<li>docs - das Webroot</li>
<li>log - enthält die Log-Dateien</li>
<li>tmp - für temporäre Dateien</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><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>www<span style="color: #000000; font-weight: bold;">/</span>example.com
<span style="color: #7a0874; font-weight: bold;">cd</span> <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>
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> conf
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> docs
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> logs
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> tmp
<span style="color: #7a0874; font-weight: bold;">cd</span> <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>
<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">755</span> <span style="color: #660033;">-R</span> example.com</pre></div></div>

<p>Als Nächstes legen wir unter "<em>/var/www/example.com/conf</em>" einen Symlink auf "<em>/etc/php5/cgi/php.ini</em>" an:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><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>php5<span style="color: #000000; font-weight: bold;">/</span>cgi<span style="color: #000000; font-weight: bold;">/</span>php.ini <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>conf<span style="color: #000000; font-weight: bold;">/</span>php.ini</pre></div></div>

<p>Das hat den Vorteil, dass alle vHosts standardmäßig die gleiche <em>php.ini</em> benutzen, man diese aber sehr leicht austauschen kann, falls man bestimmte vHost-spezifische Anpassungen vornehmen muss.<br />
Dann legen wir noch einen fcgi-Starter an:</p>
<p><em>/var/www/example.com/conf/php-fcgi.conf</em>:</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>
<span style="color: #007800;">PHPRC</span>=<span style="color: #ff0000;">&quot;/var/www/example.com/conf&quot;</span>
<span style="color: #7a0874; font-weight: bold;">export</span> PHPRC
<span style="color: #666666; font-style: italic;">#PHP_FCGI_CHILDREN=3</span>
<span style="color: #666666; font-style: italic;">#export PHP_FCGI_CHILDREN</span>
<span style="color: #7a0874; font-weight: bold;">exec</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-cgi</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">755</span> <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>conf<span style="color: #000000; font-weight: bold;">/</span>php-fcgi.conf</pre></div></div>

<p>Wenn man nun einen neuen vHost erstellt, muss nur dieser komplette Ordner kopiert werden, die Zeile "PHPRC="/var/www/example.com/conf" angepasst werden, sowie das immutable-bit für die Datei <em>php-fcgi.conf</em>, bzw. <em>php.ini</em> gesetzt werden.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chattr</span> +i <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;">/&lt;</span>ORDNERNAME<span style="color: #000000; font-weight: bold;">&gt;/</span>conf<span style="color: #000000; font-weight: bold;">/</span>php-fcgi.conf
<span style="color: #c20cb9; font-weight: bold;">chattr</span> +i <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;">/&lt;</span>ORDNERNAME<span style="color: #000000; font-weight: bold;">&gt;/</span>conf<span style="color: #000000; font-weight: bold;">/</span>php.ini</pre></div></div>

<p>Jetzt muss nur noch eine vHost-Konfiguration für <em>apache</em> angelegt werden. Hierfür legen wir unter "<em>/etc/apache2/sites-available/example.com</em>" ein Template an, welches dann kopiert und angepasst werden kann:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;</span>VirtualHost <span style="color: #000000; font-weight: bold;">*</span>:<span style="color: #000000;">80</span><span style="color: #000000; font-weight: bold;">&gt;</span>
        SuExecUserGroup <span style="color: #7a0874; font-weight: bold;">&#123;</span>USER<span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>GROUP<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
        ServerName <span style="color: #7a0874; font-weight: bold;">&#123;</span>SRV_NAME<span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #666666; font-style: italic;">#       ServerAlias {SRV_ALIAS}</span>
        ServerAdmin <span style="color: #7a0874; font-weight: bold;">&#123;</span>SRV_ADMIN<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
        DocumentRoot <span style="color: #7a0874; font-weight: bold;">&#123;</span>DOC_ROOT<span style="color: #7a0874; font-weight: bold;">&#125;</span>
        AddHandler fcgid-script .php
        <span style="color: #000000; font-weight: bold;">&lt;</span>Directory <span style="color: #7a0874; font-weight: bold;">&#123;</span>DOC_ROOT<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
                FCGIWrapper <span style="color: #7a0874; font-weight: bold;">&#123;</span>CONF_ROOT<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">/</span>php-fcgi.conf .php
                Options +SymLinksIfOwnerMatch +MultiViews +ExecCGI <span style="color: #660033;">-Indexes</span>
                AllowOverride FileInfo
                Order allow,deny
                allow from all
        <span style="color: #000000; font-weight: bold;">&lt;/</span>Directory<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
        ErrorLog <span style="color: #7a0874; font-weight: bold;">&#123;</span>LOG_ROOT<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">/</span>error.log
        CustomLog <span style="color: #7a0874; font-weight: bold;">&#123;</span>LOG_ROOT<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">/</span>access.log combined
        LogLevel warn
        ServerSignature Off
<span style="color: #000000; font-weight: bold;">&lt;/</span>VirtualHost<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>Um den vHost zu aktivieren, muss man noch folgenden Befehl absetzen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">a2ensite <span style="color: #000000; font-weight: bold;">&lt;</span>VHOST_NAME<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>Danach noch die <em>apache</em>-Konfiguration neu einlesen und der vHost ist einsatzbereit.</p>
<p>Quellen:<br />
<a href="http://wiki.hetzner.de/index.php/Apache_PHP5_fcgi_und_SuExec" target="_blank">http://wiki.hetzner.de/index.php/Apache_PHP5_fcgi_und_SuExec</a></p>
<h1>php-Addons</h1>

<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> php5-gd php5-imagick php5-mcrypt php5-mysql php5-pgsql php5-imap php5-suhosin</pre></div></div>

<p><em>gd</em> und <em>imagick</em> sind hierbei Bibliotheken zur Bildmanipulation, <em>mcrypt</em> bietet Verschlüsselungsfunktionen, <em>mysql</em> und <em>pgsql</em> sind für den Datenbankzugriff, imap bietet Funktionen zur Interaktion mit einem IMAP-Server und suhosin ist eine Sicherheitserweiterung für php.</p>
<h1>ruby</h1>
<p>Nun folgt noch die Installation von <em>ruby</em> und <em>ruby on rails</em> - ebenfalls als fastcgi:</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> ruby rdoc irb rubygems libfcgi-ruby1.8 libmysql-ruby libpgsql-ruby rails libopenssl-ruby1.8</pre></div></div>

<p>Da fastcgi schon konfiguriert ist, funktioniert <em>ruby</em>, bzw. <em>RoR</em> ohne weitere Konfiguration.</p>
<h2>rails über gem installieren</h2>
<p>Alternativ kann man <em>rails</em> auch über <em>gem</em>, anstatt über <em>aptitude</em> installieren. Dazu führt man diesen Befehl aus:</p>

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

<p>Und ändert anschließend "<em>/etc/profile</em>" und nimmt "<em>/var/lib/gems/1.8/bin</em>" in <strong><code>$PATH</code></strong> mit auf (vor "<code>export PATH</code>" hinzufügen):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># add rails to path</span>
<span style="color: #007800;">PATH</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$PATH</span>:/var/lib/gems/1.8/bin&quot;</span></pre></div></div>

<p>Quellen:<br />
<a href="http://howtoforge.net/ruby_on_rails_debian_etch" target="_blank">http://howtoforge.net/ruby_on_rails_debian_etch</a></p>
]]></content:encoded>
			<wfw:commentRss>http://johker.ibutho.de/2009/03/22/der-neue-server-teil-4-apache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Der neue Server: Teil 3 svn, mysql, postgres</title>
		<link>http://johker.ibutho.de/2009/03/20/der-neue-server-teil-3-svn-mysql-postgres/</link>
		<comments>http://johker.ibutho.de/2009/03/20/der-neue-server-teil-3-svn-mysql-postgres/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 15:29:35 +0000</pubDate>
		<dc:creator>johker</dc:creator>
				<category><![CDATA[Howto]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[acid]]></category>
		<category><![CDATA[createuser]]></category>
		<category><![CDATA[dokumentation]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[konfiguration]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[mysql_secure_installation]]></category>
		<category><![CDATA[o'reilly]]></category>
		<category><![CDATA[pg_hba.conf]]></category>
		<category><![CDATA[phpMyAdmin]]></category>
		<category><![CDATA[phpPgAdmin]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[postgresql.conf]]></category>
		<category><![CDATA[root]]></category>
		<category><![CDATA[rootforum]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[services]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[svnadmin]]></category>
		<category><![CDATA[telnet]]></category>
		<category><![CDATA[xinetd]]></category>

		<guid isPermaLink="false">http://johker.ibutho.de/?p=141</guid>
		<description><![CDATA[Mit diesem Beitrag beginnt nun eine kleine Reihe, wie man verschiedene Serverdienste installiert und konfiguriert. Angefangen wird mit dem Versionskontrollsystem svn (auch unter dem Namen subversion bekannt) und zwei verschiedenen Datenbanksystemen: mysql und postgreSQL.
subversion
SVN wird über den Internet-Superserver xinetd betrieben und hört standardmäßig auf Port 3690. Die Repositories samt ihrer Konfigurationsdateien werden später unter "/var/svn" [...]]]></description>
			<content:encoded><![CDATA[<p>Mit diesem Beitrag beginnt nun eine kleine Reihe, wie man verschiedene Serverdienste installiert und konfiguriert. Angefangen wird mit dem Versionskontrollsystem <em>svn</em> (auch unter dem Namen <em>subversion</em> bekannt) und zwei verschiedenen Datenbanksystemen: <em>mysql</em> und <em>postgreSQL</em>.</p>
<h1>subversion</h1>
<p>SVN wird über den Internet-Superserver <em>xinetd</em> betrieben und hört standardmäßig auf Port 3690. Die Repositories samt ihrer Konfigurationsdateien werden später unter "<em>/var/svn</em>" liegen und der Server wird unter dem Benutzer "<em>svn</em>" laufen.</p>
<p>Zunächst installieren wir xinetd und svn:</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> xinetd subversion</pre></div></div>

<p>Danach erstellen wir den svn-Benutzer:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">adduser <span style="color: #660033;">--system</span> <span style="color: #660033;">--group</span> <span style="color: #660033;">--no-create-home</span> <span style="color: #c20cb9; font-weight: bold;">svn</span></pre></div></div>

<p>Jetzt registrieren wir Port 3690 für svn:</p>
<p><em>/etc/services</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Local services</span>
<span style="color: #c20cb9; font-weight: bold;">svn</span> <span style="color: #000000;">3690</span><span style="color: #000000; font-weight: bold;">/</span>tcp <span style="color: #666666; font-style: italic;"># subversion</span>
<span style="color: #c20cb9; font-weight: bold;">svn</span> <span style="color: #000000;">3690</span><span style="color: #000000; font-weight: bold;">/</span>udp <span style="color: #666666; font-style: italic;"># subversion</span></pre></div></div>

<p>... erstellen den Ordner "/var/svn":</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><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>svn<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #c20cb9; font-weight: bold;">svn</span>: <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>svn<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">755</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>svn<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>... und konfigurieren xinetd, damit er auf Port 3690 Verbindungen für <em>svn</em> entgegennimmt und sie an den <em>svnserve</em>-Server weitergibt:</p>
<p><em>/etc/xinetd.d/svn</em></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># default: on</span>
<span style="color: #666666; font-style: italic;"># description: Subversion server process</span>
service <span style="color: #c20cb9; font-weight: bold;">svn</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
    disable             = no
    socket_type         = stream
    protocol            = tcp
    user                = <span style="color: #c20cb9; font-weight: bold;">svn</span>
    <span style="color: #7a0874; font-weight: bold;">wait</span>                = no
    port                = <span style="color: #000000;">3690</span>
    server              = <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><span style="color: #c20cb9; font-weight: bold;">svnserve</span>
    server_args         = <span style="color: #660033;">-i</span> <span style="color: #660033;">-r</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>svn<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>Nun kann man mit dem <em>telnet</em>-Befehl von einem anderen Rechner aus testen, ob <em>svn</em> auf Port 3690 lauscht:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">telnet SERVER_IP <span style="color: #000000;">3690</span></pre></div></div>

<p>Die Ausgabe sollte dann so aussehn:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Trying SERVER_IP...
Connected to SERVER_IP.
Escape character is <span style="color: #ff0000;">'^]'</span>.
<span style="color: #7a0874; font-weight: bold;">&#40;</span> success <span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #000000;">2</span> <span style="color: #000000;">2</span> <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;">&#40;</span> edit-pipeline svndiff1 absent-entries commit-revprops depth log-revprops partial-replay <span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span> Connection closed by foreign host.</pre></div></div>

<p>Mittels des <em>svnadmin</em>-Tools kann man nun Repositories anlegen, verändern, löschen, ...</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">svnadmin</span> create <span style="color: #660033;">--fs-type</span> fsfs <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>svn<span style="color: #000000; font-weight: bold;">/</span>testRepo</pre></div></div>

<p>Was man mit <em>svn</em> alles anstellen kann, wird hier sehr ausführlich beschrieben: <a href="http://svnbook.red-bean.com/" target="_blank">http://svnbook.red-bean.com/</a>. Dieses Buch ist wohl das Standardwerk, wenn es um <em>svn</em> geht und ein weiterer Stern am O'Reilly-Himmel und das Tollste ist: die Online-Version kostet nicht einmal was.</p>
<h1>mysql</h1>
<p>Man mag von <em>mysql</em> halten, was man will, doch es ist (leider) das Standard-Datenbanksystem für Web-Anwendungen (ein paar Gedanken zu <em>mysql</em> kann man <a href="http://forum.rootforum.de/viewtopic.php?f=104&#038;t=50167" target="_blank">hier</a> finden). Der Vorteil von <em>mysql</em> ist, dass es sehr einfach in der Installation und Handhabung ist, die Nachteile.... naja, findets selbst heraus.</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> mysql-server</pre></div></div>

<p>Während der Installation wird man nach einem Passwort für den <em>mysql</em>-root Benutzer gefragt. Danach kann man ggf. noch die Konfiguration anpassen (liegt unter "<em>/etc/mysql/my.cnf</em>"). Ein gutes Beispiel für eine <em>mysql</em>-Konfiguration kann man hier finden: <a href="http://forum.rootforum.de/viewtopic.php?f=104&#038;t=36343" target="_blank">http://forum.rootforum.de/viewtopic.php?f=104&#038;t=36343</a>. Eine Anmerkung: wenn man die empfohlene Konfiguration auf <a href="http://forum.rootforum.de/" target="_blank">rootforum.de</a> benutzt und über phpMyAdmin auf die Datenbank zugreifen will, sollte man die Zeile "skip_show_database" auskommentieren, ansonsten sehen die Benutzer (root ausgenommen) ihre Datenbanken nicht.</p>
<p>Da wir nicht nur eine optimierte Installation, sondern auch eine sichere wollen, führen wir nun noch das "mysql_secure_installation"-Skript aus und beantworten alle Fragen, abgesehen von der über das <em>mysql</em>-root Passwort, mit der Standardantwort.</p>
<p>Quellen:</p>
<p><a href="http://forum.rootforum.de/viewtopic.php?f=104&#038;t=36343" target="_blank">http://forum.rootforum.de/viewtopic.php?f=104&#038;t=36343</a></p>
<h1>postgres</h1>
<p>Kommen wir zu einem richtigen Datenbanksystem: <em>postgres</em>. <em>postgres</em> ist ein freies, quelloffenes (open-source auf "Neudeutsch") Datenbanksystem, welches komplett ANSI-SQL92 konform ist (das kann manch kommerzielles Datenbanksystem nicht einmal von sich behaupten), unterstützt unter anderem ACID-Transaktionen und Stored Procedures und weitere fortgeschrittene Datenbank-Konzepte. Es erfreut sich einer immer größer werdenden Beliebtheit und löst <em>mysql</em> in vielen Gebieten ab. Dennoch will ich hier nicht zu viel Werbung machen. Jeder sollte sich selbst Gedanken über das Datenbanksystem machen, das er einsetzt und warum er es einsetzt. Doch wenn man ein Projekt hochziehen will, bei dem man auf fortschrittliche Datenbank-Konzepte zurückgreift, bleiben im open-source Umfeld nicht viele Lösungen übrig.<br />
Die Installation gestaltet sich ähnlich einfach wie bei <em>mysql</em>:</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> postgresql-<span style="color: #000000;">8.3</span></pre></div></div>

<p>Die Konfiguration gestaltet sich etwas anders als die von <em>mysql</em>. Sie ist im wesentlichen mehr an Oracle angelehnt. Über die Datei "pg_hba.conf" kann man Zugriffsrechte vergeben. Wenn man einen Benutzer anlegt, wird standardmäßig auch eine Datenbank mit dem selben Namen erstellt, autoincrement-Werte werden etwas anders definiert als bei <em>mysql</em>, des Weiteren heißen einige Datentypen geringfügig anders, doch die postgres-Dokumentation hilft hier weiter: <a href="http://www.postgresql.org/docs/current/static/" target="_blank">http://www.postgresql.org/docs/current/static/</a>.<br />
Beispielhaft hier noch Code, wie man einen Benutzer anlegen kann:</p>

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

<p>Danach wird man nach dem Passwort und der Benutzerrolle gefragt und man kann mit folgendem Code auf die postgres-Konsole zugreifen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">psql <span style="color: #660033;">-W</span> <span style="color: #000000; font-weight: bold;">&lt;</span>Tabellenname<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>In einem weiteren Teil gehe ich dann darauf ein, wie man phpMyAdmin und phpPgAdmin einrichtet.</p>
]]></content:encoded>
			<wfw:commentRss>http://johker.ibutho.de/2009/03/20/der-neue-server-teil-3-svn-mysql-postgres/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
