{"id":250,"date":"2011-03-04T23:14:04","date_gmt":"2011-03-04T23:14:04","guid":{"rendered":"http:\/\/www.muratyaman.co.uk\/wp\/?p=250"},"modified":"2020-04-01T11:57:45","modified_gmt":"2020-04-01T10:57:45","slug":"php-fastcgi-on-lighttpd","status":"publish","type":"post","link":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/2011\/03\/php-fastcgi-on-lighttpd\/","title":{"rendered":"PHP FastCGI on LightTPD"},"content":{"rendered":"<p>Recently, I&#8217;ve been having issues with <strong>php-cgi.exe<\/strong> crashing on Apache 2.2 and IIS7 on Windows 2008. So, I&#8217;ve been searching for alternative ways of running my PHP application.<\/p>\n<p>I came across <a href=\"http:\/\/nginx.org\/\">nginx<\/a> and <a href=\"http:\/\/www.lighttpd.net\/\">lighttpd<\/a>.<\/p>\n<p>Let&#8217;s try LightTPD 1.4.28 and PHP 5.3.5.<\/p>\n<p>Get the Windows binaries for LightTPD from WLMP project: <a href=\"http:\/\/en.wlmp-project.net\/downloads.php\">http:\/\/en.wlmp-project.net\/downloads.php<\/a>. I chose the ZIP package with SSL support.<\/p>\n<p>Get the Windows binaries for PHP from: <a href=\"http:\/\/windows.php.net\/download\/\">http:\/\/windows.php.net\/download\/<\/a>. I chose the ZIP package VC9 x86 Non-Thread-Safe.<\/p>\n<p>Uncompress them into drive C: so that we can have C:\\LightTPD and C:\\PHP .<\/p>\n<p>Go to C:\\LightTPD\\conf\\<br \/>\nEdit <strong>lighttpd-srv.conf<\/strong>. Change file relative paths to absolute paths to read:<\/p>\n<pre lang=\"ini\">\r\nserver.errorlog      = \"c:\/lighttpd\/logs\/lighttpd-srv.error.log\"\r\naccesslog.filename   = \"c:\/lighttpd\/logs\/lighttpd-srv.access.log\"\r\nserver.pid-file       = \"c:\/lighttpd\/logs\/lighttpd-srv.pid\"\r\ninclude \"c:\/lighttpd\/conf\/lighttpd-tag.conf\"\r\ninclude \"c:\/lighttpd\/conf\/lighttpd-inc.conf\"\r\n<\/pre>\n<p>Edit <strong>lighttpd-inc.conf<\/strong>.<br \/>\nEnable <strong>mod_fastcgi<\/strong> among server.modules and check following settings:<\/p>\n<pre lang=\"ini\">\r\nserver.document-root = \"C:\/LightTPD\/htdocs\/\"\r\nserver.upload-dirs = \"C:\/LightTPD\/tmp\/\"\r\nfastcgi.server = ( \".php\" =>\r\n    (\"localhost\" => (\"host\" => \"127.0.0.1\", \"port\" => 521 ) )\r\n)\r\n<\/pre>\n<p>Go to C:\\LightTPD\\htdocs<br \/>\nCreate <strong>phpinfo.php<\/strong> with content:<\/p>\n<pre lang=\"php\">\r\n<?php phpinfo(); ?>\r\n<\/pre>\n<p>Go to C:\\PHP.<br \/>\nHave a copy of php.ini-production as <strong>php.ini<\/strong>.<\/p>\n<p>Run PHP CGI:<\/p>\n<pre lang=\"dos\">\r\nC:\\PHP>php-cgi.exe -b 127.0.0.1:521\r\n<\/pre>\n<p>Run LightTPD:<\/p>\n<pre lang=\"dos\">\r\nC:\\LightTPD>LightTPD.exe -f conf\\lighttpd-srv.conf -m lib\r\n<\/pre>\n<p>Go to:<br \/>\n<a href=\"http:\/\/localhost\/phpinfo.php\">http:\/\/localhost\/phpinfo.php<\/a><\/p>\n<p>Voila!<\/p>\n<p>It is definitely worth trying. Consider modifying the config files so that LightTPD can quickly serve static files such as HTML, CSS, JavaScript, JPEG, PNG files; and PHP files are passed to the CGI application or service for further processing. Also consider the process recycling settings, which is mainly affected by setting the number of requests served before the process is killed.<\/p>\n<p><strong>References:<\/strong><br \/>\n<a href=\"http:\/\/php.net\/\">http:\/\/php.net\/<\/a><br \/>\n<a href=\"http:\/\/www.lighttpd.net\/\">http:\/\/www.lighttpd.net\/<\/a><br \/>\n<a href=\"http:\/\/redmine.lighttpd.net\/wiki\/1\/TutorialLighttpdAndPHP\">http:\/\/redmine.lighttpd.net\/wiki\/1\/TutorialLighttpdAndPHP<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently, I&#8217;ve been having issues with php-cgi.exe crashing on Apache 2.2 and IIS7 on Windows 2008.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[39,68,193,54,26,124],"class_list":["post-250","post","type-post","status-publish","format-standard","hentry","category-technology","tag-apache","tag-fast-cgi","tag-iis","tag-lighttpd","tag-php","tag-windows"],"_links":{"self":[{"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/posts\/250","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=250"}],"version-history":[{"count":10,"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/posts\/250\/revisions"}],"predecessor-version":[{"id":898,"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/posts\/250\/revisions\/898"}],"wp:attachment":[{"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=250"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=250"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=250"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}