Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a server with a few different domains on it (each in a separate VHost). Each VHost runs fine, executing PHP properly, etc. For the sake of example, two of the domains are and I'm trying to create an alias on that will include files from a directory on Easy, right?

# Apache config file for
Alias /bar-alias /var/www/vhosts/
<Directory "/var/www/vhosts/">
        Options Indexes FollowSymLinks
        Order Allow,Deny
        Allow From All
        Deny From None

It works fine and dandy, except when trying to run a PHP script. Under my configuration, going to returns the source code of the script instead of executing it. I've been beating my head against the wall trying to figure out how to get Apache to execute PHP in this way, and I'm drawing a blank.

(If it is at all possible, I'd like to avoid having to do any symbolic linking or stuff like that. This seems like something that I should be able to do purely within Apache's config, I just can't work out how to do it.)

share|improve this question

Looks like it might be executing the alias before it finishes reading the full http conf. Is the following line found before or after your Alias? Try moving it above:
Include conf.d/*.conf

share|improve this answer
The Include conf.d/*.conf line comes before the Alias line. In fact, the Include actually points to the file containing the Alias. – TimE Aug 12 '10 at 17:45
Try renaming the alias file to zz_whateveritscallednow.conf to ensure it gets read after the PHP include. – James L Aug 12 '10 at 18:22

Actually, I think I got it. Out of sheer frustration, I copied the following out of an earlier part of the configs and stuck it into the <Directory> block for this alias...

<IfModule sapi_apache2.c>
    php_admin_flag engine on
    php_admin_flag safe_mode off
<IfModule mod_php5.c>
    php_admin_flag engine on
    php_admin_flag safe_mode off

And lo and behold, it started to work as I expected it to. I'm going to hammer on it some more (it really doesn't seem like I should need that) but for the time being it's working well enough.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.