In this post we are going to see how to configure different versions of PHP in Apache.
In our case the server is working with PHP 5.6 and we are going to add a virtualhost to work with PHP 7.1, we already saw previously how to install PHP 7.1 in GNU/Linux:
How to install PHP 7.1 on GNU/Linux
We begin by installing the necessary packages:
Redhat:
Bash
yum install rh-php71-php-fpm-7.1.8-1.el7.x86_64Debian:
Bash
apt -y install php-fpmWe create the Virtualhost in which we are going to configure PHP 7.1
Apache
cat /etc/httpd/conf.d/lab.red-orbita.com.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName lab.red-orbita.com
ServerAlias lab.red-orbita.com
DocumentRoot /var/www/lab/
ErrorLog /var/log/httpd/lab.red-orbita.com-error_log
CustomLog /var/log/httpd/lab.red-orbita.com-access_log combined
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/lab/$1
<Directory «/var/www/lab/»>
DirectoryIndex index.html index.php
AllowOverride All
Require all granted
</Directory>
</VirtualHost>We configure the Listen of php-fpm, in my case since I have installed it with REMI the location is: /etc/opt/rh/rh-php71/php-fpm.
Bash
sed -i «s/listen =.*/listen = 127.0.0.1:9000/» /etc/opt/rh/rh-php71/php-fpm.d/www.confWe restart apache and php-fpm
Red hat:
Bash
systemctl restart httpd rh-php71-php-fpm.serviceDebian:
We activate the module and restart
Bash
a2enmod proxy_fcgi
systemctl restart php7.1-fpm apache2All the best.
:wq!
Comments