Chroot Apache 2.2 on NetBSD

The Apache 2.2.17 package shipped in pkgsrc 2010Q4 comes with a nice ChrootDir directive that allows simple chroot configuration.

First, you will need Apache in at least version 2.2.10. Then:

# vi /usr/pkg/etc/httpd/httpd.conf
#DocumentRoot "/usr/pkg/share/httpd/htdocs"
ChrootDir "/usr/pkg/share/httpd"
DocumentRoot "/htdocs"
# ln -s /usr/pkg/share/httpd/htdocs /htdocs

You may need to create a /usr/pkg/share/httpd/var/tmp/ directory in case your Web application requires it.

You can use the logger application to send your log to an external syslog:

# vi /usr/pkg/etc/httpd/httpd.conf
ErrorLog "|/usr/bin/logger -t httpd -p info"
LogLevel warn
CustomLog "|/usr/bin/logger -t httpd -p info" combined

That’s All Folks!

Author: Joel Carnat

@work Technical Architect and SysAdmin ; @home OpenBSD and FOSS, Karate, Kobudō, Jōdō, Bodyweight workout, Photography & Music

Leave a Reply

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


This site uses Akismet to reduce spam. Learn how your comment data is processed.