Centos – PHP doesn’t work on Apache virtual host

apache-2.2centosconfigurationPHPvirtualhost

I have a virtual private server with Parallels Power Panel on CentOS 6. The default Apache virtual host (accessed using the IP) works wihtout any problem.

Now I created a new domain with Plesk and copied the files in the virtual host directory. Unfortunately PHP scripts doesn't work – you can access them, but they are not prepocessed. PHP module is working since the default virtual host is still working.

I tried to modify the httpd.conf (here is the full file) adding the NameVirtualHost directive and a VirtualHost section without success. This is the section I added:

NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin admin@###.com
    DocumentRoot /var/www/vhosts/###.com/httpdocs/
    ServerName www.###.com
    ServerAlias ###.com
    ErrorLog /var/log/httpd/###.com/error.log
    CustomLog /var/log/httpd/###.com/access.log common



<Directory "/var/www/vhosts/###.com/httpdocs/">
    Options Indexes FollowSymLinks Includes MultiViews ExecCGI
    AllowOverride All

    Order allow,deny
    Allow from all
</Directory>

</VirtualHost>

and this is my php.conf (in conf.d):

<IfModule prefork.c>
  LoadModule php5_module modules/libphp5.so
</IfModule>
<IfModule worker.c>
  LoadModule php5_module modules/libphp5-zts.so
</IfModule>

AddHandler php5-script .php

DirectoryIndex index.php

AddType application/x-httpd-php-source .phps
AddType application/x-httpd-php .php

Best Answer

For the record, the problem was Plesk.

Probably there was some problem with the manual installation of PHP 5 from Webtatic. After that any new subdomain created with Plesk have in their Apache configuration php_admin_flag engine off.

It was difficult to find where they are because Plesk creates one configuration file for every [sub]domain in a conf subdir of the domain directory and include them in httpd.conf. That is a good practice, but hard to find and you can't personalize it easily if you want to do something different from GUI options (if you change something via GUI the old conf file will be not modified, but a new one will be created and you have to reapply all your modifications).

Related Topic