I'm currently working on building an online sports logbook with cakePHP. I wanted to be able to test the software locally, without the whole bother of setting up a real heavy duty server. My setup involves using:
- Lighttpd as the webserver
- PHP 5
- MySQL
I now have a light web server running on my computer permanently, and don't notice any performance issues whatsoever (It uses around 0.1MB Ram and virtually no CPU when idle).
Here's a quick guide to setting this up:
Install the necessary packages:
sudo apt-get install lighttpd php5-cgi mysql-server mysql-client
If you haven't ever used mysql you will be asked to define an admin password, which you should remember.
Next, configure lighhttpd: edit /etc/lighttpd/lighttpd.conf:
My server modules section looks such:
server.modules = (
"mod_alias",
"mod_compress",
"mod_rewrite",
"mod_fastcgi",
"mod_access"
)
I also edited the webroot to be in my home folder (/home/XXX/webroot), however it is necessary to change the owner or group for this folder to "www-data". What I did was:
sudo chgroup -R www-data /home/XXX/webroot/
and also added group read/write permissions to /home/XXX/webroot/
Back to the config file: I added the following section to enable php:
fastcgi.server = ( ".php" =>
( "localhost" =>
( "socket" => "/tmp/php5-fcgi.socket",
"bin-path" => "/usr/bin/php5-cgi"
,"allow-x-send-file" => "enable"
)
)
)
Since I only want local network computers to be able to access the server (127.0.0.1 is localhost, 127.0.1.1 is what you get if you query your hostname -- at least under Ubuntu):
$HTTP["remoteip"] !~ "192.168.1.[0123456789]{1,3}|127.0.1.1|127.0.0.1" {
url.access-deny = ( "" )
}
Lastly, since I installed cake in a folder called cake, I added:
url.rewrite-once = ("/cake/(css|files|img|js|stats)/(.*)" => "/cake/app/webroot/$1/$2",
"^/cake/([^.]+)$" => "/cake/app/webroot/index.php?url=$1" )
This does the same job as the .htaccess files, which lighttpd doesn't support (there's a reason for this lack of "support", it speeds up the server -- hence the name lighttpd).
Once you have modified the configuration, run sudo /etc/init.d/lighttpd restart to restart the server / reload the config.
Now you just need to install cakephp, i.e. unpack it into webroot/cake.
Finally, you will want some databases: install mysql-admin (note: not the same as mysqladmin) with sudo apt-get install mysql-admin (of course, if you are so predisposed, then you can set up your databases using shell commands...). Next run this, and login with the above created password, with username root, host localhost. Create a new database under Catalogues (to add a database go to the bottom left window and right click), then add a user (note the password), and finally edit the user's "Schema-Privileges": select the new database, and add the necessary permissions, I just added all permissions.
Now, follow the cakephp installation instructions, and use the new sql user and database detailed above for the database connection.
In actual fact, you get a lot of bang for your buck with this set up, you now have a proper web server on your computer which doesn't get in the way, yet is remarkably versatile. I've programmed a print-interface meaning any computers on the network can print by entering my (local) IP using their browser, without having to install drivers (There was an issue with one of the netbooks not wanting to accept the HP drivers for our printer -- Windows bugs be thanked...).