PHP pages are downloading instead of being displayed

Created:

2016-11-16 13:22:27 UTC

Modified:

2017-08-19 15:44:09 UTC

5

Was this article helpful?


Have more questions?

Submit a request

PHP pages are downloading instead of being displayed

Applicable to:

  • Plesk for Linux

Symptoms

  • PHP is not being handled correctly.
  • Anytime we try to access a PHP page, it asks us to download it, instead of processing it properly.

Cause

  1. PHP handler is absent or incorrectly configured in Apache configuration.

  2. Fcgid module for Apache is disabled.

Resolution

Make sure there are the following lines in the main Apache configuration file (for RedHat-based system: /etc/httpd/conf/httpd.conf ; for Debian-based system: /etc/apache2/apache2.conf ).

AddHandler type-map var AddType application/x-httpd-php .php

If it does not work for the configuration, another option is to specify the handler for PHP files explicitly:

AddHandler application/x-httpd-php .php

If custom vhost.conf is used and domain configured with PHP FastCGI, ensure that the following conditions are met in sections used to handle PHP scripts:

<IfModule mod_fcgid.c> 
SetHandler fcgid-script
FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .php
Options +ExecCGI
</IfModule>

Check if Fcgid module is enabled:

    # ls -la /etc/apache2/mods-enabled/ | grep fcgid
lrwxrwxrwx 1 root root 28 Dec 7 2015 fcgid.conf -> ../mods-available/fcgid.conf
lrwxrwxrwx 1 root root 28 Dec 7 2015 fcgid.load -> ../mods-available/fcgid.load

and if it is not, enable it at Tools & Settings > Apache Web Server > fcgid .

Note If prefork is enabled for Apache webserver in Home > Tools & Settings > Apache Server , make sure that php5 tickbox is checked.

Have more questions? Submit a request
Please sign in to leave a comment.