0

I've been setting up a server using Apache 2.4, mpm_event, mod_proxy_fcgi and php_fpm.

In the mod_proxy_fcgi docs (https://httpd.apache.org/docs/2.4/mod/mod_proxy_fcgi.html) it mentions "For performance reasons, you will want to define a worker representing the same fcgi:// backend."

Their example:

<FilesMatch "\.php$">
# Note: The only part that varies is /path/to/app.sock
SetHandler  "proxy:unix:/path/to/app.sock|fcgi://localhost/"
</FilesMatch>

# Define a matching worker.
# The part that is matched to the SetHandler is the part that
# follows the pipe. If you need to distinguish, "localhost; can
# be anything unique.
<Proxy "fcgi://localhost/" enablereuse=on max=10>
</Proxy>

Now my question is; I have a php_fpm pool setup for each Vhost and specify the 'SetHandler' for each vhost so it uses the proper pool, should I be setting up a new proxy worker per vhost as well?

Example Vhost 1:

<FilesMatch "\.php$">
    SetHandler  "proxy:unix:/path/to/app1.sock|fcgi://app1/"
</FilesMatch>

<Proxy "fcgi://app1/" enablereuse=on max=10></Proxy>

Example Vhost 2:

<FilesMatch "\.php$">
    SetHandler  "proxy:unix:/path/to/app2.sock|fcgi://app2/"
</FilesMatch>

<Proxy "fcgi://app2/" enablereuse=on max=10></Proxy>

Or is using 'fcgi://localhost/' in each SetHandler the proper way?

1 Answers1

0

I realize I didn't fully understand what I was configuring. As the mod_proxy documentation says, Apache starts with 2 default workers for mod_proxy, one for Forward Proxy requests and one for Reverse Proxy requests. These workers are referring to MPM workers, this is what I was not understanding. In my case they are mpm_event workers, each run as they are configured in the Apache config.

There is no correct answer to this question without first considering your usage and the worker configuration. If you feel that one mpm worker can handle all of your sites there is no reason to not use the default worker, fcgi://localhost. If you have one large site and want it to have its own mpm worker all you need to do is specify a new Proxy and set your handler to use it.