This is an old revision of the document!


Installing lighttpd/PHP/MySQL on TonidoPlug

Want to turn your plug into a web server? This guide will show you how to install a lightweight, standards-compliant web server (lighttpd) that supports PHP and MySQL, and is flexible enough to power most web apps.

1. SSH into your plug:

$ ssh root@<ipaddress>

2. After that, you will want to “fix” apt-get by issuing the following command as root:

# mkdir -p /var/cache/apt/archives/partial

3. Install MySQL: Issue the following command as root, and when prompted, supply a password for the MySQL root user:

# apt-get install mysql-server mysql-client

4. Install lighttpd: Issue the following command as root:

# apt-get install lighttpd

After that is done installing, you should be able to connect to your plug from your local network using it’s IP address. Open up a browser, navigate to your plug’s IP to ensure that it’s working. On Ubuntu (which the TonidoPlug runs), the default web directory is /var/www, and the configuration file is /etc/lighttpd/lighttpd.conf.

5. Install PHP: Issue the following command as root to install a FastCGI-enabled version of PHP and MySQL support:

#apt-get install php5-cgi php5-mysql

You may wish to install other php5 modules at this time as well, if you think they’ll be needed by your server. You can always do this later.

After PHP is installed, open up /etc/php5/cgi/php.ini in your favorite text editor (I prefer joe, which is available with a simple apt-get install joe) and add the following line to the bottom of the file:

cgi.fix_pathinfo = 1

6. Enable PHP support in lighttpd: Issue the following command as root:

# lighttpd-enable-mod fastcgi

This will enable the FastCGI module in lighttpd. Now you need to restart lighttpd to get it to reload the modules.

# /etc/init.d/lighttpd restart

If all goes well, you should now have a server with MySQL and PHP support. You may wish to test this by placing a info.php file in your /var/www directory with the following contents:

info.php
<?php
phpinfo();
?>

Access the file using a web browser pointed to <ipaddress>/info.php, where <ipaddress> is the internal IP address of your TonidoPlug. You should see a large listing of various PHP settings, with a section called MySQL.

Congratulations, you now have a fully working PHP/MySQL web server! Be sure to forward port 80 on your router to your TonidoPlug if you intend to use this to host a website.