<?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>Arnisoft &#187; Networking</title>
	<atom:link href="http://arnisoft.com/category/networking/feed/" rel="self" type="application/rss+xml" />
	<link>http://arnisoft.com</link>
	<description>Software Development  &#38; Networkadministration</description>
	<lastBuildDate>Wed, 13 Apr 2011 16:23:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>NGinx: Custom error handling</title>
		<link>http://arnisoft.com/285/nginx-custom-error-handling/</link>
		<comments>http://arnisoft.com/285/nginx-custom-error-handling/#comments</comments>
		<pubDate>Tue, 18 May 2010 16:23:52 +0000</pubDate>
		<dc:creator>devarni</dc:creator>
				<category><![CDATA[Howto]]></category>

		<guid isPermaLink="false">http://arnisoft.com/?p=285</guid>
		<description><![CDATA[I will give you a idea about the easy implementation of error page handling with Nginx. 1. Setting error handler Error handler can be set with the error_page directive. More about this directive you can find here. Do this in your server block but better use a generic file and include this in every virtual [...]]]></description>
			<content:encoded><![CDATA[<p>I will give you a idea about the easy implementation of error page handling with Nginx.</p>
<p><b>1. Setting error handler</b></p>
<p>Error handler can be set with the <code>error_page</code> directive. More about this directive you can find <a href="http://wiki.nginx.org/NginxHttpCoreModule#error_page" mce_href="http://wiki.nginx.org/NginxHttpCoreModule#error_page" target="_blank">here</a>.</p>
<p>Do this in your server block but better use a generic file and include this in every virtual host server block.&nbsp;I use for this a file &#8220;vhost&#8221; with all such settings.</p>
<p>The handler or html files are placed in a separate folder outside the webs. You can use a folder inside your Nginx settings (I use here for example a &#8220;html&#8221; folder).</p>
<p>The location block is needed to pass the correct root and file to php fastcgi. In this example I use a file &#8220;fastcgi&#8221; &nbsp;with this mostly used lines:</p>
<pre name="code" class="php">
fastcgi_pass   unix:/tmp/fastcgi.socket;
fastcgi_index  index.php;
fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
include fastcgi_params;
</pre>
<p>Here the part in the server block (or in your generic vhost file for including):</p>
<pre name="code" class="php">

# error handler, codes can also be combined
error_page 401 /error.php?c=401;
error_page 403 /error.php?c=403;
error_page 404 /error.php?c=404;
error_page 500 /error.php?c=500;
error_page 502 503 504 /error.php?c=50x;

# serve error.php from /etc/nginx/html folder
location =/error.php {
   root /etc/nginx/html;
   include conf/fastcgi;
}
</pre>
<p><b>2. PHP file</b></p>
<p>The error.php file will be called with the URL encoded error-code, so its easy to grab this code in the PHP file from the superglobal <code>$_GET</code> array.</p>
<p>To map this error code to a message string, use a associative array and a function to return the string.</p>
<p>This is the part in the error.php file:</p>
<pre name="code" class="php">

<?php

//mapping array for error code to message string
$_err = Array("401" => "Autorisierung erforderlich! - Authorization Required",
    "403" => "Zugriff ist nicht erlaubt! - Access forbidden",
    "404" => "Seite wurde nicht gefunden - Page not found",
    "500" => "Interner Serverfehler - Internal Server Error",
    "50x" => "Seite ist momentan nicht verf&uuml;gbar. Bitte Anfrage sp&auml;ter wiederholen.<br/>-<br/>The page is temporarily unavailable. Try again later.");

// get the error string
function errorString($error) {
    global $_err;

    foreach ($_err as $key => $val) {
        if ($key == $error)
            return $val;
    }

    return "Unknown Error";
}

isset($_GET['c']) or die("Unknown Error");
$error = $_GET['c'];
$str = errorString($error);

?>

Error &lt;?=$error?&gt;: <strong>&lt;?=$str?&gt;</strong>
</pre>
<p>You can format the error page as you like. But remember: the web root url will be the  actual virtual host! Easiest way: use inline CSS. If this is not your preferred way, place the css file in a virtual host (eg. your default virtual host)</p>
]]></content:encoded>
			<wfw:commentRss>http://arnisoft.com/285/nginx-custom-error-handling/feed/lang/en/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nginx: phpmyadmin configuration</title>
		<link>http://arnisoft.com/253/nginx-phpmyadmin-configuration/</link>
		<comments>http://arnisoft.com/253/nginx-phpmyadmin-configuration/#comments</comments>
		<pubDate>Thu, 13 May 2010 15:11:53 +0000</pubDate>
		<dc:creator>devarni</dc:creator>
				<category><![CDATA[Howto]]></category>

		<guid isPermaLink="false">http://arnisoft.com/?p=253</guid>
		<description><![CDATA[This configuration is used to access phpmyadmin as a &#8220;subfolder&#8221; of the domain like: http://mysite.com/phpmyadmin The location will be append to the root! For a similar behaviour like the Apache configuration, you could use the &#8220;alias&#8221; directive My phpmyadmin installation is under /usr/share/phpmyadmin, thats why I use /usr/share as the root. server{ ... location /phpmyadmin{ [...]]]></description>
			<content:encoded><![CDATA[<p>This configuration is used to access phpmyadmin as a &#8220;subfolder&#8221; of the domain like:</p>
<p>http://mysite.com/phpmyadmin</p>
<p>
The location will be append to the root! For a similar behaviour like the Apache configuration, you could use the &#8220;alias&#8221; directive<br/><br />
My phpmyadmin installation is under /usr/share/phpmyadmin, thats why I use /usr/share as the root.
</p>
<pre name="code" class="js">
server{
...
    location /phpmyadmin{
        root    /usr/share;
        index   index.php;
    }

    location ~ \.php$ {
        set $php_root   $document_root;
            if ($request_uri ~* /phpmyadmin) {
                set $php_root /usr/share;
           }

        fastcgi_pass   unix:/tmp/fastcgi.socket;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $php_root$fastcgi_script_name;
        include /etc/nginx/fastcgi_params;
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://arnisoft.com/253/nginx-phpmyadmin-configuration/feed/lang/en/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Server Benchmark: Apache, Nginx, Cherokee, Lighttp</title>
		<link>http://arnisoft.com/239/server-benchmark-apache-nginx-cherokee/</link>
		<comments>http://arnisoft.com/239/server-benchmark-apache-nginx-cherokee/#comments</comments>
		<pubDate>Thu, 13 May 2010 10:21:14 +0000</pubDate>
		<dc:creator>devarni</dc:creator>
				<category><![CDATA[Networking]]></category>

		<guid isPermaLink="false">http://arnisoft.com/?p=239</guid>
		<description><![CDATA[Quick Benchmark of Apache, Nginx, Cherokee, Lighttpd A short benchmark of this 4 server with dynamic and static content. All server provides the same functionality like URL rewriting, password protected folders/files etc. but all have their own way to do that For shared hosting where the user has no access to the server configuration, Apache [...]]]></description>
			<content:encoded><![CDATA[<h2>Quick Benchmark of Apache, Nginx, Cherokee, Lighttpd</h2>
<p>A short benchmark of this 4 server with dynamic and static content.<br />
 All server provides the same functionality like URL rewriting, password protected folders/files etc. but all have their own way to do that <img src='http://arnisoft.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> <br />
 For shared hosting where the user has no access to the server configuration, Apache with the .htaccess file support is a good choice.</p>
<p>I used the benchmark tool from Apache <code>ab -n 50000 -c 20</code> <br />
 php-cgi goes over a Unix socket</p>
<p><strong>Dynamic Content (PHP)</strong></p>
<table border="0" cellpadding="0" cellspacing="0" width="300px">
<tbody>
<tr>
<td class="fi bb">Server</td>
<td class="fi bb">Requests (sec)</td>
<td class="fi bb">Transferrate (KB/s)</td>
</tr>
<tr class="ac">
<td class="fi">Apache 2.2.14</td>
<td>2125</td>
<td>11684</td>
</tr>
<tr>
<td class="fi">Nginx 0.7.65</td>
<td>1734<br />
 1861</td>
<td>9436 (php-cgi)<br />
 10115 (php-fpm)</td>
</tr>
<tr class="ac">
<td class="fi">Cherokee 1.0.0</td>
<td>2119<br />
 2103</td>
<td>11562 (php-cgi)<br />
 11454 (php-fpm)</td>
</tr>
</tbody>
</table>
<p><strong>Static content (14785 Bytes HTML file)</strong></p>
<table border="0" cellpadding="0" cellspacing="0" width="300px">
<tbody>
<tr>
<td class="fi bb">Server</td>
<td class="fi bb">Requests (sec)</td>
<td class="fi bb">Transferrate (KB/s)</td>
</tr>
<tr class="ac">
<td class="fi">Apache 2.2.14</td>
<td>6768</td>
<td>99593</td>
</tr>
<tr>
<td class="fi">Lighttpd 2.4.26</td>
<td class="red">15782</td>
<td class="red">213866</td>
</tr>
<tr class="ac">
<td class="fi">Cherokee 1.0.0</td>
<td>7602</td>
<td>111285</td>
</tr>
<tr>
<td class="fi">Nginx 0.7.65</td>
<td>10912</td>
<td>159828</td>
</tr>
</tbody>
</table>
<p><strong>More &#8220;real live&#8221; test with PHP and eAccelerator enabled</strong></p>
<p>Cherokee/NGinx/Lighttp are using the same php-fpm socket<br/></p>
<table border="0" cellpadding="0" cellspacing="0" width="300px">
<tbody>
<tr>
<td class="fi bb center">Server</td>
<td class="fi bb center">Requests/s</td>
<td class="fi bb center">&Oslash;</td>
</tr>
<tr class="ac">
<td class="fi">Apache 2.2.14</td>
<td>2713|2744|2766</td>
<td class="red">2741</td>
</tr>
<tr>
<td class="fi">Nginx 0.7.65</td>
<td>2416|2433|2418</td>
<td>2422</td>
</tr>
<tr class="ac">
<td class="fi">Cherokee 1.0.0</td>
<td>2702|2638|2694</td>
<td>2678</td>
</tr>
<tr>
<td class="fi">Lighttp 1.4.26</td>
<td>2492|2363|2540</td>
<td>2465</td>
</tr>
</tbody>
</table>
<p>Results<br/></p>
<p>There is a small difference between fast-cgi and php-fpm (alternative implementation of fast-cgi).<br />
 You should prefer php-fpm (will be included in PHP 5.4 or you must build it manually from source).</p>
<p>Apache and Cherokee are both excellent for dynamic content.</p>
<p>For static content Lighttp is the fastest server.</p>
<p><strong>There is not _the_ best server</strong> but a good combination: Lighttpd or Nginx as a proxy for serving static content, Apache or Cherokee for the dynamic content. Or a another proxy server like Varnish for static content and caching  and Apache/Cherokee for serving dynamic content
</p>
<p>For a PHP site with only 1 server running: Apache. <br/><br />
For a smaller memory footprint and if .htaccess is not needed: Cherokee (also the only server with a very good graphical admin interface)</p>
]]></content:encoded>
			<wfw:commentRss>http://arnisoft.com/239/server-benchmark-apache-nginx-cherokee/feed/lang/en/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

