Gentoo-Portage.com

Search Portage:
Login     Register     Language Tools

www-apache/mod_chroot

mod_chroot allows you to run Apache in a chroot jail with no additional files.

Screenshots

You also need to copy /lib/libgcc_s.so.1 and add "LoadFile /lib/libgcc_s.so.1" to your configuration file.
- 14/01/2008 23:27 GMT
A little bit more detailed this time:

Step 1)
Create the chroot-enviroment. e.g.: /var/chroot/...


Step 2)
Copy all files/ directories they are needed for the websites below /var/chroot (logfiles are not neccessary)

# ls
...
/var/chroot/home/foo # User-Homepage
/var/chroot/var/www # Default-Homepage
/var/chroot/var/run
...


Step 3)
Create Symlinks, so every directory is also reachable from the unchanged root. (Reachable with the same path as within the changed root-environment!)
(excepting /var/run)
# ls
...
/home/foo -> /var/chroot/home/foo # Only during start of apache-
/var/chroot/home/foo # User-Homepage
/var/chroot/var/www # Default-Homepage
/var/chroot/var/run
/var/www -> /var/chroot/var/www # Only during start of apache-
...


Step 4)
Rename "modules.d/15_mod_chroot.conf" e.g.: to "modules.d/15_mod_chroot.con"


Step 5)
My http.conf:
...
Include /etc/apache2/modules.d/15_mod_chroot.con
Include /etc/apache2/vhosts.d/*.conf
Include /etc/apache2/modules.d/*.conf
...


Step 6)
Change /etc/init.d/apache2 :
...
start() {
checkconfig || return 1
ebegin "Starting apache2"
ln -sfn /var/chroot/var/run/apache2.pid /var/run/apache2.pid
...

stop() {
...
rm /var/chroot/var/run/apache2.pid
eend $?
...


Note: Step 3 has a nice side-effect. It's possible to switch between chrooted-apache and unchange-rooted just by disabling the config-file in http.conf. No other adjustments are neccessary.
DW - 12/03/2007 00:12 GMT
My experience with chroot are it's mandatory your paths in the changeroot-ed environment have to be the same as in the normal one.

If chroot is "/var/chroot":
# ls
/home/foo -> /var/chroot/home/foo
/var/chroot/home/foo
/var/chroot/var/www
/var/www -> /var/chroot/var/www
...
DW - 11/03/2007 14:44 GMT
hmm.. You have to load the mod_chroot as the last module/on top of all other modules in httpd.conf..(modules are loaded from bottom and up)
That isnt the case with the ebuild so it took some time to rebuild my configs! :<
- 08/04/2006 23:24 GMT


Leave a comment:

Please login to leave a comment