This tutorial shows you how to setup lighttpd with php5-cgi and mysql-server on debian.
lighttpd runs with a small amount of ram, in this case I’ll setup the server on a 64mb ram bandwagonhost vps.
1. Installing lighttpd with php5-cgi and mod_evasive
At first, we install lighttpd, php5-cgi and a couple of other modules:
apt-get install lighttpd php5-cgi php5-common
Now let’s configure the lighttpd server, we’ll also add some rate limiting just to prevent small http-floods to take down the server:
Let’s add mod_fastcgi to the config to enable php and mod_evasive to add a small flood protection:
server.modules = ( "mod_access", "mod_alias", "mod_compress", "mod_fastcgi", "mod_evasive", "mod_redirect", # "mod_rewrite", )
At the end of the file add:
evasive.max-conns-per-ip = 3 fastcgi.server = ( ".php" => (( "bin-path" => "/usr/bin/php5-cgi", "socket" => "/tmp/php.socket" )))
Let’s check if php is working. Create a php info file:
echo "<?PHP phpinfo (); ?>" > /var/www/info.php
Now open http://yourip/info.php and see if the php-information is displayed.
2. Installation/Configuration of mysql-server
Let’s also install mysql-server and get a config which uses a small amount of memory.
apt-get install mysql-server
During the installation-process a window pops up that wants you to choose a password for the root mysql user.
Let’s use a small mysql-config to keep memory-usage low:
cp /usr/share/doc/mysql-server-5.*/examples/my-small.cnf /etc/mysql
Backup your old mysql config and replace it with the new one:
cd /etc/mysqlmv my.cnf my.cnf.backupmv my-small.cnf my.cnf
Now restart the mysql-server:
service mysql restart
Let’s check the memory-usage in htop:
Looks good, doesn’t it?
That’s it, now you got a webserver with php and mysql running on your lowendbox.