OpenBSD chroot apache howto tutorial

If you are looking for simple setup of you chroot apache under OpenBSD you are on the right place.

I’m currently working on OpenBSD 4.1 right now, but it should work on previus and next version.

The server currently serve several WordPress and Drupal sites including this one, phpMyAdmin and some other my custom scripts for monitoring.

First we must make needed directories.

mkdir -p /var/www/etc
mkdir -p /var/www/bin
mkdir -p /var/www/var/run
mkdir -p /var/www/usr/lib
mkdir -p /var/www/usr/libexec
mkdir -p /var/www/usr/local/bin
mkdir -p /var/www/usr/local/lib
mkdir -p /var/www/tmp
mkdir -p /var/www/usr/sbin/

chmod 777 /var/www/tmp
chmod +t /var/www/tmp

Next copy needed binaries + all libs.My way is really dirty/copy all libs/ but it is simple and easy to maintain.

cp -p /bin/sh /var/www/bin/sh
cp /var/run/ld.so.hints /var/www/var/run

cp /usr/libexec/ld.so /var/www/usr/libexec
cp -pr /usr/local/lib/* /var/www/usr/local/lib/
cp -pr /usr/lib/*.0 /var/www/usr/lib/
cp -pr /usr/lib/*.1 /var/www/usr/lib/
cp -pr /usr/lib/*.2 /var/www/usr/lib/
cp -pr /usr/lib/*.3 /var/www/usr/lib/

The final part is to set up sendmail working under chrooted apache.So after i dig around google the easies way was to install mini_sendmail from packages.Then modify your php.ini fail and change path to mini_sendmail
[mail function]
; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =
sendmail_path = /bin/mini_sendmail -t -i

Do not forget to copy /etc/resolve.conf to chroot apache /etc directory
cp /etc/resolve.conf /var/www/etc/

Hi,
I chmod 777 wp-content/uploads and evrything just begin to work.Make shure to chmod 777 /var/www/tmp also.

Hi,

I managed to successfully install wordpress on OpenBSD 4.2, and used your chroot instructions. Everything works fine, except, when posting, I cannot upload images and get failed to write to disk errors. If I load apache without chroot, this works. Any ideas? I have messed around with permissions, but still no joy with chroot.

Thanks,

Satej