<?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&#039;s blog &#187; postgresql</title>
	<atom:link href="http://johker.ibutho.de/tag/postgresql/feed/" rel="self" type="application/rss+xml" />
	<link>http://johker.ibutho.de</link>
	<description>stories about me, my life and my trips</description>
	<lastBuildDate>Sun, 18 Dec 2011 11:53:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<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 &#8211; wie z.B. Evolution oder Thunderbird &#8211; arbeiten zu können, deshalb wird hier darauf eingegangen wie man einen Webmailer &#8211; in diesem Fall roundcube &#8211; inkl. postfixadmin-Integration und Sieve-Plugin installiert. &#8230; <a href="http://johker.ibutho.de/2009/04/04/der-neue-server-teil-7-roundcube/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Oft hat man nicht die Möglichkeit mit einen E-Mail Client &#8211; wie z.B. Evolution oder Thunderbird &#8211; arbeiten zu können, deshalb wird hier darauf eingegangen wie man einen Webmailer &#8211; in diesem Fall <em><a href="http://roundcube.net/" target="_blank">roundcube</a></em> &#8211; inkl. <em>postfixadmin</em>-Integration und Sieve-Plugin installiert.</p>
<h1>imapproxy</h1>
<p>Da http ein &#8220;stateless&#8221;-Protokoll ist, kann es &#8211; anders als IMAP-Clients &#8211; keine Verbindungen offen halten und stellt deshalb sehr viele unnötige &#8220;LOGIN&#8221;-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 &#8220;<em>/installer</em>&#8221; 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 (&#8220;<em>~/.muttrc</em>&#8220;):</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, &#8230;</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 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 - &#8230; <a href="http://johker.ibutho.de/2009/03/29/der-neue-server-teil-5-postfix/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></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 &#8220;<em>/var/vmail/DOMAIN/BENUTZERNAME/maildir/</em>&#8221; liegen, deshalb erstellen wir nun den Ordner &#8220;<em>/var/vmail</em>&#8221; und vergeben entsprechende Rechte. Die Einsortierung nach &#8220;<em>/var/vmail/DOMAIN/BENUTZERNAME/maildir/</em>&#8221; 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 &#8220;<em>/var/www/postfixadmin/config.inc.php</em>&#8221; an seine Wünsche und Anforderungen an. Nach Ausführen des &#8220;setup.php&#8221;-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 &#8220;<strong>Internet Site</strong>&#8221; 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 &#8220;seltsamer&#8221; 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 &#8220;<em>/etc/postfix/main.cf</em>&#8220;:</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 &#8220;<em>/etc/postfix/master.cf</em>&#8221; 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 &#8220;<em>/var/log/dovecot-deliver.log</em>&#8221; 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 &#8220;<code>netstat -tulpen</code>&#8221; testen, ob der Server auf allen beabsichtigten Ports lauscht (110, 143, 993, 995, 2000). Danach kann man mittels &#8220;<code>telnet SERVER_IP 143</code>&#8220;, bzw. &#8220;<code>telnet SERVER_IP 110</code>&#8221; 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 &#8220;open relay&#8221; missbraucht werden kann (kurz und knapp heißt das, ob der Server möglicherweise eine &#8220;Spam-Schleuder&#8221; 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>6</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 &#8230; <a href="http://johker.ibutho.de/2009/03/22/der-neue-server-teil-4-apache/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></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 &#8220;<em>/var/www/</em>&#8221; anzulegen. Für jeden vHost wird ein eigener Ordner erstellt und enthält mehrere Unterordner:</p>
<ul>
<li>conf &#8211; enthält die php.ini, sowie die fcgi-Konfiguration</li>
<li>docs &#8211; das Webroot</li>
<li>log &#8211; enthält die Log-Dateien</li>
<li>tmp &#8211; 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 &#8220;<em>/var/www/example.com/conf</em>&#8221; einen Symlink auf &#8220;<em>/etc/php5/cgi/php.ini</em>&#8221; 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 &#8220;PHPRC=&#8221;/var/www/example.com/conf&#8221; 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 &#8220;<em>/etc/apache2/sites-available/example.com</em>&#8221; 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> &#8211; 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 &#8220;<em>/etc/profile</em>&#8221; und nimmt &#8220;<em>/var/lib/gems/1.8/bin</em>&#8221; in <strong><code>$PATH</code></strong> mit auf (vor &#8220;<code>export PATH</code>&#8221; 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 &#8230; <a href="http://johker.ibutho.de/2009/03/20/der-neue-server-teil-3-svn-mysql-postgres/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></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 &#8220;<em>/var/svn</em>&#8221; liegen und der Server wird unter dem Benutzer &#8220;<em>svn</em>&#8221; 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>&#8230; erstellen den Ordner &#8220;/var/svn&#8221;:</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>&#8230; 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, &#8230;</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&#8217;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&#8230;. 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 &#8220;<em>/etc/mysql/my.cnf</em>&#8220;). 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 &#8220;skip_show_database&#8221; 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 &#8220;mysql_secure_installation&#8221;-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 &#8220;Neudeutsch&#8221;) 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 &#8220;pg_hba.conf&#8221; 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>

