The point of this article is to demonstrate how to install and optimise Lighttpd, PHP5 and MySQL under Debian (My system runs ‘Etch’).
If you feel I’ve missed anything in this article, or have made an error, get in touch.
Ok, so let’s grab lighttpd, php and MySQL
apt-get install lighttpd php5-cgi php5-cli php5-mysql mysql-server
You may want to add any other php modules that you may require, such as php5-curl, php5-gd etc.
Next, as lighttpd automatically assumes you’re using php4, we need to update the fastcgi php path in:
/etc/lighttpd/conf-available/10-fastcgi.conf
Look for the line
"bin-path" => "/usr/bin/php4-cgi",
and replace it with
"bin-path" => "/usr/bin/php5-cgi",
Simple.
While you have the file open, change
"max-procs" => 2,
and
"PHP_FCGI_CHILDREN" => "2",
This will reduce the number of waiting fastcgi instances, thus reducing ram. If you have a particularly busy site, you may want to either leave this, or perhaps even increase it.
Now enable fastcgi module in lighttpd
lighty-enable-mod fastcgi
Restart lighttpd
/etc/init.d/lighttpd restart
You now have lighttpd running perfectly with php5.
You might now want to add some virtual hosts. For example purposes, we’ll call these foo.com and bar.net
Create your directory structure:
mkdir /home/sites/foo.com mkdir -p /home/sites/foo.com/http mkdir -p /home/sites/foo.com/logs mkdir /home/sites/bar.net mkdir -p /home/sites/bar.net/http mkdir -p /home/sites/logs
Give ownership of the logs directory to the web server
chown www-data /home/sites/foo.com/logs chown www-data /home/sites/bar.net/logs
Once we’ve done this, we can sort out the config side of things.
Open up
/etc/lighttpd/lighttpd.conf
Include the configuration files you’ll use for each of your domains
include "foo.com.conf" include "bar.net.conf"
Now open up
/etc/lighttpd/foo.com.conf
and add
$HTTP["host"] =~ "foo\.com" {
server.document-root = "/home/sites/foo.com/http"
accesslog.filename = "/home/sites/foo.com/logs/access.log"
}
and the same for
bar.net.conf
$HTTP["host"] =~ "bar\.net" {
server.document-root = "/home/sites/bar.net/http"
accesslog.filename = "/home/sites/bar.net/logs/access.log"
}
Again, restart lighttpd
/etc/init.d/lighttpd restart
and you’re done.
I simply altered some of it’s fine tuning values.
Open
/etc/mysql/my.cnf
and change the following values
key_buffer = 16K max_allowed_packet = 1M thread_stack = 64K thread_cache_size = 8 #max_connections = 100 table_cache = 4
Leave a Reply