I have an apache configuration file which works fine when it's placed directly in /etc/httpd/conf.d/foo.conf. However, when I move the same file somewhere else (for example, move it to /tmp/foo.conf) and then create a symlink with ln -s /tmp/foo.conf /etc/httpd/conf.d
then apache fails on startup with:
httpd: could not open document config file /etc/httpd/conf.d/foo.conf
I've tried making the file and the symlink mode 777, and tried changing them to be owned by the apache user.
It seems like apache is failing to load the file purely on the basis of it being a symlink, but I'm sure I've used symlinks successfully on other machines. Is there something I'm missing? Does apache have an option for refusing to load config files if they're symlinks?
The operating system is CentOS 4.4, apache version 2.0.52.
Is SELinux enabled on this server? I wonder if this is stopping apache from loading this symlink correctly?
The permissions for the apache user shouldn't matter as in general apache is run starting as root and then in launches webserver as the apache user (or whatever the
user
directive is). I believe this would have to be after the config file is loaded.Can you cat the symlink?
Instead of creating a symlink from conf.d to wherever it is, could you leave the file in the conf.d directory and create a symlink to the file in conf.d. Example syntax:
ln -s /etc/httpd/conf.d/foo.conf /tmp/foo.conf
Alternatively, use a hard link, so it is a regular file in both places. One file with two locations. Example syntax:
ln /tmp/foo.conf /etc/httpd/conf.d
Note that this will only work if both locations are on the same filesystem.