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

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
share|improve this question
    
When you say "you can access them, but they are not pre-processed", do you mean that you see the source code as plain text? –  Phil Sturgeon Jul 31 '13 at 17:18
    
@PhilSturgeon: yes, the browser tries to download the php file, and stop. –  Lucas Malor Jul 31 '13 at 17:20
    
I answered with a bit more info. –  Phil Sturgeon Jul 31 '13 at 17:29

3 Answers 3

If it's default installation (httpd, php packages), nothing changed, then it should be a php.ini issue with short_open_tag - php will parse files with .php extension, but ignore content if it doesn't start with <?php.

share|improve this answer
    
Thank you for your answer, but I do not use short tags. I do not know if apache configuration is the default one, since I'm using a virtual server with CentOS, Plesk and some basic packages preinstalled by my cheap but lacking provider. –  Lucas Malor Aug 1 '13 at 10:53

It sounds like you have not configured Apache to parse .php files correctly. It doesn't know what to do with them, so it spits them out as download.

http://dan.drydog.com/apache2php.html

Try step 11.

share|improve this answer
    
Thank you, but all the configuration in step 11 are already present in conf.d/php.conf (I added the code to the question). –  Lucas Malor Jul 31 '13 at 17:38
    
Try this? stackoverflow.com/questions/6245895/… –  Phil Sturgeon Jul 31 '13 at 17:40
    
The default virtual host is working well... read the first part of my question ;) –  Lucas Malor Jul 31 '13 at 17:42
    
I read that, I suggest you read some of the answers. If Apache is serving up PHP files as plain text downloads then you probably dont have mod_php set up properly. –  Phil Sturgeon Jul 31 '13 at 17:54
    
Sorry, I only read the first answer to your linked question. Anyway PHP is installed, I restart the httpd service every time I modify any configuration files, I do not have a php_admin_value rule and on CentOS there's only conf.d, not mods-enabled etc... :( –  Lucas Malor Jul 31 '13 at 18:22
up vote 0 down vote accepted

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).

share|improve this answer

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.