Experiments with Linux

Quickest Way to Install Cherokee Web Server

Submitted by Derwent Ready on Friday, 03 January 2014

Disclaimer: I take no responsibility for damage done to your system or computer from following this tutorial. I am not a security expert and do not claim that this is a secure approach.

I previously wrote an article on how to install Cherokee webserver on the Raspberry Pi but I never quite got round to publishing it. I could never bring myself to give it the final polish it needed. You can read the previous article if you like as it goes into quite a lot of detail as to how and why you'd do things certain ways. If, however you just want a quick and dirty one line setup that'll get it up and running in one go copy and paste the following into your terminal:

sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get install -y gettext automake autoconf libtool && git clone --recursive http://github.com/cherokee/webserver.git && cd webserver && ./autogen.sh --prefix=/usr --localstatedir=/var --sysconfdir=/etc --with-wwwroot=/home/pi/www && make && sudo make install && chmod +x contrib/cherokee && sudo cp contrib/cherokee /etc/init.d && sudo update-rc.d cherokee defaults && sudo reboot

Please note that this is geared more towards Raspbian for the Raspberry Pi as it allows for fully automatic building and installation of Cherokee which can take quite a while on the Pi's low power CPU but should work on any Debian based Linux variant.

Here follows a quick breakdown of what everything does and any customisations you might want to make:

This is a series of commands. You can chain commands in the terminal with the && symbol.

sudo apt-get update && sudo apt-get upgrade -y - This updates your dpkg with the latest from all your package repos and installs any updates it finds. The -y means it won't ask for confirmation before installing the updates.

sudo apt-get install -y gettext automake autoconf libtool - These are packages needed to build and install Cherokee

git clone --recursive http://github.com/cherokee/webserver.git - This clones the latest git repo for Cherokee.

cd webserver - webserver is the folder that git creates when you clone the repo. You may want to add a couple of steps before the clone: && mkdir downloads && cd downloads which will allow you to download the webserver repo to a downloads folder if you don't have one already.

./autogen.sh --prefix=/usr --localstatedir=/var --sysconfdir=/etc --with-wwwroot=/home/pi/www - This is what configures Cherokee and is where you might want to do some heavy customisation. For example the default folder for the with-wwwroot flag is /var/www but this requires root access to upload and change contents which for development can cause problems and as such by default on the Pi I put it in a subdirectory of my home folder.

make - This actually builds cherokee from the source. This is the bit that takes a loooong time on the Pi.

sudo make install - This takes the built source and actually installs it.

chmod +x contrib/cherokee - This is the startup script that will make Cherokee load at start up. By default this isn't built as exectuable but startup scripts need to be executable so this changes the file's mode to be executable.

sudo cp contrib/cherokee /etc/init.d - This is where we copy the newly executable startup script to the startup folder (/etc/init.d is where startup files go).

sudo update-rc.d cherokee defaults - This tells Debian that there's a new script to add to the startup run.

From this point on we're done. The last part just reboots Debian/the Pi so that Cherokee and boot properly (and you can check that it actually has loaded.)

Finally to test point a browser on your computer to ip-address-of-computer-with-cherokee-on (for example If you see a red white and blue  page with a little picture of a Cherokee man and the word Cherokee on it you have successfully installed Cherokee :D.

You will probably want to refer to my other article if you want to use other packages such as PHP and Mysql. If you'd rather just trust me and do another mass update (including mysql, php, sqlite and other similar packages) you can copy and paste the following line into your terminal (deleting/adding packages as you want):

sudo apt-get install php5 php5-fpm php5-mysql php5-curl php5-mcrypt php5-gd php-apc mysql-server mysql-client sqlite

Another quick breakdown:

php5 is the base PHP package

php5-fpm allows PHP to be called from Cherokee (FPM is supposed to be faster than fast cgi)

php5-curl allows you to call things from PHP using cURL

php5-mcrypt is a a cryptography library and is sneeded to install php5-gd

php5-gd is an image creation/manipulation library for PHP

php-apc is a package that allows PHP to run faster by keeping the opcode for a script cached between page requests (this means that the initial delay of PHP building the script only happens once while a script remains unchanged)

mysql-server is the main mysql server package. This allows you to host mysql databases

mysql-client this allows you to access/maintain the mysql databases from the terminal

sqlite is a flat file light alternative to mysql and is one of the most widely distributed databases. Firefox and similar programs use it for settings/bookmarks etc.

Now you're done you should be able to load pages in your wwwroot and navigate around your server. If you need to do admin in the terminal type:

sudo cherokee-admin

which will allow you to load up server-ip:9090 in your browser and login to manage Cherokee. If your server isn't accessible from the internet or you trust everyone on your network use: sudo cherokee-admin -u -b which will bypass any authentication.

I hope you found this article useful and interesting. It's much less waffly and more succinct than my last article but it doesn't go anywhere near as in depth. Let me know on Twitter or in the comments below if you liked this article or need help.

If you liked this blog post, why not buy me a beverage?

Blog Appreciation: Usefulness