Instructions for installing and configuring PHP version 7.x on a newly-provisioned RHEL 8 VM.
Check default versions and locations
$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 8.6 (or latest 8.x version)
$ httpd -v
Server version: Apache/2.4.37 (Red Hat Enterprise Linux)
$ php -v
PHP 7.4.1 (cli)
$ which php
/usr/bin/php
Utilities
$ yum install nano git mod_ssl unzip wget rsync
Create the php.conf file, if necessary
If the /etc/httpd/conf.d/php.conf
file does not exist, create it and then add these lines:
#
# Cause the PHP interpreter to handle files with a .php extension.
#
<FilesMatch \.php$>
# SetHandler application/x-httpd-php
SetHandler "proxy:fcgi://127.0.0.1:9000" [Note: Determine if this line is necessary]
</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
#php_value session.save_handler "files"
#php_value session.save_path "/var/lib/php/session"
Install newer PHP using Software Collections, if necessary
$ yum install rh-php71 rh-php71-php-fpm$ scl enable rh-php71 bash$ php -vPHP 7.1.8 (cli)
$ systemctl start rh-php71-php-fpm$ systemctl enable rh-php71-php-fpmCreated symlink from /etc/systemd/system/multi-user.target.wants/rh-php71-php-fpm.service to /usr/lib/systemd/system/rh-php71-php-fpm.service.$ systemctl restart httpd$ mv /usr/bin/php /usr/bin/phpOLD$ which php/opt/rh/rh-php71/root/usr/bin/php$ ln -s /opt/rh/rh-php71/root/usr/bin/php /usr/bin/php
Configure php.ini
Set the timezone, extension directory and enable error reporting for a development environment:
$ vi /etc/php.ini
date.timezone = America/New_York
extension_dir = "/usr/lib64/php/modules"
error_reporting = E_ALL
display_errors = On
$ systemctl restart httpd
$ systemctl restart php-fpm
$ cd /var/www/html
$ php -i | less
Additional recommended packages
You will also likely want to install these packages.
PHP packages for MySQL/MariaDB
$ yum install mariadb-server mariadb
[php-mysql rh-php71-php-mysqlnd rh-php71-php-pdo]
PHP packages for Drupal
$ yum install rh-php71-php-mbstring rh-php71-php-gd rh-php71-php-pecl-apcu rh-php71-php-ldap drush
Open ports in local firewalls
You may also need to create vhosts and open local firewall ports for 80 and 443 .
Allow database connection in firewalls
If you're going to connect to an external database, make sure that the firewalls (http://fw.noc.gatech.edu/) allow a 3306/tcp connection on that external database server (i.e. leviathan.cc) from your new VM's IP address. If newer versions of Mysql and PHP do not allow you to connect to leviathan (because the old insecure authentication is allowed), you may need to connect instead to the sarge.cc database server.