ChrootDir(mpm_common) and DocumentRoot issues
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
apache2 (Ubuntu) |
Opinion
|
Low
|
Unassigned |
Bug Description
Binary package hint: apache2
Description: Ubuntu 10.04.1 LTS
Release: 10.04
apache2:
Installed: 2.2.14-5ubuntu8
apache2-
Installed: 2.2.14-5ubuntu8
Setting document root to a folder inside the chroot provided by mpm_common (http://
directory structure:
/var/www/
/conf
/log
/error.log
/lib
/inc.php
/web <-- documentroot
/index.php <-- this just includes ../inc.php
apache2.conf:
ChrootDir /var/www/
ServerRoot /var/www/
LockFile /var/www/
PidFile /var/www/
Timeout 300
KeepAlive On
MaxKeepAliv
KeepAliveTi
User example
Group example
DefaultType text/plain
HostnameLookups Off
ErrorLog /var/www/
LogLevel warn
Include /etc/apache2/
Include /etc/apache2/
Listen 8080
# apache fails to start complains document root doesnt exist
DocumentRoot /web
# apache starts, requests fail
#
# DocumentRoot web
# apache starts, requests fail (cant find /var inside chroot)
#
# DocumentRoot /var/www/
# apache starts, requests work but php cant load inc.php (docroot==chroot)
# (this only works because / actually exists in the filesystem)
#
# ChrootDir /var/www/
# DocumentRoot /
Apache fails to start with "DocumentRoot doesn't exists" error, from strace output it seems apache does a stat/stat64 on documentroot before it chroots itself, then does it again before serving pages once request comes in.
Workaround:
Making empty "web" directory in / tricks apache into starting and servering requests, as well as php include working as expected.
Changed in apache2 (Ubuntu): | |
importance: | Undecided → Low |
A better work around might be to use a symlink setup like:
# ls -l /var/www/var/www
lrwxrwxrwx 1 root root 2 Aug 18 19:08 /var/www/var/www -> ..
This allows me to use /var/www from inside and outside the chroot.
I am using mod_chroot however (just learned that ChrootDir is in the core now, but it works differently; see bug 687275).