Setup Raspberry Pi LigHTTPd Webserver

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.

 

  1. You need a running Debian System on your Raspberry. You can find instructions on how to setup your raspberry here: Beginners Guide
  2. Start your Raspberry with a display and keyboard connected (or use SSH instead)
  3. 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:
    raspi-config
  4. Using the Tool, activate SSH-Server if you want to remotely  manage your raspberry
  5. 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
  6. Update the package database and upgrade existing packages:
    sudo apt-get update && sudo apt-get upgrade
  7. Install lighttpd, php5 and mysql:
    sudo apt-get install lighttpd php5 php5-common php5-cgi mysql-server mysql-client
  8. Open ‘/etc/php5/cgi/php.ini’ using
    sudo nano /etc/php5/cgi/php.ini
  9. Find the line
    ;cgi.fix_pathinfo=1

    and uncomment it (delete the semicolon)

  10. Open ‘/etc/lighttpd/lighttpd.conf’ using
    sudo nano /etc/lighttpd/lighttpd.conf
  11. Add
    mod_fastcgi

    to the server.modules section

  12. Add
    fastcgi.server=(".php"=>((
    "bin-path"=>"usr/bin/php-cgi",
    "socket"=>"/tmp/php.socket"
    )))
  13. 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’

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: