I updated php on my test platforms from php 7.4 to php 8.0. The update on the Centos 8 box works normally. The one on Centos 7 does not. The page with <?php phpinfo() ?>
comes up blank while my tester page simply shows the code as text.
The command line seems to work:
[lhadmin@dho-dev01 ~]$ php --version
PHP 8.0.8 (cli) (built: Jun 29 2021 07:41:19) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.8, Copyright (c) Zend Technologies
[lhadmin@dho-dev01 ~]$ php -r 'echo "Hello World!\n";'
Hello World!
I tried uninstalling php and reinstalling httpd. Then I installed php again. Still no good. I can go back to php 7.4 and everything works.
The repos I'm switching between are remi-php74 and remi-php80.
Could there be any security policies suggested by cis-cat that might be interfering with this? I tried disabling selinux but that didn't do anything.
Thank you for your input.
First, we are not planning on moving to Centos 8 because of RHEL issues. We are looking at other distros. That choice is what they call "above my pay grade." I also don't think that php80 on centos 7 is the issue. I think there is something about this system, possibly related to security settings we've been implementing. We had a problem with a mail list because default permissions on /var/log were set to 600.
As Remi Collet mentioned, it should work out of the box. The package list is 923 lines long. Are there any packages in particular that I should be watching out for? I know apache is somehow interacting with php because the info page shows the text when php is not installed. It shows a blank page when it tries to access the function.
What I've tried:
On php 7.4 - everything works. phpinfo() shows PHP Version 7.4.21, etc.
Server version: Apache/2.4.48 (codeit) Server built: May 26 2021 11:40:06
7.4 config files:
/etc/httpd/php.conf
/etc/httpd/conf.module.d/15-php.conf
/etc/httpd/modules/libphp7.so
/etc/httpd/modules/libphp7-zts.so
yum-config-manager --disable remi-php74
yum-config-manager --enable remi-php80
yum check-update # verify
yum -y update
systemctl restart httpd # with php 8.0
Phpinfo() is a blank page. Php on the command line works, though.
8.0 config files:
/etc/httpd/php.conf,
/etc/httpd/conf.module.d/20-php.conf
/etc/httpd/modules/libphp.so
Go back:
yum remove php*
yum-config-manager --disable remi-php80,
yum-config-manager --enable remi-php74,
systemctl restart httpd # with php 7.4
Repeat with different package settings.
My httpd config files:
autoindex.conf php.conf README shib.conf ssl.conf ssl.conf.rpmnew ssl.conf.rpmsave userdir.conf welcome.conf
I've even tried reinstalling httpd and building up from there. Still no go.
Contents of 20-php.conf
#
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
#
# Cannot load both php5, php7 and php modules
<IfModule !mod_php5.c>
<IfModule !mod_php7.c>
<IfModule prefork.c>
LoadModule php_module modules/libphp.so
</IfModule>
</IfModule>
</IfModule>
Contents of php.conf :
#
# The following lines prevent .user.ini files from being viewed by Web clients.
#
<Files ".user.ini">
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Order allow,deny
Deny from all
Satisfy All
</IfModule>
</Files>
#
# 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
# mod_php options
<IfModule mod_php.c>
#
# Cause the PHP interpreter to handle files with a .php extension.
#
<FilesMatch \.(php|phar)$>
SetHandler application/x-httpd-php
</FilesMatch>
#
# 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"
php_value soap.wsdl_cache_dir "/var/lib/php/wsdlcache"
#php_value opcache.file_cache "/var/lib/php/opcache"
</IfModule>