Yes, you’re right, I have parallel installation of php7.1 but virtualmin php-fpm seems to ignore it.
At the end, I managed to configure php-fpm with virtualmin, but I had to change and correct few things.
After installing php-fpm:
sudo apt-get install php-fpm
(as I have php7.0 and 7.1, I installed both of them)
I did re-check of virtualmin configuration:
VIRTUALMIN -> SYSTEM SETTINGS -> RE-CHECK CONFIGURATION
and enabled php-fpm for virtual site
VIRTUAL SERVER -> SERVER CONFIGURATION -> WEBSITE OPTIONS -> PHP script execution mode -> FPM (run as virtual server owner
.
Also, I had to enable mod_proxy
and mod_proxy_fcgi
apache modules:
WEBMIN -> SERVERS -> APACHE WEBSERVER -> tab GLOBAL CONFIGURATION -> CONFIGURE APACHE MODULES
Note: I disabled here PHP7.0/7.1, FCGID, MPM_PREFORK and enabled MPM_WORKER, PROXY, PROXY_FCGI.
Unfortunately, after this I was getting 500 errors, so additional manual steps had to be done for each virtual server.
First, in each php-fpm pool, I have had to add:
listen.owner = www-data
listen.group = www-data
listen.mode = 0666
This was only way to prevent next errors:
Permission denied: AH02454: FCGI: attempt to connect to Unix domain socket /var/php-fpm/148736275311367.sock (localhost) failed
AH01079: failed to make connection to backend: httpd-UDS
Next, as this virtualmin php-fpm is using unix socket implementation, I had to correct in every apache virtual server config file:
ProxyPassMatch ^/(..php(/.)?)$ unix:/var/php-fpm/YOUR-SOCKET-FILENAME.sock|fcgi://localhost/VIRTUAL-SERVER-ACCOUNT/wp/public_html/$1
into
ProxyPassMatch ^/(..php(/.)?)$ unix:/var/php-fpm/YOUR-SOCKET-FILENAME.sock|fcgi://localhost/VIRTUAL-SERVER-ACCOUNT/wp/public_html/
Note there is no $1 at end, this is really nicely explained on this link - https://wiki.apache.org/httpd/PHP-FPM
I hope these few quirks will be fixed in next release. Also, I hope it will be possible to choose which php version per virtual server to use.