Lighttpd is a popular event-based web server alternative to Nginx. Lighttpd can be used to serve high-traffic sites even on a small VPS.
Here, I will explain how to install Lighttpd with PHP 5 (PHP5-FPM) and MySQL on Ubuntu 14.04.
Install Lighttpd with the following commands.
sudo apt-get update
sudo apt-get install lighttpdThis will start Lighttpd once the installation finishes. You can test the status of the server by accessing the IP address of your VPS in a web browser. Upon success, you will see the Lighttp welcome page.
If the page does not load, you can force-restart the service.
sudo service lighttpd startInstall PHP5 with the following command.
sudo apt-get install php5-cgi php5-mysqlNote that the php5-mysql package is needed to use the MySQL Server with PHP.
Enable PHP5 CGI modules in Lighttpd with the following commands.
sudo lighty-enable-mod fastcgi
sudo lighty-enable-mod fastcgi-phpAfter enabling the modules, you need to restart the Lighttpd service.
sudo service lighttpd force-reloadTest the PHP integration with Lighttpd. To do this, create a test file inside the /var/www/ folder.
nano /var/www/info.phpPaste the following content into this file.
<?php phpinfo(); ?>Now, access http://[SERVER_IP]/info.php in your web browser. If the configuration was set up properly, you will see the PHP info page.
Run the following command to install the MySQL Server. During the installation, you need to give the administrator password for the MySQL root.
sudo apt-get install mysql-serverOnce the installation finishes, install a MySQL database.
mysql_install_dbAdditionally, you can use the secure MySQL installation by running the following command.
mysql_secure_installation