Php fpm on apache

From Tom's notes
Revision as of 01:57, 24 April 2021 by Tom (talk | contribs) (Created page with "Make sure to have following flags in make.conf: <source> USE="fpm threads" APACHE2_MODULES="proxy_fcgi" APACHE2_MPMS="event" </source> Emerge apache / php to activate flags....")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Make sure to have following flags in make.conf:

USE="fpm threads"
APACHE2_MODULES="proxy_fcgi"
APACHE2_MPMS="event"

Emerge apache / php to activate flags. In case of using redis

emerge -v1 dev-php/pecl-redis

Set user and group to apache for php-fpm in /etc/php/fpm-php7.4/fpm.d/www.conf

user = apache
group = apache

Add and start php-fpm

rc-update add php-fpm default
/etc/init.d/php-fpm start

Disable standard PHP module in apache by editing /etc/conf.d/apache2 and removing '-D PHP'

Activate php-fpm in apache via the fcgi proxy:

        ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/localhost/htdocs/$1
        DirectoryIndex index.php

Make sure to use the same path in the fcgi url to reference the path on your server (documentroot).

Restart apache