Migrating mod_php7 to php-fpm

I actually struggled a bit today to find what I needed. There was a decent start with SDB:Apache FastCGI and PHP-FPM configuration, but missed a few things.
/etc/sysconfig/apache2
If you're migrating, you can have both worker and prefork installed, just edit the APACHE_MPM variable name to switch. Same with having 'php7' in/out APACHE_MODULES.
mod_fcgi.conf
Above article was incomplete, more Googling showed:
<FilesMatch "\.(php|customext)$">
SetHandler "proxy:fcgi://127.0.0.1:9000/"
</FilesMatch>
<Proxy fcgi://127.0.0.1:9000>
ProxySet connectiontimeout=30 timeout=21600
</Proxy>
RewriteCond %{REQUEST_FILENAME} \.(php|customext)$
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f
RewriteRule (.*) - [H=text/html]
php7.conf
Can just rename this so it doesn't load when testing fcgi.
php.ini:
If you're migrating, you can copy the /etc/php7/apache2/php.ini to /etc/php7/fpm/php.ini otherwise you can strike problems (such as browscap missing ini location, etc).
vhosts.d:
If you're using vhosts, or custom php extensions, you should add to your VirtualHost
<Files ~ "\.(php|customext?)$">
SetHandler "proxy:fcgi://127.0.0.1:9000/"
</Files>
php-fpm.d:
If you're using custom extensions, and have the parameter security.limit_extensions enabled in your pool config, you should add the extension there.

I'd only remove apache2-mod_php7 after all the above is working. If you don't remove it, it can add the apache2/conf.d/ referennce again during package updates, which you don't want.

HTH

Sign In or Register to comment.