<?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>netz-guru blog &#187; apache2</title>
	<atom:link href="http://www.netz-guru.de/tag/apache2/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.netz-guru.de</link>
	<description>Webtechniken, Sicherheit und Interessantes...</description>
	<lastBuildDate>Fri, 18 Jun 2010 16:17:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>apache2, virtualdocumentroot und Logfiles in verschiedene Files</title>
		<link>http://www.netz-guru.de/2008/05/21/apache2-virtualdocumentroot-und-logfiles-in-verschiedene-files/</link>
		<comments>http://www.netz-guru.de/2008/05/21/apache2-virtualdocumentroot-und-logfiles-in-verschiedene-files/#comments</comments>
		<pubDate>Wed, 21 May 2008 19:18:05 +0000</pubDate>
		<dc:creator>Florian Wiessner</dc:creator>
				<category><![CDATA[Hosting]]></category>
		<category><![CDATA[Usefull Things]]></category>
		<category><![CDATA[apache2]]></category>
		<category><![CDATA[logfiles]]></category>
		<category><![CDATA[mass virtual hosting]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[virtualdocumentroot]]></category>

		<guid isPermaLink="false">http://www.netz-guru.de/?p=24</guid>
		<description><![CDATA[Wieder mal ein spezifisches Problem:
Wer mit apache2 einfaches Massenhosting betreiben will, der will nicht für jeden Virtualhost einen VirtualHost-Container in seiner Apache Konfiguration anlegen, denn ab ca. 500 Domains als VHostContainer wird zum einen die Konfiguration sehr unübersichtlich und ausserdem wird der Indianer dadurch langsamer, aufgrund von vielen offenen Filehandles. Muss man ja auch nicht, [...]]]></description>
			<content:encoded><![CDATA[<p>Wieder mal ein spezifisches Problem:</p>
<p>Wer mit apache2 einfaches Massenhosting betreiben will, der will nicht für jeden Virtualhost einen VirtualHost-Container in seiner Apache Konfiguration anlegen, denn ab ca. 500 Domains als VHostContainer wird zum einen die Konfiguration sehr unübersichtlich und ausserdem wird der Indianer dadurch langsamer, aufgrund von vielen offenen Filehandles. Muss man ja auch nicht, schliesslich gibt es das vhost_alias Modul, mit welchem man ein VirtualDocumentRoot konfigurieren kann, dass dann das DocumentRoot anhand des übermittelten ServerName oder HTTP-Host Headers auswertet.</p>
<p>In der Apache Konfiguration sieht das dann z.B. so aus:<br />
<code><br />
&lt;VirtualHost *&gt;<br />
UseCanonicalName Off<br />
Options Indexes Includes FollowSymLinks MultiViews<br />
VirtualDocumentRoot /domains/%0/www<br />
VirtualScriptAlias  /domains/%0/cgi-bin/<br />
CustomLog access_log vcommon<br />
&lt;Directory /domains/%0/www&gt;<br />
AllowOverride All<br />
&lt;/Directory&gt;<br />
&lt;/VirtualHost&gt;<br />
</code><br />
Das Problem ist nun, dass alle Logs in ein einziges File &#8220;access_log&#8221; geloggt werden, und es schwierig ist, hier für die einzelnen gehosteten Domains Statistiken zu erzeugen etc.</p>
<p>Man kann nun aber um dieses Problem zu umgehen Folgendes tun:<br />
Man erzeugt in /etc/apache2 ein Script welches die Ausgabe des Logfiles aufteilt und in mehrere Dateien speichert:</p>
<p><code><br />
</code><code><span style="#000000;"> #!/usr/bin/php<br />
<span style="#0000bb;">&lt;?php</span></span></code></p>
<p>$path <span style="#007700;">= </span><span style="#dd0000;">&#8220;/var/log/apache2&#8243;</span><span style="#007700;">;<br />
</span><span style="#0000bb;">$fh_timeout </span><span style="#007700;">= </span><span style="#0000bb;">30</span><span style="#007700;">; </span><span style="#ff8000;">// 30 sek.</span></p>
<p><span style="#0000bb;">$fd </span><span style="#007700;">= </span><span style="#0000bb;">fopen</span><span style="#007700;">(</span><span style="#dd0000;">&#8220;php://stdin&#8221;</span><span style="#007700;">, </span><span style="#dd0000;">&#8220;r&#8221;</span><span style="#007700;">);</span></p>
<p>while(!<span style="#0000bb;">feof</span><span style="#007700;">(</span><span style="#0000bb;">$fd</span><span style="#007700;">)) {</span></p>
<p><span style="#0000bb;">$row </span><span style="#007700;">= </span><span style="#0000bb;">fgets</span><span style="#007700;">(</span><span style="#0000bb;">$fd</span><span style="#007700;">);</span></p>
<p>list(<span style="#0000bb;">$vhost</span><span style="#007700;">,</span><span style="#0000bb;">$h</span><span style="#007700;">,</span><span style="#0000bb;">$l</span><span style="#007700;">,</span><span style="#0000bb;">$u</span><span style="#007700;">,</span><span style="#0000bb;">$t</span><span style="#007700;">,</span><span style="#0000bb;">$r</span><span style="#007700;">,</span><span style="#0000bb;">$s</span><span style="#007700;">,</span><span style="#0000bb;">$b</span><span style="#007700;">,</span><span style="#0000bb;">$referrer</span><span style="#007700;">,</span><span style="#0000bb;">$ua</span><span style="#007700;">) = </span><span style="#0000bb;">explode</span><span style="#007700;">(</span><span style="#dd0000;">&#8220;;&#8221;</span><span style="#007700;">,</span><span style="#0000bb;">$row</span><span style="#007700;">,</span><span style="#0000bb;">10</span><span style="#007700;">);</span></p>
<p>if (!${<span style="#0000bb;">$vhost</span><span style="#007700;">}) { ${</span><span style="#0000bb;">$vhost</span><span style="#007700;">} = </span><span style="#0000bb;">fopen</span><span style="#007700;">(</span><span style="#0000bb;">$path</span><span style="#007700;">.</span><span style="#dd0000;">&#8220;/&#8221;</span><span style="#007700;">.</span><span style="#0000bb;">$vhost</span><span style="#007700;">.</span><span style="#dd0000;">&#8220;_access.log&#8221;</span><span style="#007700;">,</span><span style="#dd0000;">&#8220;a+&#8221;</span><span style="#007700;">); }<br />
</span><span style="#0000bb;">$lastwrite</span><span style="#007700;">[</span><span style="#0000bb;">$vhost</span><span style="#007700;">] = </span><span style="#0000bb;">time</span><span style="#007700;">();<br />
</span><span style="#0000bb;">fputs </span><span style="#007700;">(${</span><span style="#0000bb;">$vhost</span><span style="#007700;">},</span><span style="#dd0000;">&#8220;$h $l $u $t $r $s $b $referrer $ua&#8221;</span><span style="#007700;">);</span></p>
<p>foreach (<span style="#0000bb;">$lastwrite </span><span style="#007700;">as </span><span style="#0000bb;">$vhost </span><span style="#007700;">=&gt; </span><span style="#0000bb;">$time</span><span style="#007700;">) {<br />
if ((</span><span style="#0000bb;">time</span><span style="#007700;">() &#8211; (</span><span style="#0000bb;">$time</span><span style="#007700;">+</span><span style="#0000bb;">30</span><span style="#007700;">))  &gt;=</span><span style="#0000bb;">0</span><span style="#007700;">) {<br />
</span><span style="#0000bb;">fclose</span><span style="#007700;">(${</span><span style="#0000bb;">$vhost</span><span style="#007700;">});<br />
unset(${</span><span style="#0000bb;">$vhost</span><span style="#007700;">});<br />
unset(</span><span style="#0000bb;">$lastwrite</span><span style="#007700;">[</span><span style="#0000bb;">$vhost</span><span style="#007700;">]);<br />
}<br />
}<br />
}<br />
</span><span style="#0000bb;">?&gt;</span></p>
<p>Nun müssen wir in der apache2 Konfiguration noch das Logformat ändern und die Ausgabe des Logfiles an unser Script durchpipen:<br />
<code><br />
LogFormat "%V;%h;%l;%u;%t;\"%r\";%&gt;s;%b;\"%{Referer}i\";\"%{User-agent}i\"" vcommon<br />
CustomLog "|/etc/apache2/splitlogs.php" vcommon</code></p>
<p>Dann Apache einmal neu starten und künftig werden pro Host separate Logfiles erstellt.</p>
<p>Edit: Fast hätte ich es vergessen! Das Script braucht natuerlich eXecutable-Flag also am besten chmod  755 /etc/apache2/splitlogs.php ausführen!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.netz-guru.de/2008/05/21/apache2-virtualdocumentroot-und-logfiles-in-verschiedene-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>apache2, mod_mysql_auth, debian etch</title>
		<link>http://www.netz-guru.de/2008/01/30/apache2-mod_mysql_auth-debian-etch/</link>
		<comments>http://www.netz-guru.de/2008/01/30/apache2-mod_mysql_auth-debian-etch/#comments</comments>
		<pubDate>Wed, 30 Jan 2008 02:03:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Hosting]]></category>
		<category><![CDATA[Webtechniken]]></category>
		<category><![CDATA[apache2]]></category>
		<category><![CDATA[auth]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[etch]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.netz-guru.de/2008/01/30/apache2-mod_mysql_auth-debian-etch/</guid>
		<description><![CDATA[Wer ebenfalls verzweifelt mod_mysql_auth für Apache2 unter Debian Etch sucht, dem sei gesagt, dass es aus lizenztechnischen Gründen in Debian Etch nicht mehr enthalten ist.
Man kann jedoch das Module relativ einfach nachinstallieren:

mkdir /root/src
aptitude install apache2-prefork-dev libmysqlclient15-dev
cd /root/src/
mkdir auth_mysql
cd auth_mysql
wget http://download.nuxwin.com/apache2.2-modules/auth_mysql/mod_auth_mysql-3.0.0.tar.gz
wget http://download.nuxwin.com/apache2.2-modules/auth_mysql/patch/apache2.2.diff
tar xzf mod_auth_mysql-3.0.0.tar.gz
mv apache2.2.diff mod_auth_mysql-3.0.0/
cd mod_auth_mysql-3.0.0
patch -p0 &#60; apache2.2.diff mod_auth_mysql.c
apxs2 -c -L/usr/lib/mysql -I/usr/include/mysql -lmysqlclient -lm [...]]]></description>
			<content:encoded><![CDATA[<p>Wer ebenfalls verzweifelt mod_mysql_auth für Apache2 unter Debian Etch sucht, dem sei gesagt, dass es aus lizenztechnischen Gründen in Debian Etch nicht mehr enthalten ist.</p>
<p>Man kann jedoch das Module relativ einfach nachinstallieren:<br />
<span id="more-14"></span><br />
mkdir /root/src<br />
aptitude install apache2-prefork-dev libmysqlclient15-dev<br />
cd /root/src/<br />
mkdir auth_mysql<br />
cd auth_mysql<br />
wget http://download.nuxwin.com/apache2.2-modules/auth_mysql/mod_auth_mysql-3.0.0.tar.gz<br />
wget http://download.nuxwin.com/apache2.2-modules/auth_mysql/patch/apache2.2.diff<br />
tar xzf mod_auth_mysql-3.0.0.tar.gz<br />
mv apache2.2.diff mod_auth_mysql-3.0.0/<br />
cd mod_auth_mysql-3.0.0<br />
patch -p0 &lt; apache2.2.diff mod_auth_mysql.c<br />
apxs2 -c -L/usr/lib/mysql -I/usr/include/mysql -lmysqlclient -lm -lz mod_auth_mysql.c<br />
apxs2 -i mod_auth_mysql.la<br />
echo &#8220;LoadModule mysql_auth_module /usr/lib/apache2/modules/mod_auth_mysql.so&#8221; &gt; /etc/apache2/mods-available/auth_mysql.load<br />
a2enmod auth_mysql<br />
/etc/init.d/apache2 force-reload</p>
]]></content:encoded>
			<wfw:commentRss>http://www.netz-guru.de/2008/01/30/apache2-mod_mysql_auth-debian-etch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
