This is a short tutorial on how to setup an lighttpd server with php5 and mysql on a raspberry pi under debian.
Of course, most parts of it can be used for any other Debian or Ubuntu System as well.
- You need a running Debian System on your Raspberry. You can find instructions on how to setup your raspberry here: Beginners Guide
- Start your Raspberry with a display and keyboard connected (or use SSH instead)
- If this is your first boot, you may want to expand the Root-Filesystem to fill the SD-Card, you can do this using the Configuration Tool, which should automatically start on first boot. If it doesn’t, run:
- Using the Tool, activate SSH-Server if you want to remotely manage your raspberry
- If you only want to run a webserver on your Raspberry and don’t need any graphics, set the memory for the graphic card to ‘0’ using the ‘memory_split’ option. This will give you more RAM for the CPU, since it’s not given to the GPU. You may also want to deactivate ‘Start desktop on boot’, since it’s not required for the webserver
- Update the package database and upgrade existing packages:
sudo apt-get update && sudo apt-get upgrade
- Install lighttpd, php5 and mysql:
sudo apt-get install lighttpd php5 php5-common php5-cgi mysql-server mysql-client
- Open ‘/etc/php5/cgi/php.ini’ using
sudo nano /etc/php5/cgi/php.ini
- Find the line
and uncomment it (delete the semicolon)
- Open ‘/etc/lighttpd/lighttpd.conf’ using
sudo nano /etc/lighttpd/lighttpd.conf
to the server.modules section
fastcgi.server=(".php"=>(( "bin-path"=>"usr/bin/php-cgi", "socket"=>"/tmp/php.socket" )))
- If you want, install additional php5 modules:
sudo apt-get install php5-mysql php5-curl php5-gd php5-idn 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-common
You should now have a running lighttpd webserver with php5 and mysql.
Place your .html and .php files to ‘/var/www’