I have a little Debian 9 server with Apache 2.4 installed. I need it to serve my home with a Nextcloud service, which requires PHP7.0. Then I also need to get it to serve a rather old service (http://www.refbase.net), that requires PHP5.6.
I'm no Apache expert and all I want, is to simply serve these two services for internal family use. Reading about, I seem to understand that this can be achieved by using the PHP5-FPM and PHP7.0-FPM services? I have both installed:
user@server:/$ sudo systemctl status php5-fpm [sudo] password of user: ● php5-fpm.service - The PHP FastCGI Process Manager Loaded: loaded (/lib/systemd/system/php5-fpm.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2019-11-05 22:08:08 GMT; 3 days ago
user@server:~$ sudo systemctl status php7.0-fpm ● php7.0-fpm.service - The PHP 7.0 FastCGI Process Manager Loaded: loaded (/lib/systemd/system/php7.0-fpm.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2019-11-09 16:48:14 GMT; 59min ago
I've also got these installed:
sudo apt install libapache2-mod-fcgid sudo a2enmod actions fcgid alias proxy_fcgi
So I created two folders in /var/www/ that are php56 and php70 with the idea of configuring two different virtual hosts.
<VirtualHost *:80> ServerName php56.example.com DocumentRoot /var/www/php56 <Directory /var/www/php56> Options -Indexes +FollowSymLinks +MultiViews AllowOverride All Require all granted </Directory> <FilesMatch \.php$> # Apache 2.4.10+ can proxy to unix socket SetHandler "proxy:unix:/var/run/php/php5.6-fpm.sock|fcgi://localhost/" </FilesMatch> </VirtualHost>
<VirtualHost *:80> ServerName php72.example.com DocumentRoot /var/www/php70 <Directory /var/www/php70> Options -Indexes +FollowSymLinks +MultiViews AllowOverride All Require all granted </Directory> <FilesMatch \.php$> SetHandler "proxy:unix:/var/run/php/php7.0-fpm.sock|fcgi://localhost/" </FilesMatch> </VirtualHost>
I created two files in the respective www directories created above:
echo "<?php phpinfo(); ?>" > /var/www/php56/index.php echo "<?php phpinfo(); ?>" > /var/www/php70/index.php
Both virtual sites are enabled but when I go to test them, they both show PHP 7.0 being enabled. When checking in the /var/run/php/ folder, I can only see the 7.0 FPM sock an pid files.
update-alternatives has PHP7.0 activated by default.
Any clues as to how I can serve both PHP versions at the same time so I can get both services running?