I have an Apache / 2.4.10 (Ubuntu) server running a website in php 5.5. But I'm creating a new site and it needs php 5.6. Is it possible to have two versions of php installed on my server and use each one in different folders?
I have an Apache / 2.4.10 (Ubuntu) server running a website in php 5.5. But I'm creating a new site and it needs php 5.6. Is it possible to have two versions of php installed on my server and use each one in different folders?
Example in Linux Mint 18
Assuming that Apache is installed, the virtual host is created for both projects and added the necessary php PPAs. Let's assume the site56.local project in php5.6 and the site70.local project in php7.0.
Install php5.6-fpm and php7.0fpm with the following command:
sudo apt-get install php7.0-fpm
Create two files in / usr / lib / cgi-bin / and save
sudo nano /usr/lib/cgi-bin/php56-fcgi
sudo nano /usr/lib/cgi-bin/php70-fcgi
Open the php56 conf file "/etc/apache2/conf-available/php5.6-fpm.conf" add the following settings and save.
<IfModule mod_fastcgi.c> AddHandler php56-fcgi .php Action php56-fcgi /php56-fcgi Alias /php56-fcgi /usr/lib/cgi-bin/php56-fcgi -socket /var/run/php/php5.6-fpm.sock -pass-header Authorization Action php70-fcgi /php70-fcgi Alias /php70-fcgi /usr/lib/cgi-bin/php70-fcgi -socket /var/run/php/php7.0-fpm.sock -pass-header Authorization </IfModule> <Directory /usr/lib/cgi-bin> Require all granted </Directory>
Now enable the new Apache configuration.
sudo a2enconf php5.6-fpm
If you installed php5.6 and php5.7, check if you disabled both and restarted Apache.
sudo a2dismod php5.6 php7.0
sudo systemctl restart apache2
Create an .htacces file in the project that should be in php7.0 and add the following Handler.
AddHandler php70-fcgi .php
Now create a phpinfo file in the project and see if it works.
Note: Verify that htaccess is enabled on your apache2.conf or httpd.conf.
site70: