1

I'm looking to run both PHP 5.6 and 7.1 in my development server (Debian 9), with Apache. I know that Nginx can easily handle this, but I really need Apache.

Here so confs

# My main configuration file, running with PHP7.1

<VirtualHost xx.xx.xx.xx:80>
    ServerName www.mydomain.com
    ServerAlias mydomain.com

    DocumentRoot /var/www/mydomain.com/html
</VirtualHost>

<VirtualHost xx.xx.xx.xx:80>
    ServerName xx.xx.xx.xx

    <Directory />
        Deny from all
    </Directory>
</VirtualHost>


# PHP 5.6

<VirtualHost xx.xx.xx.xx:80>
    ServerName foo.mydomain.com

    DocumentRoot /var/www/foo.mydomain.com/html

    <FilesMatch \.php$>
        SetHandler "proxy:unix:/var/run/php/php5.6-fpm.sock"
    </FilesMatch>
</VirtualHost>

The 7.1 is working, while 5.6 returns a 404. Thanks !

Treast
  • 1,095
  • 1
  • 9
  • 20

2 Answers2

1

If you have already installed PHP 5.6 and PHP 7.1 in your laptop and which has Apache as web server. Then use below command to run both PHP version alternatively.

Steps to run PHP 5.6 and stop PHP 7.1 :

  • sudo a2dismod php7.1
  • sudo a2enmod php5.6
  • sudo service apache2 restart

Steps to run PHP 7.1 and stop PHP 5.6 :

  • sudo a2dismod php5.6
  • sudo a2enmod php7.1
  • sudo service apache2 restart

Finally run phpinfo(); to check which version of php is running currently.

Note: To install PHP7.1 in Debian Jessie, use below link. https://techglimpse.com/install-php-debian-jessie-linux/

Ortomala Lokni
  • 56,620
  • 24
  • 188
  • 240
Rana Pratap Singh
  • 867
  • 12
  • 18
  • Combined with the answer of [Install php5.6 in debian 9](https://stackoverflow.com/questions/46378017/install-php5-6-in-debian-9), it works also in Debian Stretch. Thank you. – Ortomala Lokni Dec 23 '17 at 17:51
0

Similar problem have already been asked. Go to this link. Please read everything on given link. This may help. Run multiple php version on Apache serve using fast-cgi