<?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; installation</title>
	<atom:link href="http://johker.ibutho.de/tag/installation/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>fetchmail Integration in postfixadmin</title>
		<link>http://johker.ibutho.de/2009/04/07/fetchmail-integration-in-postfixadmin/</link>
		<comments>http://johker.ibutho.de/2009/04/07/fetchmail-integration-in-postfixadmin/#comments</comments>
		<pubDate>Tue, 07 Apr 2009 21:26:34 +0000</pubDate>
		<dc:creator>johker</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tipps und Tricks]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[cronjob]]></category>
		<category><![CDATA[crontab]]></category>
		<category><![CDATA[fetchmail]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[konfiguration]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[postfixadmin]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://johker.ibutho.de/?p=227</guid>
		<description><![CDATA[Viele Benutzer haben auch Mailboxen bei anderen Anbietern, z.B. bei gmx oder web.de. Damit diese Benutzer ihre E-Mails aggregieren können, wird fetchmail eingerichtet. fetchmail ist bereits in postfixadmin integriert, somit können fetchmail-Einträge über postfixadmin verwaltet werden (derzeit leider nur von Administratoren). Über das mitgelieferte fetchmail.pl-Skript werden die Daten aus der Datenbank ausgelesen, fetchmail aufgerufen, die [...]]]></description>
			<content:encoded><![CDATA[<p>Viele Benutzer haben auch Mailboxen bei anderen Anbietern, z.B. bei gmx oder web.de. Damit diese Benutzer ihre E-Mails aggregieren können, wird <em>fetchmail</em> eingerichtet. <em>fetchmail</em> ist bereits in <em>postfixadmin</em> integriert, somit können <em>fetchmail</em>-Einträge über <em>postfixadmin</em> verwaltet werden (derzeit leider nur von Administratoren). Über das mitgelieferte <em>fetchmail.pl</em>-Skript werden die Daten aus der Datenbank ausgelesen, <em>fetchmail</em> aufgerufen, die Mails durch <em>amavisd-new</em> überprüft und an die Mailboxen der Benutzer ausgeliefert. Das <em>perl</em>-Skript wurde etwas angepasst, damit es mit <em>postgres</em> interagieren kann. Des Weiteren wurden die Dateinamen etwas angepasst.</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> fetchmail
<span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> liblockfile-simple-perl</pre></div></div>

<p>Nötige Verzeichnisse für das Skript anlegen:</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>run<span style="color: #000000; font-weight: bold;">/</span>fetchmail
<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>run<span style="color: #000000; font-weight: bold;">/</span>fetchmail<span style="color: #000000; font-weight: bold;">/</span>fetchmail-all.lock</pre></div></div>

<p>Das Skript:</p>
<p><em>fetchmail.pl</em></p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> DBI<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> MIME<span style="color: #339933;">::</span><span style="color: #006600;">Base64</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;"># use Data::Dumper;</span>
<span style="color: #000000; font-weight: bold;">use</span> File<span style="color: #339933;">::</span><span style="color: #006600;">Temp</span> <span style="color: #009966; font-style: italic;">qw/ mkstemp /</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> Sys<span style="color: #339933;">::</span><span style="color: #006600;">Syslog</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;"># require liblockfile-simple-perl</span>
<span style="color: #000000; font-weight: bold;">use</span> LockFile<span style="color: #339933;">::</span><span style="color: #006600;">Simple</span> <span style="color: #000066;">qw</span><span style="color: #009900;">&#40;</span>lock trylock unlock<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
openlog<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;fetchmail-all&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;pid&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;mail&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> log_and_die <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">my</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$message</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">@_</span><span style="color: #339933;">;</span>
  syslog<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;err&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$message</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066;">die</span> <span style="color: #0000ff;">$message</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># read options and arguments</span>
&nbsp;
<span style="color: #0000ff;">$configfile</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;/etc/fetchmail/config&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #0000ff;">@ARGS1</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">@ARGV</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$_</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span> <span style="color: #0000ff;">@ARGS1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/^-/</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/^--config$/</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #0000ff;">$configfile</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span> <span style="color: #0000ff;">@ARGS1</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># postgres settings</span>
<span style="color: #0000ff;">$database</span><span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;postfix&quot;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$hostname</span><span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;127.0.0.1&quot;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$user</span><span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;postfix&quot;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$password</span><span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;XXXXXX&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #0000ff;">$run_dir</span><span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;/var/run/fetchmail&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># use specified config file</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>e <span style="color: #0000ff;">$configfile</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">do</span> <span style="color: #0000ff;">$configfile</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">$dsn</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;DBI:Pg:database=$database;host=$hostname&quot;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$lock_file</span><span style="color: #339933;">=</span><span style="color: #0000ff;">$run_dir</span> <span style="color: #339933;">.</span> <span style="color: #ff0000;">&quot;/fetchmail-all.lock&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #0000ff;">$lockmgr</span> <span style="color: #339933;">=</span> LockFile<span style="color: #339933;">::</span><span style="color: #006600;">Simple</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">make</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>autoclean <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span>max <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$lockmgr</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">lock</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$lock_file</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> log_and_die <span style="color: #ff0000;">&quot;can't lock ${lock_file}&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#postgres connect</span>
<span style="color: #0000ff;">$dbh</span> <span style="color: #339933;">=</span> DBI<span style="color: #339933;">-&gt;</span><span style="color: #006600;">connect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$dsn</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$user</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$password</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> log_and_die <span style="color: #ff0000;">&quot;cannot connect the database&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #0000ff;">$sql</span><span style="color: #339933;">=</span><span style="color: #cc0000; font-style: italic;">&lt;&lt;SQL;
SELECT id,mailbox,src_server,src_auth,src_user,src_password,src_folder,fetchall,keep,protocol,mda,extra_options,usessl 
FROM fetchmail
WHERE date_part('epoch',now())-date_part('epoch',date) &gt; poll_time*60
SQL</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">%config</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">map</span><span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$id</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$mailbox</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$src_server</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$src_auth</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$src_user</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$src_password</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$src_folder</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$fetchall</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$keep</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$protocol</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$mda</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$extra_options</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$usessl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">=@</span><span style="color: #0000ff;">$_</span><span style="color: #339933;">;</span>
&nbsp;
  syslog<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;info&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;fetch ${src_user}@${src_server} for ${mailbox}&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #0000ff;">$cmd</span><span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;user '${src_user}' there with password '&quot;</span><span style="color: #339933;">.</span>decode_base64<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$src_password</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;'&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #0000ff;">$cmd</span><span style="color: #339933;">.=</span><span style="color: #ff0000;">&quot; folder '${src_folder}'&quot;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$src_folder</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #0000ff;">$cmd</span><span style="color: #339933;">.=</span><span style="color: #ff0000;">&quot; mda &quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$mda</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$mda</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#       $cmd.=&quot; mda \&quot;/usr/local/libexec/dovecot/deliver -m ${mailbox}\&quot;&quot;;</span>
        <span style="color: #0000ff;">$cmd</span><span style="color: #339933;">.=</span><span style="color: #ff0000;">&quot; is '${mailbox}' here&quot;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #0000ff;">$cmd</span><span style="color: #339933;">.=</span><span style="color: #ff0000;">&quot; keep&quot;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$keep</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #0000ff;">$cmd</span><span style="color: #339933;">.=</span><span style="color: #ff0000;">&quot; fetchall&quot;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$fetchall</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #0000ff;">$cmd</span><span style="color: #339933;">.=</span><span style="color: #ff0000;">&quot; ssl&quot;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$usessl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #0000ff;">$cmd</span><span style="color: #339933;">.=</span><span style="color: #ff0000;">&quot; &quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$extra_options</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$extra_options</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #0000ff;">$text</span><span style="color: #339933;">=</span><span style="color: #cc0000; font-style: italic;">&lt;&lt;TXT;
set postmaster &quot;postmaster&quot;
set nobouncemail
set no spambounce
set properties &quot;&quot;
set syslog
&nbsp;
poll ${src_server} with proto ${protocol}
        $cmd
&nbsp;
TXT</span>
&nbsp;
  <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$file_handler</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$filename</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> mkstemp<span style="color: #009900;">&#40;</span> <span style="color: #ff0000;">&quot;/tmp/fetchmail-all-XXXXX&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">or</span> log_and_die <span style="color: #ff0000;">&quot;cannot open/create fetchmail temp file&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #000066;">print</span> <span style="color: #0000ff;">$file_handler</span> <span style="color: #0000ff;">$text</span><span style="color: #339933;">;</span>
  <span style="color: #000066;">close</span> <span style="color: #0000ff;">$file_handler</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #0000ff;">$ret</span><span style="color: #339933;">=</span><span style="color: #ff0000;">`/usr/bin/fetchmail -f $filename -i $run_dir/fetchmail.pid`</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000066;">unlink</span> <span style="color: #0000ff;">$filename</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #0000ff;">$sql</span><span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;UPDATE fetchmail SET returned_text=&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$dbh</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">quote</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$ret</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;, date=now() WHERE id=&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$id</span><span style="color: #339933;">;</span>
  <span style="color: #0000ff;">$dbh</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">do</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">@</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$dbh</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">selectall_arrayref</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #0000ff;">$lockmgr</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">unlock</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$lock_file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
closelog<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Damit das Skript regelmäßig ausgeführt wird, legen wir einen Cronjob dafür an (als Benutzer <strong>root</strong>). In der hier gezeigten Konfiguration wird das Skript alle 5 Minuten ausgeführt.</p>
<p><em>crontab -e</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;">5</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> <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>fetchmail.pl <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>

]]></content:encoded>
			<wfw:commentRss>http://johker.ibutho.de/2009/04/07/fetchmail-integration-in-postfixadmin/feed/</wfw:commentRss>
		<slash:comments>0</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>
		<item>
		<title>Der neue Server: Teil 1 Installation und Basiskonfiguration</title>
		<link>http://johker.ibutho.de/2009/03/17/der-neue-server-teil-1-installation-und-basiskonfiguration/</link>
		<comments>http://johker.ibutho.de/2009/03/17/der-neue-server-teil-1-installation-und-basiskonfiguration/#comments</comments>
		<pubDate>Tue, 17 Mar 2009 19:32:06 +0000</pubDate>
		<dc:creator>johker</dc:creator>
				<category><![CDATA[Howto]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[adduser]]></category>
		<category><![CDATA[apt]]></category>
		<category><![CDATA[apticron]]></category>
		<category><![CDATA[aptitude]]></category>
		<category><![CDATA[bashrc]]></category>
		<category><![CDATA[bash_aliases]]></category>
		<category><![CDATA[benachrichtigung]]></category>
		<category><![CDATA[completion]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[dateizugriff]]></category>
		<category><![CDATA[dist-upgrade]]></category>
		<category><![CDATA[DoS]]></category>
		<category><![CDATA[dpkg-reconfigure]]></category>
		<category><![CDATA[dropbox]]></category>
		<category><![CDATA[findutils]]></category>
		<category><![CDATA[hetzner]]></category>
		<category><![CDATA[htop]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[locate]]></category>
		<category><![CDATA[lsof]]></category>
		<category><![CDATA[lvm]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[mc]]></category>
		<category><![CDATA[mdadm]]></category>
		<category><![CDATA[midnight commander]]></category>
		<category><![CDATA[ncurses]]></category>
		<category><![CDATA[partitionierung]]></category>
		<category><![CDATA[postfix]]></category>
		<category><![CDATA[public]]></category>
		<category><![CDATA[raid]]></category>
		<category><![CDATA[rescue-system]]></category>
		<category><![CDATA[root]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[smart]]></category>
		<category><![CDATA[smartmontools]]></category>
		<category><![CDATA[traffic]]></category>
		<category><![CDATA[update]]></category>
		<category><![CDATA[updatedb]]></category>
		<category><![CDATA[useradd]]></category>
		<category><![CDATA[vimrc]]></category>

		<guid isPermaLink="false">http://johker.ibutho.de/?p=102</guid>
		<description><![CDATA[Seit ca. November letzten Jahres war klar, dass ein neuer Server her muss - nicht zuletzt, weil einige Leute bei ibutho ausgestiegen sind und ibutho doch etwas zu schwach ist für unsere Ansprüche. Die Planungen liefen auch schon seit Ende letzten Jahres und nun haben sie alle Gestalt angenommen. Die Domains werden alle zentral über [...]]]></description>
			<content:encoded><![CDATA[<p>Seit ca. November letzten Jahres war klar, dass ein neuer Server her muss - nicht zuletzt, weil einige Leute bei ibutho ausgestiegen sind und ibutho doch etwas zu schwach ist für unsere Ansprüche. Die Planungen liefen auch schon seit Ende letzten Jahres und nun haben sie alle Gestalt angenommen. Die Domains werden alle zentral über <a href="http://www.inwx.de/" target="_blank">inwx.de</a> verwaltet. Dies hat den Vorteil, dass wir unabhängig vom Provider des Root-Servers sind und später ohne Probleme wechseln können. Beim Server haben wir uns für einen <a href="http://www.hetzner.de/hosting/produkte_rootserver/ds3000/" target="_blank">DS3000</a> von <a href="http://hetzner.de" target="_blank">Hetzner</a> entschieden. Dieser sagte uns sowohl von den Hardware-Daten als auch vom Preis-/Leistungsverhältnis zu (AMD Athlon 64 X2 5600+, 2GB RAM, 2 x 400GB Festplatte, 100MBit Anbindung ans Internet, 7 IP-Adressen, unbegrenzter Traffic).</p>
<p>Im Weiteren will ich auf die Grundinstallation eingehen und in den folgenden Teilen auf die beispielhafte Installation und Konfiguration verschiedenster Server-Dienste. Ich hoffe, dass diese Beiträge für den ein oder anderen nützlich sind, wenn sie ihren eigenen Server konfigurieren und absichern wollen. Ich bitte um rege Diskussionen, damit die Beiträge sinnvoll erweitert und Fehler beseitigt werden können.</p>
<h1>Installation des Systems</h1>
<p>Hetzner vereinfacht dem Administrator die Installation eines eigenen Betriebssystems über das Rescue-System sehr. Es wir ein Skript installimage angeboten, über welches man z.B. die Festplatte partitionieren kann, ein LVM einrichten kann oder einen Software-RAID konfigurieren kann.</p>
<p>Bei meiner Installation entschied ich mich für ein RAID1-System mit LVM. Für RAID1 entschied ich mich aufgrund der gesteigerten Ausfallsicherheit und der gesteigerten Lese-Performance. Für LVM entschied ich mich, da dies mehr Flexibilität mit sich bringt als ein starres Partitionsschema. Sollte man später bemerken, dass eine Volume zu groß oder zu klein ist, kann man es einfach verkleinern/vergrößern. Versierte Leser mögen sich hier fragen, warum ich nicht komplett auf ein LVM-Setup setze und dem LVM auch das Mirroring überlasse. Der Grund ist einfach: über ein Software-RAID erhalte ich höhere Leseraten (siehe auch: <a href="http://www.joshbryan.com/blog/2008/01/02/lvm2-mirrors-vs-md-raid-1/" target="_blank">http://www.joshbryan.com/blog/2008/01/02/lvm2-mirrors-vs-md-raid-1/</a>, insbesondere auch die Kommentare). Beim Dateisystem setze ich auf ext3 bzw. ext2 für "/boot", da sich ext3 im LVM problemlos im laufenden Betrieb vergrößern bzw. verkleinern lässt.</p>
<p>Hier mein Partitionslayout:</p>
<table border="1" cellspacing="0" cellpadding="4" width="100%" bordercolor="#000000">
<col width="55"></col>
<col width="55"></col>
<col width="71"></col>
<col width="75"></col>
<tbody>
<tr valign="top">
<td colspan="2" width="43%" height="17" bgcolor="#e6e6e6">Mountpunkt</td>
<td width="28%" bgcolor="#e6e6e6">Dateisystem</td>
<td width="29%" bgcolor="#e6e6e6">Größe</td>
</tr>
<tr valign="top">
<td colspan="2" width="43%" height="18">/boot</td>
<td width="28%">ext2</td>
<td width="29%">256M</td>
</tr>
<tr valign="top">
<td colspan="2" width="43%" height="18">vg0</td>
<td width="28%">lvm</td>
<td width="29%">all</td>
</tr>
<tr valign="top">
<td width="21%" height="18"></td>
<td width="21%">swap</td>
<td width="28%">swap</td>
<td width="29%">2G</td>
</tr>
<tr valign="top">
<td width="21%" height="18"></td>
<td width="21%">/</td>
<td width="28%">ext3</td>
<td width="29%">5G</td>
</tr>
<tr valign="top">
<td width="21%" height="18"></td>
<td width="21%">/home</td>
<td width="28%">ext3</td>
<td width="29%">15G</td>
</tr>
<tr valign="top">
<td width="21%" height="18"></td>
<td width="21%">/tmp</td>
<td width="28%">ext3</td>
<td width="29%">4G</td>
</tr>
<tr valign="top">
<td width="21%" height="17"></td>
<td width="21%">/var</td>
<td width="28%">ext3</td>
<td width="29%">50G</td>
</tr>
</tbody>
</table>
<p>Sowohl "/boot", als auch "vg0" sind jeweils eine RAID1-Partition. Die ganze Arbeit das RAID einzurichten und danach das LVM hat mir das hetzner-Skript abgenommen.</p>
<h1>Erste Schritte</h1>
<h2>aptitude-Mirror konfigurieren</h2>
<p>Hetzner stellt einen eigenen aptitude-/apt-Mirror und diesen werden wir als allererstes ändern. Die Vorteile liegen auf der Hand: hohe Übertragungsraten und es handelt sich um internen Traffic, wird als nicht berechnet.</p>
<p>/etc/apt/sources.list:</p>

<div class="wp_syntax"><div class="code"><pre class="apt_sources" style="font-family:monospace;"><span style="color: #adadad; font-style: italic;"># Packages and Security Updates from the Hetzner Debian Mirror</span>
<span style="color: #00007f;">deb</span> <span style="color: #009900;">ftp://mirror.hetzner.de/debian/packages</span>  <span style="color: #b1b100;">lenny</span>          <span style="color: #b16000;">main</span> <span style="color: #b16000;">contrib</span> <span style="color: #b16000;">non-free</span>
<span style="color: #00007f;">deb</span> <span style="color: #009900;">ftp://mirror.hetzner.de/debian/security</span>  <span style="color: #b1b100;">lenny</span>/updates  <span style="color: #b16000;">main</span> <span style="color: #b16000;">contrib</span> <span style="color: #b16000;">non-free</span></pre></div></div>

<p>Und nun ein erstes Update&amp;Upgrade:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">aptitude</span> update <span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000; font-weight: bold;">&amp;</span>amp; <span style="color: #c20cb9; font-weight: bold;">aptitude</span> dist-upgrade</pre></div></div>

<h2>postfix Installation</h2>
<p>Da <em>postfix</em> der Mailserver meiner Wahl ist und ich nicht will, dass irgend ein Programm <em>exim</em> oder ähnliches installiert, werden wir jetzt gleich postfix installieren, jedoch noch nicht konfigurieren. Die Konfiguration folgt ausführlich in einem weiteren Teil.</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</pre></div></div>

<h2>Systemtools</h2>
<h3>apticron</h3>
<p>apticron ist ein Tool, welches einen per Mail informiert, wenn es Updates gibt. Dies ist besonders hilfreich, da das Tool die Paketquellen im Hintergrund updated, aber die Updates nicht einspielt; so bleibt es dem Administrator immer selbst überlassen, welche Pakete er einspielt und welche nicht, bzw. welche er erst ausführlicher testen will, da die Funktionalität des Systems evtl. erheblich beeinträchtigt werden könnte.</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> apticron</pre></div></div>

<h3>mdadm</h3>
<p>Mit <em>mdadm</em> wurde bereits das Software-RAID erstellt. Doch <em>mdadm</em> kann mehr: es kann den Benutzer auch per E-Mail informieren, wenn es Probleme mit dem RAID gibt. Dies wollen wir hier einstellen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">dpkg-reconfigure mdadm</pre></div></div>

<h3>smartmontools</h3>
<p>Mit den <em>smartmontools</em> kann man den Status des Festplatten abfragen und bekommt E-Mails, wenn die Festplatte kurz vor ihrem Lebensende ist.</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> smartmontools</pre></div></div>

<p><em>/etc/default/smartmontools</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># uncomment to start smartd on system startup</span>
<span style="color: #007800;">start_smartd</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># uncomment to pass additional options to smartd on startup</span>
<span style="color: #007800;">smartd_opts</span>=<span style="color: #ff0000;">&quot;--interval=1800&quot;</span></pre></div></div>

<p><em>/etc/smartd.conf</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">DEVICESCAN <span style="color: #660033;">-m</span> root <span style="color: #660033;">-M</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>share<span style="color: #000000; font-weight: bold;">/</span>smartmontools<span style="color: #000000; font-weight: bold;">/</span>smartd-runner</pre></div></div>

<h3>htop</h3>
<p><em>htop</em> ist eine erweiterte Version von <em>top</em> und bietet eine ncurses-Oberfläche, sowie Farben und "grafische" Anzeigen.</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> htop</pre></div></div>

<h3>lsof</h3>
<p><em>lsof</em> kann anzeigen, wer gerade auf einen Ordner/Gerät zugreift. Das Tool kann nützlich sein, wenn man einen Ordner unmounten will, aber noch jemand/etwas darauf zugreift.</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> lsof</pre></div></div>

<h3>mc</h3>
<p>Wer DOS noch kennt, kennt auch den <em>Norton Commander</em>. <em>mc</em> (ausgeschrieben: midnight commander) ist ein <em>Norton Commander</em>-Klon und vereinfacht einem das Leben in vielen Situationen. Einfach mal ausprobieren:</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> mc</pre></div></div>

<h3>locate</h3>
<p>Mit <em>locate</em> kann man schnell nach Dateien suchen. Es baut einen Index über Dateien und Ordner des Dateisystems auf und aktualisiert diesen mittels eines Cronjobs regelmäßig. Sucht man eine Datei, so gibt man einfach folgendes ein:</p>

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

<p>Das Paket kann mit folgendem Befehl installiert werden:</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;">locate</span></pre></div></div>

<p>Nach der Installation sollte als Erstes der Index aufgebaut werden (dies wird später automatisch gemacht):</p>

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

<h2>Benutzer anlegen</h2>
<p>Meine Anforderung an die Home-Laufwerke der einzelnen Benutzer ist, dass sie nicht von jedem gelesen werden können, aber dass man trotzdem Ordner/Dateien unterhalb des eigenen Home-Laufwerks für andere zugänglich machen kann, um z.B. einen "Briefkasten" zu implementieren, wo andere Benutzer Dateien für einen ablegen können, aber nicht sehen können, was sich sonst noch darin befindet. Deshalb wird mit folgenden Befehl die Sichtbarkeit der Home-Verzeichnisse geändert:</p>

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

<p>Außerdem hätte ich gerne, dass jeder Benutzer standardmäßig in der Gruppe "users" ist (man weiß ja nie, wozu das noch gut sein könnte). Dazu fügen wir an die Datei "<em>/etc/default/useradd</em>" am Ende folgendes an - bzw. an die Datei "<em>/etc/adduser.conf</em>" (je nachdem, ob man <em>adduser</em> oder <em>useradd</em> zum Hinzufügen von Benutzern verwendet):<br />
<em>/etc/default/useradd</em>:</p>

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

<p><em>/etc/adduser.conf</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">EXTRA_GROUPS</span>=<span style="color: #ff0000;">&quot;users&quot;</span>
<span style="color: #007800;">ADD_EXTRA_GROUPS</span>=<span style="color: #000000;">1</span></pre></div></div>

<p>Die "Briefkasten"-Erweiterung:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>skel<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> public
<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">755</span> public<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> public<span style="color: #000000; font-weight: bold;">/</span>dropbox
<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">753</span> public<span style="color: #000000; font-weight: bold;">/</span>dropbox<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">chown</span> root: public<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-R</span></pre></div></div>

<p>Nun legen wir noch eigene Versionen der Dateien .vimrc, .bashrc, .bash_aliases in "<em>/etc/skel/</em>":<br />
<em>.vimrc</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="vim" style="font-family:monospace;">sy on
se nu
set incsearch
set hlsearch
colorscheme slate</pre></div></div>

<p><em>.bashrc</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># ~/.bashrc: executed by bash(1) for non-login shells.</span>
<span style="color: #666666; font-style: italic;"># see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)</span>
<span style="color: #666666; font-style: italic;"># for examples</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PS1</span>=<span style="color: #ff0000;">'\h:\w\$ '</span>
<span style="color: #7a0874; font-weight: bold;">umask</span> 022
&nbsp;
<span style="color: #666666; font-style: italic;"># If not running interactively, don't do anything</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;">$PS1</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000; font-weight: bold;">&amp;</span>amp; <span style="color: #7a0874; font-weight: bold;">return</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># don't put duplicate lines in the history. See bash(1) for more options</span>
<span style="color: #666666; font-style: italic;"># don't overwrite GNU Midnight Commander's setting of `ignorespace'.</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">HISTCONTROL</span>=<span style="color: #007800;">$HISTCONTROL</span><span style="color: #800000;">${HISTCONTROL+,}</span>ignoredups
<span style="color: #666666; font-style: italic;"># ... or force ignoredups and ignorespace</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">HISTCONTROL</span>=ignoreboth
&nbsp;
<span style="color: #666666; font-style: italic;"># append to the history file, don't overwrite it</span>
<span style="color: #7a0874; font-weight: bold;">shopt</span> <span style="color: #660033;">-s</span> histappend
&nbsp;
<span style="color: #666666; font-style: italic;"># for setting history length see HISTSIZE and HISTFILESIZE in bash(1)</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># check the window size after each command and, if necessary,</span>
<span style="color: #666666; font-style: italic;"># update the values of LINES and COLUMNS.</span>
<span style="color: #7a0874; font-weight: bold;">shopt</span> <span style="color: #660033;">-s</span> checkwinsize
&nbsp;
<span style="color: #666666; font-style: italic;"># make less more friendly for non-text input files, see lesspipe(1)</span>
<span style="color: #666666; font-style: italic;">#[ -x /usr/bin/lesspipe ] &amp;amp;&amp;amp; eval &quot;$(SHELL=/bin/sh lesspipe)&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># set variable identifying the chroot you work in (used in the prompt below)</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;">$debian_chroot</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000; font-weight: bold;">&amp;</span>amp; <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-r</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>debian_chroot <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #007800;">debian_chroot</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>debian_chroot<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># set a fancy prompt (non-color, unless we know we &quot;want&quot; color)</span>
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TERM</span>&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
    xterm-color<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">color_prompt</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span><span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #000000; font-weight: bold;">esac</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># uncomment for a colored prompt, if the terminal has the capability; turned</span>
<span style="color: #666666; font-style: italic;"># off by default to not distract the user: the focus in a terminal window</span>
<span style="color: #666666; font-style: italic;"># should be on the output of commands, not on the prompt</span>
<span style="color: #666666; font-style: italic;">#force_color_prompt=yes</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$force_color_prompt</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-x</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>tput <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000; font-weight: bold;">&amp;</span>amp; tput setaf <span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #666666; font-style: italic;"># We have color support; assume it's compliant with Ecma-48</span>
        <span style="color: #666666; font-style: italic;"># (ISO/IEC-6429). (Lack of such support is extremely rare, and such</span>
        <span style="color: #666666; font-style: italic;"># a case would tend to support setf rather than setaf.)</span>
        <span style="color: #007800;">color_prompt</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span>
    <span style="color: #000000; font-weight: bold;">else</span>
        <span style="color: #007800;">color_prompt</span>=
    <span style="color: #000000; font-weight: bold;">fi</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: #ff0000;">&quot;<span style="color: #007800;">$color_prompt</span>&quot;</span> = <span style="color: #c20cb9; font-weight: bold;">yes</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #007800;">PS1</span>=<span style="color: #ff0000;">'${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '</span>
<span style="color: #000000; font-weight: bold;">else</span>
    <span style="color: #007800;">PS1</span>=<span style="color: #ff0000;">'${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">unset</span> color_prompt force_color_prompt
&nbsp;
<span style="color: #666666; font-style: italic;"># If this is an xterm set the title to user@host:dir</span>
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TERM</span>&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
xterm<span style="color: #000000; font-weight: bold;">*|</span>rxvt<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
    <span style="color: #007800;">PS1</span>=<span style="color: #ff0000;">&quot;\[\e]0;<span style="color: #007800;">${debian_chroot:+($debian_chroot)}</span>\u@\h: \w\a\]<span style="color: #007800;">$PS1</span>&quot;</span>
    <span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #000000; font-weight: bold;">esac</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Alias definitions.</span>
<span style="color: #666666; font-style: italic;"># You may want to put all your additions into a separate file like</span>
<span style="color: #666666; font-style: italic;"># ~/.bash_aliases, instead of adding them here directly.</span>
<span style="color: #666666; font-style: italic;"># See /usr/share/doc/bash-doc/examples in the bash-doc package.</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> ~<span style="color: #000000; font-weight: bold;">/</span>.bash_aliases <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    . ~<span style="color: #000000; font-weight: bold;">/</span>.bash_aliases
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># enable color support of ls and also add handy aliases</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-x</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><span style="color: #c20cb9; font-weight: bold;">dircolors</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;">eval</span> <span style="color: #ff0000;">&quot;<span style="color: #780078;">`dircolors -b`</span>&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">ls</span></span>=<span style="color: #ff0000;">'ls --color=auto'</span>
    <span style="color: #666666; font-style: italic;">#alias dir='dir --color=auto'</span>
    <span style="color: #666666; font-style: italic;">#alias vdir='vdir --color=auto'</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">#alias grep='grep --color=auto'</span>
    <span style="color: #666666; font-style: italic;">#alias fgrep='fgrep --color=auto'</span>
    <span style="color: #666666; font-style: italic;">#alias egrep='egrep --color=auto'</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># some more ls aliases</span>
<span style="color: #666666; font-style: italic;">#alias ll='ls -l'</span>
<span style="color: #666666; font-style: italic;">#alias la='ls -A'</span>
<span style="color: #666666; font-style: italic;">#alias l='ls -CF'</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># enable programmable completion features (you don't need to enable</span>
<span style="color: #666666; font-style: italic;"># this, if it's already enabled in /etc/bash.bashrc and /etc/profile</span>
<span style="color: #666666; font-style: italic;"># sources /etc/bash.bashrc).</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>bash_completion <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    . <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>bash_completion
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>

<p><em>.bash_aliases</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">l</span>=<span style="color: #ff0000;">'ls -lA'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">ll</span>=<span style="color: #ff0000;">'ls -l'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">la</span>=<span style="color: #ff0000;">'ls -a'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">lla</span>=<span style="color: #ff0000;">'ls -la'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">lal</span>=<span style="color: #ff0000;">'ls -la'</span></pre></div></div>

<p>Zusätzlich installieren wir noch das Paket "bash-completion", um eine komplexere Code- und Befehlsvervollständigung zu bekommen (wird erst nach erneutem Anmelden an der Konsole aktiv):</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> bash-completion</pre></div></div>

<p>Nun können wir mittels adduser einen Benutzer anlegen:</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>Benutzername<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://johker.ibutho.de/2009/03/17/der-neue-server-teil-1-installation-und-basiskonfiguration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
