[CentOS] Php script not running

Fri Nov 30 15:53:48 UTC 2018
Leon Fauster <leonfauster at googlemail.com>

> Am 30.11.2018 um 14:28 schrieb Jerry Geis <jerry.geis at gmail.com>:
> 
> Hi All, I have centos 7. Apache and php are installed.
> CGI runs fine - php does not seem to run.
> 
> I have the /etc/httpd/conf.d/php.conf file
> php.conf
> #
> # Cause the PHP interpreter to handle files with a .php extension.
> #
> <FilesMatch \.php$>
>    SetHandler application/x-httpd-php
> </FilesMatch>
> 
> #
> # Allow php to handle Multiviews
> #
> AddType text/html .php
> 
> #
> # Add index.php to the list of files that will be served as directory
> # indexes.
> #
> DirectoryIndex index.php
> 
> #
> # Uncomment the following lines to allow PHP to pretty-print .phps
> # files as PHP source code:
> #
> #<FilesMatch \.phps$>
> #    SetHandler application/x-httpd-php-source
> #</FilesMatch>
> 
> #
> # Apache specific PHP configuration options
> # those can be override in each configured vhost
> #
> php_value session.save_handler "files"
> php_value session.save_path    "/var/lib/php/session"
> 
> 
> I have:
> AddHandler cgi-script   .cgi .php
> 
> The result is 500 internal server error.
> 
> everything seems like its setup - I have restarted httpd.
> 
> These are the PHP that are loaded:
> rpm -qa | grep php
> php-common-5.4.16-45.el7.x86_64
> php-5.4.16-45.el7.x86_64
> php-fpm-5.4.16-45.el7.x86_64
> php-cli-5.4.16-45.el7.x86_64
> 
> I do not see any reason in any of the httpd/log files just the 500 internal
> server error returned.
> 
> If I do the file with the PHP info line  <?php phpinfo(); ?> this displays
> correctly, but my other script does not run.
> 
> I have checked the permissions on the script and it is executable and owned
> by the same user my CGI programs are owned that work.
> 
> What might I be missing?


PHP scripts are not passed to the "cgi-script" handler. They are passed to the "application/x-httpd-php" 
handler already configured in php.conf (provide by mod_php package). So, revert your changes (Delete: 
AddHandler cgi-script .cgi .php) and everything should run ... 

PS: I assume that you run httpd/php via mod_php. This requires that the MPM is set to "prefork.c" (.+mpm.conf).
 

--
LF