Web Server Setup

This web site is being hosted from a Raspberry Pi using Lighttpd

I put my web server on the same RPi that I use as a NAS but it's not required to do that.
Having a NAS (Samba) set up on the RPi is nice as you can directly access your web files. If not then unless you are creating web pages on the RPi, you would have to configure FTP and upload your changes. Or transfer files to the web directory on your RPi using a thumb drive.

I pretty much followed the tutorial here:
http://www.penguintutor.com/linux/light-webserver

With the exception that I did not set my router and the RPi to use static IP.  Instead I set up my router for IP to MAC Reservations. Much easier.
Also read the Port Forwarding section which must be done as well.

These are the commands to get everything going.
If you just want a plain web page server then do only steps 1, 7, 8, 9.
If you need SQL and PHP support then do all steps in the order shown. (Steps 2-6 must be done in the order shown).

  1. sudo apt-get install lighttpd
  2. sudo apt-get install mysql-server
  3. sudo apt-get install php5-common php5-cgi php5
  4. sudo apt-get install php5-mysql
  5. sudo lighty-enable-mod fastcgi-php
  6. sudo service lighttpd force-reload
  7. sudo chown www-data:www-data /var/www
  8. sudo chmod 775 /var/www
  9. sudo usermod -a -G www-data pi
/var/www/ is where you will put your HTML files and images etc.
Once your files are placed there you are live......

The Lighttpd config file is located here: /etc/lighttpd/lighttpd.conf
The file will look something like this:

-------------------------------------------------------------------------------------
server.document-root        = "/var/www"
server.upload-dirs              = ( "/var/cache/lighttpd/uploads" )
server.errorlog                   = "/var/log/lighttpd/error.log"
server.pid-file                    = "/var/run/lighttpd.pid"
server.username                = "www-data"
server.groupname             = "www-data"
server.port                         = 86


index-file.names            = ( "index.php", "index.html", "index.lighttpd.html$
url.access-deny             = ( "~", ".inc" )
server.modules = (
        "mod_access",
        "mod_alias",
        "mod_compress",
        "mod_redirect",
#       "mod_rewrite",
)
--------------------------------------------------------------------------------------

In the above file, I have changed my server port to 86 from the standard 80.
If you use a non standard port like I have then your URL must have the port number specified.
In my case:
http://64.13.91.137:86

You could also change the server.document-root to somewhere else such as a connected hard disk.



BACK