Wednesday, February 20, 2013

Raspberry Pi as webserver

Now I want to setup a small webserver on my raspberry pi. First we have to choose an appropriate lightweight webserver, because a standard Apache installation seems to big & overkill.
Two small webserver, which seem to be very good and also widely used are:
I heard a lot of good things about nginx, mainly its speed and rewriting abilities, but I decided to use lighttpd just because I found good instructions for it first. Installing:
 sudo apt-get install lighttpd
Configuration:
sudo nano /etc/lighttpd/lighttpd.conf
Check that the following modules are enabled:
server.modules = (
            "mod_access",
            "mod_alias",
            "mod_accesslog",
            "mod_auth",
            "mod_ssi",
            "mod_cgi",
            "mod_compress",
            "mod_fastcgi",
            "mod_rewrite",
            "mod_magnet",
)
The web root dir should be "/var/www/" and the user which runs lighttpd is "www-data" - no need to change anything here.
Lighttpd should be already running. You can start/stop/restart the service with:
sudo /etc/init.d/lighttpd start
sudo /etc/init.d/lighttpd stop
sudo /etc/init.d/lighttpd restart
Now create a file "/var/www/index.html" with some html code, open a Browser and go to "http://<yourIP>/index.html". VoilĂ .

No comments: