Lighttpd is a secure web server, which is faster when compared to Apache. We will show here how you can install Lighttpd on an Ubuntu 9.10 server with PHP5 support (through FastCGI) and MySQL support. In this tutorial we have used hostname as server1.example.com with the IP address 192.168.0.100. They maybe different for you. The first thing you need to do is to login as root. You can login as root in Ubuntu Linux by typing in the terminal: sudo su

Installing MySQL 5:

In the terminal type: aptitude install mysql-server mysql-client You will be asked to provide a password for MySQL user “root“. The same password will be valid for the user root@localhost as well as root@server1.example.com .

Installing Lighttpd on Ubuntu 9.10:

Lighttpd is already available as a pre-configured package in Ubuntu 9.10, so we can install it through terminal very easily. Type in the terminal: aptitude install lighttpd Now open your web browser and type http://192.168.0.100, and you should see the Lighttpd placeholder page:

The default document folder of Lighttpd for user root is /var/www/ on Ubuntu, and the configuration file is /etc/lighttpd/lighttpd.conf. Additional configurations are stored in files which are situated in the /etc/lighttpd/conf-available/ directory.

Installing PHP5

To enable PHP5 in Lighttpd, you will have to  modify the configuration file /etc/php5/cgi/php.ini. To edit it, type in the terminal: vi /etc/php5/cgi/php.ini Scroll down to the end of this file and add this line at the end of file: cgi.fix_pathinfo = 1 To enable the FastCGI configuration (which is stored in /etc/lighttpd/conf-available/10-fastcgi.conf), run the following command: lighttpd-enable-mod fastcgi To reload the server for changes to take place, type in the terminal: /etc/init.d/lighttpd force-reload

Installing MySQL 5 support:

To get MySQL support in PHP, we can install the php5-mysql package. But it is a good idea to install some other PHP5 modules together with MySQL as well, as you might need them for your applications. You can search for available PHP5 modules by typing in the terminal: aptitude search php5 Based on some of the packages that you select, you can install them with MySQL by typing in the terminal: aptitude install php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-json Now, again restart Lighttpd by typing: /etc/init.d/lighttpd restart

Testing your web server and PHP:

The document root for the default web server is /var/www. We will now create a small PHP file (info.php) in that directory and call it in a browser. The file will display lots of useful details about our PHP installation, such as the installed PHP version. To create this file, type in the terminal: vi /var/www/info.php Now type this code into this file: Save the file and close the terminal. Now we call this file in a browser by typing  http://192.168.0.100/info.php

As you see in the screenshot, PHP5 is working fine, and it is working through FastCGI, as shown in the Server API line. If you scroll further down, you will see all modules that are already enabled in PHP5.Now, your web server is ready for working. Hope this tutorial helps you in setting up a light and fast as well as a faster web server in Ubuntu 9.10. For more such tutorials, keep hooked onto TechPP.

How to Install Lighttpd with PHP5 and MySQL on Ubuntu 9 10 - 88How to Install Lighttpd with PHP5 and MySQL on Ubuntu 9 10 - 54How to Install Lighttpd with PHP5 and MySQL on Ubuntu 9 10 - 30How to Install Lighttpd with PHP5 and MySQL on Ubuntu 9 10 - 99How to Install Lighttpd with PHP5 and MySQL on Ubuntu 9 10 - 94How to Install Lighttpd with PHP5 and MySQL on Ubuntu 9 10 - 80How to Install Lighttpd with PHP5 and MySQL on Ubuntu 9 10 - 43