Setting Up PhileCMS on a Raspberry Pi model B running piCore 6

I stumbled across Tiny Core Linux a couple of years ago and became a fan immediately. Tiny Core Linux is a minimalist Linux distro that runs entirely in RAM, which makes it extremely fast. It has its own package manager, tce-ab, which might be hard to wrap your head around at first, but is very easy to use.

I also happen to be a happy owner of a Raspberry Pi model B computer that I've got as a birthday present from my friends some time ago.

Truth be told, Raspberry Pi was lying on the shelf picking up dust most of the time, as it turned out to be not the best media player platform out there.

So here I am, trying to migrate this particular website from a hosting provider that makes me pay 6.60 EUR per month for basically nothing.

I don't need much: this website runs PhileCMS and doesn't need MySQL or anything resource-intense, and instead solely relies on Markdown.

So, on a dark and cold December day here in Estonia, I decided to put my Raspberry Pi to the test.

The specs of my Raspberry Pi are as follows:

CPU: 700 MHz
RAM: 512 MB
Network: 10/100 Mbit/s

I thought it might be just enough to run a simple Apache instance.

Setting up piCore

Start by going to Tiny Core website and download This particular version will provide us with openssh and mc out of the box, which is pretty handy.

Unpack the archive and write the .img file to an SD card you have lying around (mine is 128 MB and it's totally enough for Tiny Core).

If you're running Linux, then run sudo dd if=*path_to_img* of =/dev/*mmcblk0* && sudo sync

Don't forget to replace /dev/mmcblk0 with the path to your SD card.

Follow the instructions to expand your second SD card partition that will store your extensions (the first partition will be read-only).

If you would like to open multiple console windows during your session, you need to edit cmdline.txt on the first SD card partition and append multivt to the end of the line.

Preparing the USB flash drive

Tiny Core only supports ext2, ext3 and ext4 filesystems, so your regular FAT32 flash drive won't work. I have formatted mine to ext2 because using a journaling filesystem will greatly decrease the lifespan of the drive. Do some internet research on how to format your drive to ext2 on your own, I won't cover this.

Make sure you create /opt folder on the flash drive for Tiny Core to properly see it.

Booting up

You can now insert both your SD card and the flash drive that will later become /opt into the Raspberry Pi and power it on.

The system should boot pretty fast and automatically log you in as user tc. Upon initial startup, the system will automatically start openssh server and generate the necessary public and private keys.

There are a couple of files that are required for Tiny Core to function:

  • /opt/.filetool.lst
  • /opt/.xfiletool.lst
  • /opt/
  • /opt/
  • /opt/
  • /opt/tcemirror

If you don't have them somewhere on a persistent storage, Tiny Core will be generating them every time the system boots up.

We can get away with some of them not being in /opt folder on our flash drive, but and .filetool.lst have to be copied over to the flash drive. In my case, I have copied all of them just to keep things simple.

Setting up SSH keys

piCore with SSH preinstalled will generate new SSH keys every time the system boots up unless you create a persistent storage and copy your keys there.

  1. The automatically generated keys will go to /usr/local/etc/ssh. You can fire up mc, and copy all of them to your flash drive. In case you need to access other terminal windows, you can press Ctrl + Alt + F2 to switch to the second terminal (for example, to create the /opt folder on the flash drive).

    For convenience, I created a new folder called ssh inside the /opt folder on the drive and copied my keys there.

  2. The next thing to do is to make sure that piCore knows where to find the SSH keys on the drive. To do that, edit /opt/ and add the following lines before # Start openssh daemon:

    # Symlink keys
    ln -sf /opt/ssh/ssh_host_dsa_key /usr/local/etc/ssh/
    ln -sf /opt/ssh/ /usr/local/etc/ssh/
    ln -sf /opt/ssh/ssh_host_ecdsa_key /usr/local/etc/ssh/
    ln -sf /opt/ssh/ /usr/local/etc/ssh/
    ln -sf /opt/ssh/ssh_host_ed25519_key /usr/local/etc/ssh/
    ln -sf /opt/ssh/ /usr/local/etc/ssh/
    ln -sf /opt/ssh/ssh_host_rsa_key /usr/local/etc/ssh/
    ln -sf /opt/ssh/ /usr/local/etc/ssh/

This will create symlinks to the key files and overwrite them if they already exist in /usr/local/etc/ssh on each system startup.

Edit your /opt/.filetool.lst and delete the lines:


Modifying user accounts and setting passwords

By default, piCore logs you into the system as user tc without any authentication, although the password is set to 'piCore'. You need to change that password so that once you have your system in production, no one can get root access to your system. So, open up a terminal and type sudo passwd tc and enter your new password. Once that is done, you need to copy the following files to your /opt/etc folder:

  • /etc/passwd
  • /etc/group
  • /etc/shadow
  • /etc/gshadow

This is easily done through mc.

Then edit your /opt/ and add the following lines after # ------ Put other system startup commands below this line:

# Load users and passwords
ln -sf /opt/etc/shadow /etc/
ln -sf /opt/etc/gshadow /etc/
ln -sf /opt/etc/passwd /etc/
ln -sf /opt/etc/group /etc/

After that, remove the following lines from your /opt/.filetool.lst:


Installing extensions

As I mentioned earlier, we'll be using PhileCMS, which requires PHP 5.4 to run. At first, I thought I'd go with lighttpd, but didn't want to mess around trying to get PHP to work with it.

The good news is that piCore has apache2.4-mod-php5 extension readily available, which greatly simplifies our task. We'll also need rsync installed, which I'll explain later. Run tce-load -wi apache2.4-mod-php5 rsync. It will pull the required extension as well as their dependencies from the internet and install them onto the second partition of your SD card.

Setting up Apache

Apache stores its config files in /usr/local/etc/httpd/. The *.html files themselves are stored in /usr/local/apache2/htdocs/

Copy /usr/local/etc/httpd/httpd.conf to /opt/apache2/ and add the following to the end of your /opt/

# Apache
rm /usr/local/apache2/htdocs/index.html
ln -sf /opt/apache2/httpd.conf /usr/local/etc/httpd/
apachectl start

You should also enable mod_rewrite as it is required by PhileCMS. Open /opt/apache2/httpd.conf and uncomment #LoadModule rewrite_module modules/

Configuring PhileCMS

Download PhileCMS from the project website and extract it into /opt/apache/htdocs/ on your flash drive. Make sure your config.php contains an encryption key and the required folders have the correct permissions set. Follow the documentation. The required folder permissions are documented under Post Installation->Permissions.

Syncing your website from the flash drive to RAM

PhileCMS has its own way of caching things for your website, however, it's not suitable for us, as we are using a flash drive that has limited read/write cycles and we want it to last as long as possible.

So our best option would be to sync our whole htdocs folder into RAM. This should also make things a bit faster.

In order to sync the files from your flash drive you need to add the following line to the end of your /opt/

rsync -av /opt/apache2/htdocs/phile/ /usr/local/apache2/htdocs >> /usr/local/var/logs/rsync.log 

You can also automate the aforementioned command using cron to run every 5, 10 or 15 minutes, so that your website gets updated as you upload new Markdown files. Rsync is smart enough to calculate the deltas between your changes, so it won't take as long as you would expect if you simply copied the contents of your /opt/apache2/htdocs/ each time.

Setting up piCore kernel boot options

In order for us to customize the kernel boot parameters for piCore, we need to edit cmdline.txt file that resides on the piCore partition of the SD card.

I have added the following: showapps multivt tz=EET-2EEST opt=UUID="cc39f15a-fe96-47d1-9002-0d3f4ad45174"

I'll break it down for you:

showapps lists the extensions piCore is loading during the boot process. It is useful during setup to make sure you have done everything right. This option can be removed later when you're in production mode.

multivt gives you additional console windows. This is, again, very useful during the setup process. You will probably be editing some files in Midnight Commander on one screen and then restarting Apache or something along those lines in another. In case you need to access other terminal windows, you can press Ctrl + Alt + F2 to switch to the second terminal, for example.

tz=EET-2EEST defines the time zone I am in (Estonia). Do some internet research to find the right for you.

opt=UUID=... is the UUID of the external USB flash drive I am using to store my web server settings as well as the Markdown files for PhileCMS. To get the UUID for your drive, you should run sudo blkid -S UUID */dev/sdb1*. Replace /dev/sdb1 with the path to your flash drive.

Tiny Core also supports assigning other folders to external devices, however, I had troubles when I also defined the same USB drive to the /tce folder. In this case, you can also define the drive by its /dev path (can be used if you only have one external flash drive, because this path is determined at boot time as different devices are discovered, so the same device can have different paths on another boot).


Now you have yourself a CMS that scans your /opt/apache2/htdocs/content folder for Markdown files and generates complete webpages on the fly. My setup serves pages in about 3 seconds, which is pretty nice for a Raspberry Pi that was just sitting on the shelf.

Now go ahead and explore what else you can do with that awesome piece of hardware and Tiny Core Linux.

Back Home