PHP doesn’t work on Apache virtual host – Managing your servers can streamline the performance of your team by allowing them to complete complex tasks faster. Plus, it can enable them to detect problems early on before they get out of hand and compromise your business. As a result, the risk of experiencing operational setbacks is drastically lower.
But the only way to make the most of your server management is to perform it correctly. And to help you do so, this article will share nine tips on improving your server management and fix some problem about apache-2.2, centos, php, configuration, virtualhost.
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
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).
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
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.
Try step 11.