How to Install Lighttpd With PHP5 (FastCGI) And MySQL On Linux Mint 12 / Ubuntu 11.10


Security, speed, compliance, and flexibility — all of these describe lighttpd (pron. lighty) which is rapidly redefining efficiency of a web server; as it is designed and optimized for high performance environments. With a small memory footprint compared to other web-servers, effective management of the cpu-load, and advanced feature set (FastCGI, SCGI, Auth, Output-Compression, URL-Rewriting and many more) lighttpd is the perfect solution for every server that is suffering load problems. And best of all it’s Open Source licensed under the revised BSD license.


Here i will explain you the installation of Lighttd with PHP and MySQL on Linux Mint 12.

Installing Lighttpd:

To start off we will install Lighttpd.

Type following Command on the Terminal and then press enter.

raj@geeksite~/$ sudo apt-get install lighttpd

Start the Lighttpd by using the following command.

raj@geeksite~/$ sudo /etc/init.d/lighttpd restart

Testing Lighttpd:

To make sure everything installed correctly we will now test Lighttpd to ensure it is working properly. Open up any web browser and then enter the following into the web address:  or  https://your.ip.addr.ess/index.lighttpd.html

You should see the Lighttpd Placeholder page, lighttpd’s default document root is /var/www/ on Ubuntu / Linux Mint; the configuration file is /etc/lighttpd/lighttpd.conf and additional configurations are stored in the /etc/lighttpd/conf.available/ directory.

Installing MySQL:

Next is to install the MySQL server and client, both are available in Linux Mint repository; just issue the following command to install it.

raj@geeksite~/$ sudo apt-get install mysql-server mysql-client php5-mysql

After the installation it will ask you to configure the MySQL root password, so just enter the password.

Re-enter the password to confirm.

Installing PHP:

Next is to install PHP 5 on Ubuntu with FastCGI. Ubuntu / Linux Mint provides a FastCGI-enabled PHP5 package. We can install by issuing the following command.

raj@geeksite~/$ sudo apt-get install php5-cgi

Configuring PHP5 and Lighttpd:

To enable PHP5 in Lighttpd, you will have to modify the configuration file /etc/php5/cgi/php.ini and uncomment the line cgi.fix_pathinfo=1:

raj@geeksite~/$ sudo gedit /etc/php5/cgi/php.ini 


 ; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI. PHP's
 ; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok
 ; what PATH_INFO is. For more information on PATH_INFO, see the cgi specs. Setting
 ; this to 1 will cause PHP CGI to fix its paths to conform to the spec. A setting
 ; of zero causes PHP to behave as before. Default is 1. You should fix your scripts

To enable the FastCGI configuration (which is stored in /etc/lighttpd/conf-available/10-fastcgi.conf), run the following command:

raj@geeksite~/$ sudo lighttpd-enable-mod fastcgi
raj@geeksite~/$ sudo lighttpd-enable-mod fastcgi-php

To reload the server for changes to take place, type in the terminal.

raj@geeksite~/$ sudo /etc/init.d/lighttpd force-reload

Testing PHP:

For testing the PHP, Place one PHP file on to the default directory of the Lighttpd.

In the terminal copy/paste the following line:

raj@geeksite~/$ sudo gedit /var/www/info.php

This will open up a file called phpinfo.php.

Copy/Paste this line into the info file:

<?php phpinfo(); ?>

 Save and close the file.

 Now open you’re web browser and type the following into the web address: or https://your.ipadd-ress/info.php

The page will look like below:

As you see in the screenshot, PHP5 is working fine, and it is working through FastCGI, as shown in theServer API line. If you scroll further down, you will see all modules  that are already enabled in PHP5; look the support information of MySQL.

Now your web server is ready for working.

You might also like