![]() |
Now serving 104 guides. |
|
Chrooting Apache and PHP General Information Chrooting has been around for a long time now. Chrooting makes a program believe that the root of the file system is higher up in the hierarchy. For example, if I wanted to create a chroot in /chroot/httpd, a program executed from within the chroot would believe that "/chroot/httpd" was actually "/". There in lies the beauty as the program can't reach any files outside "/chroot/httpd". Security of the server as a whole is increased due to the fact that the system binaries are off limits. In addition, chroots usually only have the bare minimum files inside, so exploits have a harder time breaking in.Chroots can be broken out of. On FreeBSD, jail can also be used. Jail does the same as chroot, but on top of what chroot does, jail restricts what a process can do. One of the benefits of OpenBSD is the fact that apache comes chrooted by default, which is nice. But, that's not going to stop NetBSD or FreeBSD from doing this also. So, why chroot instead of jail? Jailing processes is actually a simple task. Basically I want to help you out with 2 areas in this article. The first is to get apache and php chrooted while working with a chrooted mysql. And the second, I hope you can figure out from this how to chroot your own processes. Once you figure out how to setup chroot trees, configuring jails should not be a challenge for you at all. Installation Lets start off by installing apache with mod_ssl and create our SSL certificates.
Configuration Now we need to prepare our directory structure for the chroot.
mknod for this task.
ldd, truss, and strings are amongst the most commonly used. I'll go over ldd and strings here.
Once that's done let's get those modules inside the chroot tree.
Author: Leigh Renfrow 3 Comments Posted by sporkit on August 06, 2005 at 5:47:09 pm EEST
i was able to chroot apache as and php in my jail at /usr/chroot_apache but unfortunatly ran into this problem at that last step.
sporkitBSD# ln /tmp/mysql.sock /usr/chroot_apache/tmp ln: /usr/chroot_apache/tmp/mysql.sock: Cross-device link also i compilied the port for mysql41 but never found a my.cnf. i search the entire system too. the mysql server is working however with out it. and one last thing. occationally when im copying files over after trying to actually start the jail it'll say i have a dependancy on a certain file. even if move it over to the correct place with the same permissions it still complains. Posted by sporkit on August 06, 2005 at 5:47:09 pm EEST
to get this working i recompiled the mysql
./configure --prefix=/usr/mysql41 --with-unix-socket-path=/usr/chroot_apache/tmp/mysql.sock if you dont set the correct permissions for the database directory it wont work either. # chown -R mysql data # chgrp -R mysql . most importantly mysql will give you vauge errors about mysql.sock if it cant write to your new temp dir. chmod 755 /usr/chroot_apache/tmp Posted by star on October 22, 2006 at 7:36:24 am EEST
I'm geting this one error :
avec# [/][7:25am] # chroot /chroot/httpd/ /usr/local/sbin/httpd fopen: Operation not supported httpd: could not open document config file /dev/null I've cheked all files twice, everything seems to be normal. Also it's it normal for php4 : avec# [/][7:25am] # pkg_info | grep "php4" php4-4.4.4_1 PHP Scripting Language (Apache Module and CLI) php4-bz2-4.4.4_1 The bz2 shared extension for php php4-ctype-4.4.4_1 The ctype shared extension for php php4-extensions-1.0 A "meta-port" to install PHP extensions php4-gd-4.4.4_1 The gd shared extension for php php4-mbstring-4.4.4_1 The mbstring shared extension for php php4-mcrypt-4.4.4_1 The mcrypt shared extension for php php4-mysql-4.4.4_1 The mysql shared extension for php php4-overload-4.4.4_1 The overload shared extension for php php4-pcre-4.4.4_1 The pcre shared extension for php php4-posix-4.4.4_1 The posix shared extension for php php4-session-4.4.4_1 The session shared extension for php php4-sockets-4.4.4_1 The sockets shared extension for php php4-tokenizer-4.4.4_1 The tokenizer shared extension for php php4-xml-4.4.4_1 The xml shared extension for php php4-zlib-4.4.4_1 The zlib shared extension for php avec# [/][7:28am] # avec# [/][7:25am] # ldd /usr/local/libexec/apache/libphp4.so /usr/local/libexec/apache/libphp4.so: libcrypto.so.4 => /lib/libcrypto.so.4 (0x2826b000) libssl.so.4 => /usr/lib/libssl.so.4 (0x2835d000) libcrypt.so.3 => /lib/libcrypt.so.3 (0x2838b000) libm.so.4 => /lib/libm.so.4 (0x283a3000) avec# [/][7:29am] # all modules for php works fine on non-chrooted apache. |
Copyright 2003 - 2008 BSD Guides. All rights reserved. |
About | Terms of Use | Privacy | Contact |

