mini_httpd is a great web server - fast, easy to install, uncluttered and with a really small footprint. This makes mini_httpd ideal for serving php pages such as my eximadm script.
In the past there have been issues with mini_httpd and php, mainly because php relies on the presence of certain environment variables which, while not strictly demanded by the RFCs, are provided by Apache and many other 'major' web servers. To make a long story short, I wrote a small patch for mini_httpd-1.19.
For those shy of patching software, here's the pre-patched source code. Please bear in mind that this is not meant as some kind of code forking, and when in doubt, please download and use the source on the official mini_httpd web site.
In order to make php run as a .cgi, there's two possibilities - either put the path_to_php at the beginning of each php script (like #!/usr/bin/php
) which is rather tiresome - you'd end up with patching a zillion of php scripts on your server.
The other way is to register php as a binary handler; this requires the module binfmt_misc to be loaded. I wrote the simple script below which is loaded at system startup and all is well.
#!/bin/sh # Register PHP as binary handler for .php files /sbin/modprobe binfmt_misc if [ -z "$(/sbin/mount | /usr/bin/grep "binfmt_misc")" ]; then /sbin/mount -t binfmt_misc none /proc/sys/fs/binfmt_misc fi echo ":PHP:E::php::/usr/bin/php:" > /proc/sys/fs/binfmt_misc/register # end
Now all that remains to do is to make all .php files executable:
find /some_path -name "*.php" -exec chmod a+x {} \;
If you run mini_httpd with SSL and chroot, then you must create/copy a <basedir>/dev/random
device - either copy it from your regular /dev directory or create one with mknod <basedir>/dev/random c 1 8
, else mini_httpd won't be able to encrypt the pages.