Thursday, November 22, 2012

Install Lighttpd, PHP5, MySQL on Raspberry Pi

To run a 'typical' server on Raspberry Pi, a Web server is necessary. If possible, it can run application (by PHP5, Java, Perl, Python, etc...). Apache may be the most famous web server, but here I choose Lighttpd is it is not as big as Apache. In fact, a lightweight server is more suitable. Also, it will use FastCGI to run PHP and Python, I will list out what applications/ services to be run on this server.

Finally Mysql is also a popular DB. At the beginning I don't want to install it as there may be a huge overhead on the Pi. In fact, some embedded DB such as sqlite would be a better option. However, there are still applications which only official support Mysql, so at last I decide to install it and hopefully can fine-tune it later.

So here is the steps...

Install Lighttpd and PHP5

  1. Login as root
  2. create the user and group "www-data"
  3. Install the following packages:
    • apt-get update (get the latest repository)
    • apt-get install lighttpd php5-cgi
After installation, check the /etc/lighttpd/lighttpd.conf
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
it will includes setting under /etc/lighttpd/conf-enabled. Make sure there is something like "fastcgi" and "fastcgi-php". (The settings can be fine tuned afterwards)
# ls /etc/lighttpd/conf-enabled/
10-fastcgi.conf  15-fastcgi-php.conf

Install Mysql

just install the packages "mysql-server", "php5-mysql"

No comments: