Inicio Linux & Systems Networks & Infrastructure Cybersecurity Cloud & DevOps SIEM & Monitoring DFIR & Threat Intel Development & Other Todas las categorias Herramientas Proyectos Sobre

Configurar varias versiones de PHP en apache

Read in English
Configurar varias versiones de PHP en apache

Tabla de contenidos

En esta entrada vamos a ver como configurar diferentes versiones de PHP en apache.

En nuestro caso el servidor esta trabajando con PHP 5.6 y vamos agregar un virtualhost para tabajar con PHP 7.1, ya vimos anteriormente como instalar PHP 7.1 en GNU/Linux:

Como instalar PHP 7.1 en GNU/Linux

Comenzamos insalamos los paquetes necesarios:

Redhat :

bash
yum install rh-php71-php-fpm-7.1.8-1.el7.x86_64

Debian:

bash
apt -y install php-fpm

Creamos el Virtualhost  en el cual vamos a configurar 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>

Configuramos el Listen de php-fpm, en mi caso dado que lo he instalado con REMI la ubicación es: /etc/opt/rh/rh-php71/php-fpm.d/, normalmente la ubicación sería  /etc/php-fpm.d/

bash
sed -i «s/listen =.*/listen = 127.0.0.1:9000/» /etc/opt/rh/rh-php71/php-fpm.d/www.conf

Reiniciamos apache y php-fpm

Red hat:

bash
systemctl restart httpd  rh-php71-php-fpm.service

Debian:

Activamos el modulo y reiniciamos

bash
a2enmod proxy_fcgi
systemctl restart php7.1-fpm apache2

Un saludo.

:wq!

Comentarios