CentOS apache conf.d dark mystery: why some virtual hosts are more equal then others | Server support blog

CentOS apache conf.d dark mystery: why some virtual hosts are more equal then others

I’ve got a complain the other day: for some reason some virtualhosts on dedicated server was not working properly with suExec PHP as configured.

I went to examine the configuration. There was about 17 virtual hosts, manually converted from mod_php configuration into FCGI/suExec. All configuration was absolutely identical. And yet some virtual hosts was falling back to default wrapper /var/www/cgi-bin/php-fcgi executed as apache user.
I couldn’t quite lay may hand on the reason why some virtual hosts was not taking suExec configuration – no trace in /var/log/suexec.log form this virtual hosts either.
Lets take a look at 2 virtual hosts apache configuration:

Not working abc.com.conf

And working xyz.com.conf

It took me some time to recall one very important but seldom noticed rule which caused this problem :

Config files in /etc/httpd/conf.d/ are loaded in ALPHABETICAL order.

So, at the time abc.conf is loaded and virtual host defined mod_fcgid is NOT YET loaded from fcgid.conf and all definitions from within

...

are invalid and ignored. This is also true for all the rest of virtual hosts config files that are loaded before fcgid.conf by alphabetical order.
Let’s fix this problem.

# cd /etc/httpd/conf.d
# mv fcgid.conf 00-fcgid.conf
# service httpd restart

Problem solved.
This rule also useful if you want to control the precedence of virtual host and/or module definitions (e.g. you want some virtual host to be always configured first no matter what).

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">