0

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

and then:

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>

and then:

<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?

Thanks

  • maybe helps stackoverflow.com/a/46831696/9216348 – Andra Nov 9 '19 at 18:20
  • @Andra, it appears that Stretch doesn't actually have php5.6-fpm but rather php5-fpm which does however point to php5.6-fpm: "php5-fpm is already the newest version (5.6.40+dfsg-0+deb8u7". When I try to run " sudo a2enconf php5-fpm", I get "ERROR: Conf php5-fpm does not exist!". I get the same if I run " sudo a2enconf php5.6-fpm". Mor importantly, I notice that when I execute phpinfo, I get "Apache 2.0 Handler" as Server API so its not even running cgi. – MiniTux Nov 17 '19 at 12:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.