Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have quite a strange problem with my Apache server.

I have two files containing <?php phpinfo(); ?>. They are both placed on the same server, however in different vhosts. The vhosts look like this:

First one:

<VirtualHost *:80>
        DocumentRoot /var/www/[...]/public_html
        ServerName something
        <Directory />
                AllowOverride All
        </Directory>
</VirtualHost>

Second one:

<VirtualHost *:80>
        DocumentRoot /var/www/[...]/public_html
        ServerName something
        ServerAlias something

        <Directory />
                AllowOverride All
        </Directory>
</VirtualHost>

As you see they are almost equal. However, if I point to the phpinfo.php on the second vhost, the source is sent to the client. On the first one phpinfo is executed and shown to the user successfully.

What can cause this difference?

share|improve this question

3 Answers 3

up vote 4 down vote accepted
  • Are you sure both files end in .php?

  • Are you using <? and not <?php in one of the sources?

  • Even though you say that there is no .htaccess file that doesn't work would you mind pasting the content of it?

  • Try reverting the order of the virtual hosts to see if anything changes.

  • Try once without any extra directory directives.

share|improve this answer
    
<? was used of course. Well I can't control what people put on the server ;-) Maybe the configuration was a bit too strict. Setting "short_open_tag = On" solved the issue. –  phidah Oct 26 '09 at 0:15
    
Now you should watch out for "<?xml" entries in your files as it will now be parsed by PHP and fail. –  mr-euro Oct 26 '09 at 15:09

Do you think you can post the full server configs?

What are the file names of both files?

I would also venture to guess that an .htaccess file is there, but without seeing the other config files we can't say for sure.

share|improve this answer

"AllowOverride All" means that any apache setting can be overridden by a .htaccess file in the DocumentRoot of each vhost (or in a subdirectory of the DocumentRoot). Check if your php settings are configured there.

share|improve this answer
    
There is no .htaccess file in the document root that doesn't work. –  phidah Oct 25 '09 at 12:38

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.