Friday, December 28, 2007

Using mini_httpd with PHP on OpenBSD

This article details the steps I used to get mini_httpd working on OpenBSD 3.8 with PHP. Getting mini_httpd running is trivial, compile and go. Getting mini_httpd working with PHP on the surface is not really difficult, however the challenge is in getting the POST variables to pass between mini_httpd and PHP.

Initially, I spent a couple of days of trying to get mini_httpd to work with PHP on OpenBSD 3.8 using the PHP build from the ports tree and it just was not working. The fix required two things.

First: was to patch the mini_httpd 1.19 as described by Ben Hochstrasser (see his article)

Second: was to build PHP 4.3.x with the following command:
./configure --prefix=/usr --sysconfdir=/etc --with-config-file-path=/etc \
--disable-force-cgi-redirect --without-mysql \
--with-zlib --disable-cli --enable-discard-path --enable-debug --enable-ftp --without-pear

This solved the problem of passing the POST variables from mini_httpd to PHP. The catch to this method is that you must put #!/usr/bin/php at the beginning of each .php file. To start mini_httpd you should change directories to the one containing the PHP files then,
use the following syntax:

/usr/local/sbin/mini_httpd -p 80 -c \"**.php\" -l /var/log/httpd.log

While this solution is somewhat specific to my needs I hope you will find it useful and can adapt part or all of it for your own situation. Many thanks to Ben Hochstrasser for his assistance in debugging the setup.

email: paul dot pescitelli at gmail dot com

1 comment:

Petter Marry said...

I have read your blog its very attractive and impressive. I like it your blog.

PHP 7 Training in chennai | PHP 7 Training Course

PHP 7 Training in chennai | Online PHP 7 Course