Linux OSBN/Ubuntuusers Planet XING / LinkedIn / Amazon

Monkey web server + PHP5 + SQLite on Raspbian

Using Raspbian it is possible to convert a Raspberry Pi into a full-featured Webserver with PHP support. Using SQLite the embedded web server is also capable of serving database-driven web applications.

First of all the official Monkey APT repository needs to be included – this can done very easily by addind a line into the configuration file /etc/apt/sources.list:

# echo "deb primates_pi main" >> /etc/apt/sources.list

The following commands are updating the APT cache and installing Monkey including SSL– and FastCGI support (needed for PHP) and some other plugins:

# apt-get update
# apt-get install monkey{,-auth,-dirlisting,-fastcgi,-liana,-logger,-mandril,-polarssl}

Afterwards PHP5 including FastCGI Process Manager and SQLite3 support is installed:

# apt-get install php5{,-fpm,-cgi,-sqlite} sqlite3

After that it is necessary to enable and configure the Monkey FastCGI module. Because Monkey offers no native PHP support FastCGI establishes a connection to PHP FastCGI Process Manager. This software communicates with the PHP interpreter and returns the generated content to the web server. The module is activated by adding a line in the configuration file /etc/monkey/plugins.load:

# vi /etc/monkey/plugins.load
    # =======
    # Adds FastCGI proxy support.
    Load /usr/lib/monkey/


The module is configurated afterwards in a dedicated configuration file in /etc/monkey/plugins/fastcgi.

The first category (FASTCGI_SERVER) contains information about the PHP FastCGI Process Manage. In my setup the default values were already correct. If you are having issues you should have a look whether the socket (/var/run/php5-fpm.sock in this case) exists.

Access limitations can be defined in the second category (FASTCGI_LOCATION). Basically it is a good idea to enable executing PHP files only for particular subdirectories. Rules are defined in regular expressions – in this case executing all PHP files is allowed for testing purposes. To make debugging easier unique names are definied in the particular categories (ServerName, LocationName).

In my setup I had the issue that PHP applications were not executed after some time. To fix this I altered the MaxConnections  and KeepAlive settings.

# vi /etc/monkey/plugins/fastcgi/fastcgi.conf
        ServerName php5-fpm1
        ServerPath /var/run/php5-fpm.sock
        MaxConnections 5

        LocationName php5_location
        ServerNames php5-fpm1
        KeepAlive On
        Match /*.php


After restarting the Monkey service PHP is availble:

# service monkey restart

If you are planning to use this system as public web server you really should secure the system:

# apt-get install fail2ban iptables-persistent aide

Of course firewall rules, Fail2Ban and AIDE configurations needs to be customized. 🙂

Sharing is caring

2 Comments Add New Comment

  1. dudu says:

    I installed Monkey web server with PHP-support on Puppy Linux 6.3.0 32-bit.
    When you configure the file plugins.load to enable a plugin, you should look at the correct – horizontal – position of the line, otherwise you
    get the error-message “Invalid indentation level”.
    My fastcgi.conf was
    ServerName php-fpm
    In the file /sites/default I uncommented in the section [HANDLERS] the line
    Match /.*.php fastcgi

Leave a Reply

Your email address will not be published. Required fields are marked *