When installing PHP 7 from Remi repository, you'll need to find the correct module path for Apache configuration. The standard path for the PHP Apache module is typically:
/usr/lib64/httpd/modules/libphp7.so
However, with Remi's installation, you might find it in a different location. Run this command to locate it:
find / -name "*php7*.so" 2>/dev/null
Here's the proper way to configure Apache to use PHP 7 from Remi repo:
LoadModule php7_module /usr/lib64/httpd/modules/libphp7.so
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
Add PHP file type handling:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
Create a test PHP file in your web root:
echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php
Then restart Apache and check:
sudo systemctl restart httpd
curl http://localhost/phpinfo.php
If you encounter permission issues:
sudo chown -R apache:apache /var/www/html
sudo chmod -R 755 /var/www/html
If PHP isn't executing, check SELinux:
sudo setsebool -P httpd_execmem 1
For better performance, consider using PHP-FPM:
sudo yum install php70-php-fpm
sudo systemctl start php70-php-fpm
Then configure Apache to use FPM:
<FilesMatch \.php$>
SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>
When installing PHP7 from Remi repository on CentOS/RHEL 6 systems, users typically follow these steps:
sudo yum -y install httpd
sudo yum -y install epel-release
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
sudo rpm -Uvh remi-release-6*.rpm
sudo yum -y --enablerepo=remi,remi-test install php70
scl enable php70 'php -v'
sudo ln -s /usr/bin/php70 /usr/bin/php
The main obstacle occurs when trying to configure Apache to use the PHP7 module. The typical approach would be to add these directives to httpd.conf:
LoadModule php7_module unknown_path
<FilesMatch \\.php$>
SetHandler application/x-httpd-php
</FilesMatch>
For proper Apache integration with PHP7 from Remi repo, you'll need these additional steps:
# Install the PHP Apache module
sudo yum -y --enablerepo=remi,remi-test install php70-php
# Create the necessary symlink
sudo ln -s /opt/remi/php70/root/usr/lib64/httpd/modules/libphp7.so /usr/lib64/httpd/modules/
# Edit your Apache configuration
sudo vi /etc/httpd/conf.d/php70-php.conf
Add these contents to the php70-php.conf file:
LoadModule php7_module modules/libphp7.so
<FilesMatch \\.php$>
SetHandler application/x-httpd-php
</FilesMatch>
# Path to php.ini
PHPINIDir /etc/opt/remi/php70
After making these changes, perform these verification steps:
# Restart Apache
sudo service httpd restart
# Create a test PHP file
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/test.php
# Check the PHP version
curl http://localhost/test.php | grep "PHP Version"
For better performance, consider using PHP-FPM:
# Install PHP-FPM
sudo yum -y --enablerepo=remi,remi-test install php70-php-fpm
# Configure Apache
<FilesMatch \\.php$>
SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>
# Start PHP-FPM
sudo systemctl start php70-php-fpm
sudo systemctl enable php70-php-fpm