Tiny Core Linux – Personal Web Server off a USB key

The logic: Keeping a computer the whole time to self-host my stuff has a cost so I wanted to explore some alternatives.I have an HP Thin Client (with Windows XP Embedded) that doesn’t have a hard drive (runs off Flash Memory) but can boot from USB.

After looking at SMS (Superb Mini Server – boot SMS is not the default option in the start up screen), Freenas/Nas4free (not really geared to run a web server), Puppy Linux (could have been a decent alternative), I settled on Tiny Core Linux – http://distro.ibiblio.org/tinycorelinux/

Very nifty piece of kit! I installed it on a USB using http://sourceforge.net/projects/core2usb/ and booted my Thin Client from the USB.

Some references to get started:

– Install SSH so I can remote from my laptop- http://myblog-kenton.blogspot.ie/2012/03/install-openssh-server-on-tiny-core.html 

– Install of packages via terminal – http://wiki.tinycorelinux.net/wiki:package_management_cheat_sheet

– For more, see http://wiki.tinycorelinux.net/wiki:start

I installed apache2, apache2-mod-php5 and mysql. PHP is enabled by default. In order to install web apps (WordPress, MyTinyToDo, Tiny Tiny RSS), the empty databases need to created before you can run the web installer so I had to dig out the manual for the mysql terminal commands (http://dev.mysql.com/doc/refman/5.0/en/mysql-command-options.html). It boils down to:

– Create an admin (first time run): mysqladmin -u root password “newpassword”

– Log in: mysql -u root -p

Enter Password

– CREATE DATABASE wordpress;

– exit

Let’s stick with the WordPress example, download the installer from the WordPress site, expand it under /usr/local/apache2/htdocs, start apache (sudo /usr/local/apache2/bin/apachectl start, edit first /usr/local/apache2/conf/httpd.conf if you want to use another port than default port 80 and add index.php to the DirectoryIndex directive) and access http://your.ip/wordpress/ to kick off the web installer.

Note, if you use xampp (available as a self-contained package .scm for Tiny Core Linux) instead of apache2/mysql native packages .tcz, the mysql.sock file isn’t created in the default /tmp/ directory but the one under the /opt/lampp directory structure, you need to create a symlink from that directory so the WordPress installer can find /tmp/mysql.sock (see http://stackoverflow.com/questions/4219970/warning-mysql-connect-2002-no-such-file-or-directory-trying-to-connect-vi).

OK, so you have it working. Now, you need to set up the persistence. Yes, Tiny Core Linux runs from RAM so if you shut down now, you will have lost all your changes.

So, 3 things to look at:

– Edit /opt/.filetool.lst to add the new locations to be backed up (/usr/local/apache2/ and /usr/local/mysql/data)

– Edit /opt/bootlocal.sh to add the daemons to start automatically at start-up (/usr/local/apache2/bin/apachectl and /etc/init.d/services/mysql start)

– And back up by running filetool.sh -b!

I need to figure out if there is a better way to ensure things are backed up before any type of shutdown than running the filetool.sh -b script.

I have everything in place so I’ll leave everything run for a few days and I’ll update this with the outcome, viable or just a nice to play with.