Debian lenny: switch Apache in a chroot environment

To do this i’ve followed an howto from unixlife.it with some modifications.
Assuming you have your websites on /var/www/ and you want to move it on a chroot dir, /var/chroot/apache/, for example, let’s see what do you need to do:
Remember to do a complete backup before doing anything that could be “dangerous”.

In /etc/apache2/apache2.conf add those lines:

ChrootDir /var/chroot/apache
LoadFile /lib/libgcc_s.so.1
LoadFile /lib/libnss_dns.so.2

The you’ve to create the directories for the chroot environment (a bit different from the unixlife article):

mkdir -p /var/chroot/apache/var/www
cd /var/chroot/apache
mkdir bin dev etc lib tmp usr var
mkdir bin lib sbin share
mkdir curl misc php zoneinfo
mount -t auto -o bind /usr/share/php /var/chroot/apache/usr/share/php
mount -t auto -o bind /var/www /var/chroot/apache/var/www
mount -t auto -o bind /tmp /var/chroot/apache/tmp/

Leggi tutto “Debian lenny: switch Apache in a chroot environment”