<?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>Dimitri.eu &#187; Lighttpd</title>
	<atom:link href="http://www.dimitri.eu/category/categories/technical/lighttpd/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dimitri.eu</link>
	<description>About personal and IT-related occupations</description>
	<lastBuildDate>Fri, 30 Jul 2010 18:20:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>How to configure Lighttpd with PHP5 and MySQL5</title>
		<link>http://www.dimitri.eu/how-to-configure-lighttpd-with-php5-and-mysql5/</link>
		<comments>http://www.dimitri.eu/how-to-configure-lighttpd-with-php5-and-mysql5/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 23:00:15 +0000</pubDate>
		<dc:creator>Dimi</dc:creator>
				<category><![CDATA[Lighttpd]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.dimitri.eu/?p=82</guid>
		<description><![CDATA[Over the years Apache has become somewhat of a standard web-server on unix servers but since the end of 2007 a worthy alternative to apache was born, called Lighttpd. Lighttpd has been proven to handle webrequests more efficiently than apache, resulting in a smaller memory footprint and a lower cpu load. For the moment a [...]]]></description>
			<content:encoded><![CDATA[<p>Over the years Apache has become somewhat of a standard web-server on unix servers but since the end of 2007 a worthy alternative to apache was born, called Lighttpd. <a href="http://www.lighttpd.net/" target="_blank">Lighttpd</a> has been proven to handle webrequests more efficiently than apache, resulting in a smaller memory footprint and a lower cpu load. For the moment a lot of large websites (more than 10 millions requests per day) are running on a lighttpd webserver, a few examples of these sites are:</p>
<ul>
<li><a href="http://www.imageshack.us" target="_blank">imageshack.us</a></li>
<li><a href="http://www.wikipedia.org" target="_blank">wikipedia.org</a></li>
<li><a href="http://www.mininova.org" target="_blank">mininova.org</a></li>
<li><a href="http://www.myspace.com" target="_blank">myspace.com</a></li>
<li><a href="http://www.youtube.com" target="_blank">youtube.com</a></li>
<li><a href="http://www.sourceforge.net" target="_blank">sourceforge.net</a></li>
</ul>
<p>This already is a fine curriculum so I thought it was time to configure a lighttpd server (with MySQL5 and PHP5 support) myself although I don&#8217;t come across any customers (I work at a hosting provider) who are using this at the moment.</p>
<p>We start of knowing that I usually work on debian-servers so some commands will not work on fedora, red-hat, and others.</p>
<p><span id="more-82"></span>First of all we check if apache isn&#8217;t already installed which it is in a lot of cases.</p>
<pre class="brush:bash; gutter: false; toolbar:false">dpkg -l | grep apache

ii  apache2-doc            2.2.3-4+etch6    documentation for apache2
ii  apache2-mpm-prefork    2.2.3-4+etch6    Traditional model for Apache
ii  apache2-utils          2.2.3-4+etch6    utility programs for webservers
ii  apache2.2-common       2.2.3-4+etch6    Next generation, scalable,</pre>
<p>If apache seems to be installed we will need to remove it to avoid conflicts on port 80.</p>
<pre class="brush:bash; gutter: false; toolbar:false">apt-get remove apache2-doc apache2-mpm-prefork apache2-utils apache2.2-common</pre>
<p>Now we will install MySQL (The &#8220;-y&#8221; parameter avoids questions during the install by answering &#8220;yes&#8221; to every question.</p>
<pre class="brush:bash; gutter: false; toolbar:false">apt-get install –y mysql-server mysql-client</pre>
<p>We start MySQL.</p>
<pre class="brush:bash; gutter: false; toolbar:false">/etc/init.d/mysql start</pre>
<p>We configure the MySQL root password.</p>
<pre class="brush:bash; gutter: false; toolbar:false">mysqladmin -u root password ''password_of_your_choice''</pre>
<p>After the succesfull installation of MySQL we continue the configuration by installing lighttpd.</p>
<pre class="brush:bash; gutter: false; toolbar:false">apt-get install -y lighttpd</pre>
<p>Just as a test we can now surf to the hostname or ip-address of your server to verify the succesfull installation.</p>
<p><img class="size-full wp-image-104 alignnone" title="lighttpd" src="http://www.dimitri.eu/wp-content/uploads/2009/10/lighttpd.jpg" alt="lighttpd" width="598" height="381" /></p>
<p>The default document root is /var/www/ and the configuration file is /etc/lighttpd/lighttpd.conf.</p>
<p>We will now install PHP5 as a fastCGI module, we will also add some other PHP5-modules so that these can also be addressed by PHP..</p>
<pre class="brush:bash; gutter: false; toolbar:false">apt-get install -y php5-cgi php5-mysql php5-curl ...</pre>
<p>After this installation we will need to modify the configuration files of PHP and lighttpd. In the PHP configuration file (eg. /etc/php5/cgi/php.ini) we add the following line (preferably at the end of the file.</p>
<pre class="brush:bash; gutter: false; toolbar:false">cgi.fix_pathinfo = 1</pre>
<p>In the lighttpd configuration file (/etc/lighttpd/lighttpd.conf) we modify &#8220;server.modules&#8221; by adding a new line</p>
<pre class="brush:bash; gutter: false; toolbar:false">"mod_fastcgi",</pre>
<p>At the end of this file we also need to add a few lines to tell the webserver that all files with the .php extension need to be handled by the FastCGI module.</p>
<pre class="brush:php; gutter: false; toolbar:false">fastcgi.server = ( ".php" =&gt;((
"bin-path" =&gt; "/usr/bin/php5-cgi",
"socket" =&gt; "/tmp/php.socket"
)))</pre>
<p>After saving this configuration file we can restart the lighttpd service.</p>
<pre class="brush:bash; gutter: false; toolbar:false">/etc/init.d/lighttpd restart</pre>
<p>We can now test be creating a basic php-file like info.php with the following content</p>
<pre class="brush:php; gutter: false; toolbar:false">&lt;?php phpinfo(); ?&gt;</pre>
<p>We can now witness a working lighttpd webserver with PHP5 loaded.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dimitri.eu/how-to-configure-lighttpd-with-php5-and-mysql5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

