Solved PHP-FPM (Unix Sockets) to PHP-FPM (Daemon & Port) -- Difficulties

I was having difficulties with the server serving PHP queries using Unix Sockets for some strange reason. With that said I started to overhaul my configuration and read documentation.

I currently am using the following which is resulting in a 503 Service Unavailable.

Does anybody know how run a Virtualhost on a specific PORT example "9100" using PHP-FPM Daemon as opposed to Unix Sockets?

httpd.conf (FilesMatch):

Code:
<FilesMatch "\.php$">
    SetHandler  "proxy:fcgi://localhost:9100/usr/local/www/apache24/data/website/"
</FilesMatch>


www.conf (Domain):

Code:
[website]

user = www
group = www
listen = 127.0.0.1:9100
listen.owner = www
listen.group = www
listen.mode = 0660
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.max_requests = 500
request_terminate_timeout = 300
security.limit_extensions = .php

Results are 503 Service Unavailable. I want to designate every website on it's individual PORT PHP-FPM daemon; for both uses of Apache 2.4 and NGINX.

Is anyone setup like this and functioning?

I am going for speed and being able to manage hundreds of individual PHP-FPM pools simultaneously.


Thanks!

~TruthSword
 
/usr/local/etc/php-fpm.d # service php-fpm status
php_fpm is not running.

I get this everytime! Ever since the server was built (Christmas time last year). I don't understand why I cannot run the php_fpm daemon. Perhaps this is the reason why the 503 Service Unavailable.

Currently using PHP 7.2.x
 
I think you are misunderstanding what the SetHandler line is setting up. You are not telling it to serve a specific directory location, you are using it to tell Apache (or another webserver) what to do if Apache gets a request to send the web page back to the end user when it is a php file, eg "handle" that file request
  • Apache get a request to display "page_x.php"
  • Apache goes ok, I've got to process this php code, I'll send the php source code of "page_x.php" to the thing I know that handles it, in this case the php-fpm service and ask it to turn it into something I can send back to the user as a web page.
  • The php-fpm service reads the "page_x.php" code, interprets the php, turns it into html and returns to Apache that html as output
  • Apache then sends this html output to the requester as a web page.

In your Apache VirtualHost config the setting should be this, which means "For each file that ends with .php send it to the service listening on 127.0.0.1:9100".
Code:
<VirtualHost ip.address:port>
    DocumentRoot "/usr/local/www/apache24/data/website/"
    <FilesMatch "\.php$">
       SetHandler  "proxy:fcgi://127.0.0.1:9100"
    </FilesMatch>
</VirtualHost>

in the php-fpm config the corresponding setting needs to be this
Code:
listen = 127.0.0.1:9100

Note that if you set one to 127.0.0.1:9100 and the other to localhost:9100 that it not the same.

p.s. I would look in /var/log/php-fpm.log if php-fpm doesn't stay running after you start it, it should tell you why.
 
I think you are misunderstanding what the SetHandler line is setting up. You are not telling it to serve a specific directory location, you are using it to tell Apache (or another webserver) what to do if Apache gets a request to send the web page back to the end user when it is a php file, eg "handle" that file request
  • Apache get a request to display "page_x.php"
  • Apache goes ok, I've got to process this php code, I'll send the php source code of "page_x.php" to the thing I know that handles it, in this case the php-fpm service and ask it to turn it into something I can send back to the user as a web page.
  • The php-fpm service reads the "page_x.php" code, interprets the php, turns it into html and returns to Apache that html as output
  • Apache then sends this html output to the requester as a web page.

In your Apache VirtualHost config the setting should be this, which means "For each file that ends with .php send it to the service listening on 127.0.0.1:9100".
Code:
<VirtualHost ip.address:port>
    DocumentRoot "/usr/local/www/apache24/data/website/"
    <FilesMatch "\.php$">
       SetHandler  "proxy:fcgi://127.0.0.1:9100"
    </FilesMatch>
</VirtualHost>

in the php-fpm config the corresponding setting needs to be this
Code:
listen = 127.0.0.1:9100

Note that if you set one to 127.0.0.1:9100 and the other to localhost:9100 that it not the same.

p.s. I would look in /var/log/php-fpm.log if php-fpm doesn't stay running after you start it, it should tell you why.
anlashok,

After changing the httpd.conf block you shared. I disabled the one that I had and entered that one for testing. It switched the error message from 503 to 500 internal server error.
 
Looks to be solved! I changed it back to the other block and narrowed the problem by analyzing the logs. Thank you for reminding me to look in the logs. I checked a different set of logs given the name change on my configuration file and seen that there was port conflicts on the different sub-domain pools.

Much appreciated! Solved!
 
Back
Top