<?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>xgrr.de - the whole not the half &#187; apache2</title>
	<atom:link href="http://www.xgrr.de/wordpress/tag/apache2/feed" rel="self" type="application/rss+xml" />
	<link>http://www.xgrr.de/wordpress</link>
	<description>things, thoughts and stuff out of life, daily business and computer science</description>
	<lastBuildDate>Fri, 12 Feb 2010 10:11:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Apache2 + mod_fcgid + PHP = Awesome</title>
		<link>http://www.xgrr.de/wordpress/2010/02/12/apache2-mod_fcgid-php-awesome</link>
		<comments>http://www.xgrr.de/wordpress/2010/02/12/apache2-mod_fcgid-php-awesome#comments</comments>
		<pubDate>Fri, 12 Feb 2010 10:05:33 +0000</pubDate>
		<dc:creator>peterschen</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[apache2]]></category>
		<category><![CDATA[fastcgi]]></category>
		<category><![CDATA[fcgi]]></category>
		<category><![CDATA[fcgid]]></category>
		<category><![CDATA[improvement]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[prefork]]></category>
		<category><![CDATA[threaded]]></category>
		<category><![CDATA[webserver]]></category>
		<category><![CDATA[worker]]></category>

		<guid isPermaLink="false">http://www.xgrr.de/wordpress/?p=731</guid>
		<description><![CDATA[For years now I was using PHP as a Apache module and not thinking twice about it. Easy to install not much to maintain and working reasonably well. Server too slow? Buy a new server. Recently one of our servers got really slow again with varying timeouts while serving pages. Memory shortage. No new server [...]]]></description>
			<content:encoded><![CDATA[<p>For years now I was using PHP as a Apache module and not thinking twice about it. Easy to install not much to maintain and working reasonably well. Server too slow? Buy a new server. Recently one of our servers got really slow again with varying timeouts while serving pages. Memory shortage. No new server available I needed to make the most of it and started investigating how to decrease the memory footprint of Apache.</p>
<p>FastCGI was the answer. With PHP as a module installed every Apache process can take up to the maximum amount of memory you defined in php.ini plus what the Apache process needs by himself even though this process is only serving static content. With the switch to FastCGI it was possible to use the threaded version of Apache (mpm_worker). Static contents are now served really fast without need for invoking PHP at all. PHP scripts are served by calling the FastCGI IPC.</p>
<p>As memory is still low Apache and PHP are both configured to &#8220;die&#8221; after quite a low number of requests served. This can sometimes lead to a small delay while the processes are restarted but ensures that the memory footprint is kept low.</p>
<p>How did I do it? I won&#8217;t go into details on how to install Apache, mod_fcgid and PHP because there are loads of howto&#8217;s out there. Please find the configuration I&#8217;m using below. I&#8217;m using Debian and Apache, mod_fcgid and PHP are installed out of the repository. If you have a custom compiled version or different distribution your paths can differ.</p>
<p>Depending on your available hardware it is feasible to tweak the settings for the mpm_worker module so more concurrent clients can be served and/or the amount of requests which is handled before re-creating the thread is higher. It is also very recommended to use eAccelerator in conjunction with this setup. <a title="eAccelerator to enhance PHP performance " href="http://www.xgrr.de/wordpress/2010/02/10/eaccelerator-to-enhance-php-performance">See my post on the topic for more information</a>.</p>
<p><strong>/etc/apache2/apache2.conf (excerpt):</strong></p>
<blockquote>
<pre>&lt;IfModule mpm_worker_module&gt;
	StartServers           4
	ServerLimit            4
	MaxClients           128
	MinSpareThreads        8
	MaxSpareThreads       16
	ThreadsPerChild       32
	MaxRequestsPerChild  500
&lt;/IfModule&gt;</pre>
</blockquote>
<p><strong>/etc/apache2/mods-available/fcgid.conf:</strong></p>
<blockquote>
<pre>&lt;IfModule mod_fcgid.c&gt;
	AddHandler fcgid-script .fcgi .php
	FCGIWrapper /var/www/php-fcgi-starter .php

	IdleTimeout		3600
	BusyTimeout		 300
	ProcessLifeTime		7200
	IPCConnectTimeout	  10
	IPCCommTimeout		 360
	MaxProcessCount		  15
	MaxRequestsPerProcess	  -1
	PHP_Fix_Pathinfo_Enable    1
&lt;/IfModule&gt;</pre>
</blockquote>
<p><strong>/var/www/php-fcgi-starter:</strong></p>
<blockquote>
<pre>#!/bin/sh
PHPRC=/etc/php5/cgi/
export PHPRC
export PHP_FCGI_MAX_REQUESTS=250
export PHP_FCGI_CHILDREN=1
exec /usr/lib/cgi-bin/php</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.xgrr.de/wordpress/2010/02/12/apache2-mod_fcgid-php-awesome/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WebDAV: All-time access to your files</title>
		<link>http://www.xgrr.de/wordpress/2008/08/15/webdav-all-time-access-to-your-files</link>
		<comments>http://www.xgrr.de/wordpress/2008/08/15/webdav-all-time-access-to-your-files#comments</comments>
		<pubDate>Fri, 15 Aug 2008 10:42:01 +0000</pubDate>
		<dc:creator>peterschen</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[apache2]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[netdrive]]></category>
		<category><![CDATA[novell]]></category>
		<category><![CDATA[webdav]]></category>

		<guid isPermaLink="false">http://www.xgrr.de/wordpress/?p=353</guid>
		<description><![CDATA[Yeah. Streaming isn&#8217;t that compatible with firewalls around the world especially in corporate situations. So I needed to figure out a better solution to get to my precious files without hassle. The solution: WebDAV. I allready use WebDAV in combination with Subversion. DAV is an extension to the HTTP protocol which allows you also to [...]]]></description>
			<content:encoded><![CDATA[<p>Yeah. Streaming isn&#8217;t that compatible with firewalls around the world especially in corporate situations. So I needed to figure out a better solution to get to my precious files without hassle. The solution: WebDAV.</p>
<p>I allready use WebDAV in combination with Subversion. DAV is an extension to the HTTP protocol which allows you also to upload files onto the webserver. This makes FTP useless and with some tricky tools it also integrates quite nicely in your desktop environment.</p>
<p>I have a 2 tier setup. At home my server features a Apache2 with enabled WebDAV. Configured as follows:</p>
<pre>Alias /share /path/to/your/files

&lt;Location /share&gt;
	Header add MS-Author-Via "DAV"

	BrowserMatch "^WebDAVFS/1.[012]" redirect-carefully
	BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
	BrowserMatch "Microsoft-WebDAV-MiniRedir/5.1.2600" redirect-carefully
	BrowserMatch "^WebDrive" redirect-carefully
	BrowserMatch "^WebDAVFS" redirect-carefully

	DAV on
	AuthType Basic
	AuthName Share
	AuthUserFile /path/to/your/.htpasswd
	Require valid-user
&lt;/Location&gt;</pre>
<p>And on my Windows XP PC there is a nice tool from Novell running called NetDrive. As this tool could not be provided by Novell directly due to license issues I <a href="http://www.xgrr.de/wordpress/wp-content/uploads/2008/08/netdrive.zip">put it here for download</a> (they especially mention to look for netdrive.exe on Google. So I think it shouldn&#8217;t hurt ).</p>
<p>With NetDrive you can mount the share like a network share as a normal drive and also can access it as such. With this solution you have all-time access to you files without need for any kind of strange solution which can issue other problems like NAT for instance.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.xgrr.de/wordpress/2008/08/15/webdav-all-time-access-to-your-files/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making Apach2 even faster</title>
		<link>http://www.xgrr.de/wordpress/2007/11/20/making-apach2-even-faster</link>
		<comments>http://www.xgrr.de/wordpress/2007/11/20/making-apach2-even-faster#comments</comments>
		<pubDate>Tue, 20 Nov 2007 11:08:06 +0000</pubDate>
		<dc:creator>peterschen</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[apache2]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.xgrr.de/wordpress/2007/11/20/making-apach2-even-faster/</guid>
		<description><![CDATA[When I built my new webserver I had to decide if I gonna use lighttpd or apache2. I wanted to use lighttpd because in fact it is faster than apache2. But then I discovered that it doesn&#8217;t support .htaccess files heavily used by my customers. So I had to throw away my flowery plans and [...]]]></description>
			<content:encoded><![CDATA[<p>When I built my new webserver I had to decide if I gonna use lighttpd or apache2. I wanted to use lighttpd because in fact it is faster than apache2. But then I discovered that it doesn&#8217;t support .htaccess files heavily used by my customers. So I had to throw away my flowery plans and use apache2 again. (Not that I&#8217;m really sad about it &#8211; the configuration was easy beacause I&#8217;m using it since&#8230; a long time ago <img src='http://www.xgrr.de/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> )</p>
<p>But I figured there has to be something to make the apache2 faster that it is out-of-the-box on a Debian Etch system. I wanted to use mod_fastcgi to link PHP and use mpm-worker for apache2 but due to a lack of time I failed. Later I discovered it was only a matter of permission which prevented this.  Due to mod-php5 I couldn&#8217;t use mpm-worker but had to use mpm-prefork the slower variant.</p>
<p>With this in mind I thought &#8220;lets check the apache2 docs and check if there is something we can do about this&#8221;. So I discovered the following directives which can fasten up things a little bit:</p>
<pre><a href="http://httpd.apache.org/docs/2.2/mod/mod_log_config.html#BufferedLogs" title="Apache2 Documentation">BufferedLogs </a>On
<a href="http://httpd.apache.org/docs/2.2/en/mod/core.html#EnableSendfile" title="Apache2 Documentation">EnableSendfile</a> On<a href="http://httpd.apache.org/docs/2.2/en/mod/core.html#hostnamelookups" title="Apache2 Documentation">
HostnameLookups</a> Off</pre>
<p>BufferedLogs is an experimental directive which prevents Apache2 to write logs directly to the disk but keeps them in memory and write them in a bunch. This should minimize the write overhead for each access so the access itself is faster.<br />
With EnableSendfile you tell apache2 to use the sendfile method from the Kernel for static files which should prevent apache2 to read the file itself so reducing the readoverhead for static content.<br />
HostnameLookups is off by default on Debian Etch. I don&#8217;t know how it is on other distributions. The command prevents apache2 to make an lookup for the ip from the visitor. When your nameserver is slow or no hostname can be resolved this could slow your system down incredibly. (In my expirience 70% all the problems with databases or webserver are DNS problems).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.xgrr.de/wordpress/2007/11/20/making-apach2-even-faster/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
