Kategorien
Uncategorized

mini_httpd with PHP as CGI

While playing around a bit with other webservers than Apache, I decided to give mini_httpd a try. The documentation is very "limited" and you have to find out the things yourself. So here are the steps I did to get mini_httpd running on Debian Etch. Downloading and extracting is very easy:

wget 'http://www.acme.com/software/mini_httpd/mini_httpd-1.19.tar.gz' tar xzvf mini_httpd-1.19.tar.gz

While playing around a bit with other webservers than Apache, I decided to give mini_httpd a try. The documentation is very "limited" and you have to find out the things yourself. So here are the steps I did to get mini_httpd running on Debian Etch. Downloading and extracting is very easy:

wget 'http://www.acme.com/software/mini_httpd/mini_httpd-1.19.tar.gz' tar xzvf mini_httpd-1.19.tar.gz

Next step is compiling. There is no configure script in the sources, so if you want to enable e.g SSL support you need to edit the Makefile manually. But for now I want to keep everything at the default-values. cd mini_httpd-1.19 make After the compilation you will find the binaries in the mini_httpd-1.19 source dir (htpasswd,mini_httpd). Most interesting for now is of course the mini_httpd binary. You may want to copy it to a more common place in the filesystem. Starting mini_httpd: mini_httpd knows some startupoptions like port, user, etc. You can either specify these options on the commandline when starting the server or create a separate configuration file (e.g. mini_httpd.conf) where you set all these values. Here are thorsten@debsrv:/usr/local/src/mini_httpd-1.19$ ./mini_httpd --help usage: ./mini_httpd [-C configfile] [-D] [-p port] [-d dir] [-dd data_dir] [-c cgipat] [-u user] [-h hostname] [-r] [-v] [-l logfile] [-i pidfile] [-T charset] [-P P3P] [-M maxage] I decided to create a configfile with the following content: port=88 (for testing purposes only - would be normally 80) user=nobody nochroot cgipat=**php dir=/opt/mini_httpd data_dir=./html logfile=./logs/mini-httpd.log pidfile=/var/run/mini-httpd.pid charset=iso-8859-1 The startup of the server goes like this afterwards: ./mini_httpd -C mini_httpd.conf I would also like to use PHP in mini_httpd. There is no module like mod_php in Apache, but you can implement it via CGI. There is not much configuration to be done (see cgi-pat in mini_httpd.conf) and the shebang in the php sourcefiles need to point to your php binary (e.g. /usr/local/php-cgi), but I couldn’t get it to work successfully. After some investigation with the help of google I found out, that I need to patch the sources of mini_httpd. There is already a patch available from the m0n0wall project but this patch is not feasible for me, because it adds some m0n0wall related functionality, too. So I modified the patch to fit just to my requirements. It also adds "index.php" to the list of default filenames.

mini_httpd.patch

Dowload this patch and apply it to the sources of mini_httpd. After patching you need to call "make" again to build the new binary. patch -p0 -i mini_httpd.patch make

Eine Antwort auf „mini_httpd with PHP as CGI“

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.