Different PHP Version per folder when using FastCGI Implementation
After few expertiments - the result:
Tested on CentOS 7 and Debian 9.. with Additional php version added In case we have added website and select for it to use PHP 7.2 from Domain Menu.
To use (for example php 5.6) for directory /var/www/domain.com/web/iwantanotherphp/ create:
- Create .htaccess file in folder that we want to use different version with content: cat /var/www/domain.com/web/iwantanotherphp/.htaccess
<IfModule mod_fcgid.c>
AddHandler fcgid-script .php
FcgidWrapper /var/www/domain.com/web/iwantanotherphp/php56.fcgi .php
</IfModule>
- Create PHP 5.6 wrapper in same folder with content: cat /var/www/domain.com/web/iwantanotherphp/php56.fcgi
#!/bin/bash
DEFAULTPHPINI=/etc/php/5.6/cgi/php.ini
exec /usr/bin/php-cgi5.6 -c ${DEFAULTPHPINI}
(if you want may copy php.ini in same folder with name php56.ini)
and mod wrapper to look like that:
#!/bin/bash
DEFAULTPHPINI=/var/www/domain.com/web/iwantanotherphp/php56.ini
exec /usr/bin/php-cgi5.6 -c ${DEFAULTPHPINI}
Thats it. :)
Crate one phpinfo.php in:
/var/www/domain.com/web/
and one in tools subfolder:
/var/www/domain.com/web/tools
- To check your perfect work b- open:
https://domain.com/phpinfo.php https://domain.com/iwantanotherphp/phpinfo.php
This is currently only possible when PHP version that we selected for Domain is FastCGI/CGI.
I think about that and it will be great if it is possible to be integrated into the ISPConfig control panel - it will be really very useful for all users who use ISPConfig ;)