{"id":161,"date":"2008-11-10T23:18:21","date_gmt":"2008-11-10T17:48:21","guid":{"rendered":"http:\/\/www.bin-co.com\/blog\/?p=161"},"modified":"2008-11-10T23:18:21","modified_gmt":"2008-11-10T17:48:21","slug":"installing-lighttpd-web-server-in-linux-with-php-and-mysql","status":"publish","type":"post","link":"https:\/\/www.bin-co.com\/blog\/2008\/11\/installing-lighttpd-web-server-in-linux-with-php-and-mysql\/","title":{"rendered":"Installing lighttpd Web Server in Linux with PHP and MySQL"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.bin-co.com\/blog\/wp-content\/uploads\/2008\/11\/lighttpd_logo-1-1.png\" alt=\"lighttpd Web Server\" title=\"Lighttpd Logo\" width=\"200\" height=\"197\" class=\"alignnone size-full wp-image-160 intro\" align=\"right\" \/><\/p>\n<p class=\"intro\">After <a href=\"http:\/\/www.bin-co.com\/blog\/2008\/09\/installing-lampapache-web-serverphpmysql-in-debian\/\" title=\"Installing LAMP(Apache Web Server\/PHP\/MySQL) in Debian\">two articles<\/a> on <a href=\"http:\/\/www.bin-co.com\/blog\/2008\/09\/compile-install-lamp-linux-apache-mysql-php-server-from-source\/\" title=\"Compile and Install a LAMP(Linux\/Apache\/MySQL\/PHP) Server from Source\">installing Apache<\/a>, lets take a look at <strong class=\"highlight\">installing and configuring lighttpd web server on a linux system<\/strong>. <a href=\"http:\/\/www.lighttpd.net\/\">lighttpd<\/a> (pronounced &#8220;lighty&#8221;) is a web server designed to be secure, fast, standards-compliant and flexible while having a low memory footprint.<\/p>\n<p>Before installation, a few points to remember. These <strong class=\"highlight\">instruction are not for a production environment &#8211; this is for a development environment<\/strong>. To install the software, <strong class=\"highlight\">you need root access<\/strong>. You can get that using this command&#8230;<\/p>\n<pre><code class=\"cli\">su -\n[Enter root password]<\/code><\/pre>\n<p>or by prefixing &#8216;<code>sudo<\/code>&#8216; before each command.<\/p>\n<h2>Installing the Server<\/h2>\n<p>First install lighttpd and PHP &#8211; use your distro&#8217;s package management(yum, apt-get) system to do this.<\/p>\n<h3>Install lighttpd<\/h3>\n<p>You can use this command in Red Hat based systems(Fedora, Cent OS, etc.) to install lighttpd. Debian\/Ubuntu systems might the same package name &#8211; could someone post the package name of lighttpd in the comments?<\/p>\n<pre><code class=\"cli\">yum install lighttpd lighttpd-fastcgi<\/code><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.bin-co.com\/blog\/wp-content\/uploads\/2008\/09\/php-logo-1-1.png\" alt=\"PHP Logo\" title=\"PHP Logo\" width=\"179\" height=\"98\" class=\"alignnone size-full wp-image-123\" align=\"right\" \/><\/p>\n<h3>Install PHP<\/h3>\n<p>If you don&#8217;t have PHP, you can install it using the command&#8230;<\/p>\n<pre><code class=\"cli\">yum install php php-cli php-common<\/code><\/pre>\n<p>In Debian\/Ubuntu systems, the command is&#8230;<\/p>\n<pre><code class=\"cli\">apt-get install php5-cli php5-common php5-cgi<\/code><\/pre>\n<p>You can make sure you have php-cgi(needed for working with lighttpd) by running this command&#8230;<\/p>\n<pre><code class=\"cli\">php-cgi -v<\/code><\/pre>\n<h3>Installing MySQL<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.bin-co.com\/blog\/wp-content\/uploads\/2008\/09\/mysql_logo.gif\" alt=\"\" title=\"MySQL Logo\" width=\"150\" height=\"98\" class=\"alignnone size-full wp-image-127\" align=\"right\" \/><\/p>\n<p>If MySQL is not yet installed, use this command to install it&#8230;<\/p>\n<pre><code class=\"cli\">yum install mysql-server php-mysql mysql mysql-libs<\/code><\/pre>\n<p>Debian\/Ubuntu Command&#8230;<\/p>\n<pre><code class=\"cli\">apt-get install mysql-client mysql-common mysql-server php5-mysql<\/code><\/pre>\n<h2>Configuring lighttpd<\/h2>\n<p>lighttpd configuration is done by <strong class=\"highlight\">editing the text file &#8216;\/etc\/lighttpd\/lighttpd.conf&#8217;.<\/strong><\/p>\n<p><strong class=\"highlight\">Enable some lighttpd modules<\/strong> by removing the comment character(#) from the beginning of the line. I have enabled the following modules&#8230;<\/p>\n<pre><code class=\"conf\">server.modules              = (\n                                \"mod_rewrite\",\n                                \"mod_redirect\",\n                                \"mod_access\",\n                                \"mod_fastcgi\",\n                                \"mod_accesslog\" )\n<\/code><\/pre>\n<p><strong class=\"highlight\">Configure lighttpd&#8217;s document root<\/strong> &#8211; if you already have Apache, I would recommend using the same document root as Apache(applicable for development servers only). <\/p>\n<pre><code class=\"conf\">server.document-root        = \"\/var\/www\/\"<\/code><\/pre>\n<p>I find it helpful to <strong class=\"highlight\">enable folder listing<\/strong> in my server.<\/p>\n<pre><code class=\"conf\">## virtual directory listings\ndir-listing.activate       = \"enable\"<\/code><\/pre>\n<h3>Turn On FastCGI PHP Support<\/h3>\n<p>Now, make sure lighttpd works with PHP &#8211; first get the path of php-cgi using the command..<\/p>\n<pre><code class=\"cli\">$ whereis php-cgi\nphp-cgi: \/usr\/bin\/php-cgi #Might be different on your system.<\/code><\/pre>\n<p>Then <strong class=\"highlight\">add the path to the configuration file<\/strong> of lighttpd&#8230;<\/p>\n<pre><code class=\"conf\">#### fastcgi module\n## read fastcgi.txt for more info\n## for PHP don't forget to set cgi.fix_pathinfo = 1 in the php.ini\nfastcgi.server             = ( \".php\" =>\n                               ( \"localhost\" =>\n                                 (\n                                   \"socket\" => \"\/tmp\/php.socket\",\n                                   <strong class=\"highlight\">\"bin-path\" => \"\/usr\/bin\/php-cgi\"<\/strong>\n                                 )\n                               )\n                            )<\/code><\/pre>\n<p>Make sure you <strong class=\"highlight\">uncomment the above lines<\/strong> by removing the &#8216;#&#8217; characters.<\/p>\n<p>After you are done, <strong class=\"highlight\">save the file<\/strong>. Time to try out the server.<\/p>\n<h2>Starting the lighttpd Server<\/h2>\n<p>First stop Apache if it is running&#8230;<\/p>\n<pre><code class=\"cli\">\/etc\/init.d\/httpd stop<\/code><\/pre>\n<p>Now start lighttpd using the command<\/p>\n<pre><code class=\"cli\">\/etc\/init.d\/lighttpd start<\/code><\/pre>\n<p>Go to your document root(<code>\/var\/www<\/code>) and <strong class=\"highlight\">create a php files called &#8216;info.php&#8217; and put this code<\/strong> inside it&#8230;<\/p>\n<pre><code class=\"php\">&lt;?php\nphp<!-- wordpress bug workaround -->Info();<\/code><\/pre>\n<p>Now fire up a browser and <strong class=\"highlight\">go to <a href=\"http:\/\/localhost\/\" title=\"Might not work if the preceding instructions where not followed\">localhost<\/a><\/strong> &#8211; you should see a file listing page with a \u2018info.php\u2019 in the list. Click on that link &#8211; if you see a PHP information page, your web server is setup correctly.<\/p>\n<p>To make sure MySQL-PHP connection is working, <a href=\"http:\/\/www.bin-co.com\/database\/clients\/phpmyadmin\/installing_phpmyadmin.php\" title=\"Installing phpMyAdmin 2.8\">install phpMyAdmin<\/a> &#8211; or write a database connection script &#8211; whatever is easier for you.<\/p>\n<h2>Related Links<\/h2>\n<ul>\n<li><a href=\"http:\/\/www.lighttpd.net\/\">lighttpd fly light<\/a><\/li>\n<li><a href=\"http:\/\/en.wikipedia.org\/wiki\/Lighttpd\">lighttpd &#8211; Wikipedia<\/a><\/li>\n<li><a href=\"http:\/\/cssgallery.info\/lighttpd-install-perl-mysql-support-in-chrooted-jail\/\">Lighttpd install perl, mysql support in chrooted jail<\/a><\/li>\n<li><a href=\"http:\/\/www.cyberciti.biz\/tips\/lighttpd-php-fastcgi-configuration.html\">Lighttpd PHP fastcgi configuration<\/a><\/li>\n<li><a href=\"http:\/\/www.cyberciti.biz\/tips\/howto-install-lighttpd-on-freebsd.html\">FreeBSD Install Lighttpd Web Server<\/a><\/li>\n<li><a href=\"http:\/\/fandar-it.com\/content\/view\/35\/32\/\">Install lighttpd with php<\/a><\/li>\n<li><a href=\"http:\/\/wiki.vpslink.com\/Install_and_Configure_lighttpd\">Install and Configure lighttpd<\/a><\/li>\n<li><a href=\"http:\/\/www.howtoforge.com\/lighttpd_php5_mysql_fedora7\">Installing Lighttpd With PHP5 And MySQL Support On Fedora 7<\/a><\/li>\n<\/ul>\n<p><strong class=\"highlight\">Shameless Plug<\/strong>: If you are a Linux user, you may want to check out my <a href=\"http:\/\/lindesk.com\/\" title=\"Lindesk - Linux on the Desktop\">Linux Blog &#8211; LinDesk<\/a> &#8211; its about Linux on the Desktop &#8211; Articles, Application Reviews and Tutorials about many aspects of Linux included configuration and scripting.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>After <a href=\"http:\/\/www.bin-co.com\/blog\/2008\/09\/installing-lampapache-web-serverphpmysql-in-debian\/\" title=\"Installing LAMP(Apache Web Server\/PHP\/MySQL) in Debian\">two articles<\/a> on <a href=\"http:\/\/www.bin-co.com\/blog\/2008\/09\/compile-install-lamp-linux-apache-mysql-php-server-from-source\/\" title=\"Compile and Install a LAMP(Linux\/Apache\/MySQL\/PHP) Server from Source\">installing Apache<\/a>, lets take a look at <strong class=\"highlight\">installing and configuring lighttpd web server on a linux system<\/strong>. <a href=\"http:\/\/www.lighttpd.net\/\">lighttpd<\/a> (pronounced &#8220;lighty&#8221;) is a web server designed to be secure, fast, standards-compliant and flexible while having a low memory footprint.<\/p>\n<\/div>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16,21,28,30],"tags":[92,147,167,173,210,252,289,297,312],"class_list":["post-161","post","type-post","status-publish","format-standard","hentry","category-linux","category-php","category-tutorial","category-web-development","tag-development","tag-install","tag-lighttpd","tag-linux","tag-php","tag-server","tag-tutorial","tag-web","tag-yum"],"_links":{"self":[{"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/posts\/161","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/comments?post=161"}],"version-history":[{"count":0,"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/posts\/161\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/media?parent=161"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/categories?post=161"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/tags?post=161"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}