Contents

Introduction

The board may not look that powerful but there is more than enough grunt to run a small web server supported by php and mysql. I have not covered this here but have also installed wordpress on the server and runs very well too.

This HOWTO is based on the Debian build and has been tested on the first and second release.

Please note you are required to check security setting and access to the server, this is a guide on getting to the first point of having a working server and first few pages.

Install Process

Installing Lighttpd

Lighttpd is one of the smallest web server around and ideal for the raspberry Pi as its uses very little memory.

First you need to set up a group and user that the web server can use:
sudo addgroup --system www-data
sudo adduser www-data www-data
Next run the install, this will take a few moments:
sudo apt-get install lighttpd
You can check that the server is installed correctly by typing:ps -u www-data u

The main web server is now installed and can be checked by opening a browser and entering the address of your server and checking Lighttpd's default information page:http://[your raspberry pi address]/index.lighttpd.html

NOTE: Your web sites files are located at /var/www/

However you will also need php and mysql to get the best out of a web site...

Installing php5 and mySQL

This is much bigger than the web server alone so is going to take some time to download and install... for me it was around 10 mins.

These can both be installed in one go by running the following:sudo apt-get install mysql-server php5-cgi php5-mysql

NOTE: During the install you will be asked for a password for accessing mySQL with. As this will be for root access I suggest something you will not forget! You will need it again at some point!

The apt-get program will have left the downloads on your server and these take up space. If you want to remove them (as its now all installed) you can run the following to remove all apt-get download files:sudo apt-get clean

Configuration and Setting Up

Configuration of Lighttpd

To access the PHP server, your web server needs to know where its installed. I'll also add a Error 404 handler as there is nothing worse than a visitor getting a Error 404 from your site!

To turn on the cgi mod of the server type the following:sudo lighty-enable-mod cgi

I think this did more than create a configuration file but found I had to remove the mod and add the php setting directly in the Lighttpd configuration file as follows:-

First remove the cgi reference in the cgi config file by adding a '#' to the start of the line. Edit the file as follows:sudo pico /etc/lighttpd/conf-enabled/10-cgi-php.conf

change line to read as follows:#server.modules +=("mod_cgi")

To 'SAVE' changes press Ctrl-O and [enter] followed by Ctrl-X and [enter].

Now edit the main configuration files as follows:sudo pico /etc/lighttpd/lighttpd.conf

Add the following line to the server modules section:"mod_cgi",

Add the following to the end of the file:cgi.assign = (".php" => "/usr/bin/php5-cgi")
server.error-handler-404 = "/index.html"
To 'SAVE' changes press Ctrl-O and [enter] followed by Ctrl-X and [enter].

The first line added enables the cgi module, the second points to the php-cgi server if a .php file is accesses and the last is our Error 404 handler.

You can set the file names to any page you want, I just set it to index.html as a default.

Last thing to do in the configuration is to restart the server as follows:sudo /etc/init.d/lighttpd force-reload

Setting Up and Test

I would suggest you may want to check the php service is working ok by creating a quick .php file:sudo pico /var/www/phpinfo.php

And add the following lines:
<?php
phpinfo();
?>

Now as before use a browser to open your raspberry pi and access phpinfo.phphttp://[your raspberry pi address]/phpinfo.php