Solved Apache 2.4 + PHP 7.2.x + PHP-FPM Daemon (Multiple Pools) Resulting in "File not found"

I thought I had everything working correctly as a previous thread in Web and Network Services. I cleaned things up and organized and after doing so; things stopped working. I am 100% positive my SetHandler line is exactly what it needs to be. However each site isn't processing PHP for some reason.

Domain/index.html works fine. /index.php results in "File not found."

Here is the breakdown! (Domain #1 sharpenyoursword.org is having a DNS update and I manually have /etc/hosts updated on my workstation to work on it) -- It was working fine until I added more than 1 at a time I believe. This is as clean as my setup has been so far. Looking forward to getting through this barrier! Thanks again everyone! anlashok always seems to be very helpful regarding Apache, PHP and PHP-FPM! Much obliged!

APACHE 2.4: /usr/local/etc/apache24/httpd.conf:

Contents of httpd.conf:


Code:
ServerRoot "/usr/local"
LoadModule mpm_event_module libexec/apache24/mod_mpm_event.so
Listen 104.36.16.72:80

# LOGGING - MAIN APACHE

ErrorLog "/usr/local/www/apache24/logs/error/apache24-main-error.log"

LogFormat "%h %l %u %t \"%r\" %>s %b" common
CustomLog /usr/local/www/apache24/logs/access/apache24-access_log common

# ALT APACHE MODES (NON-PHP-FPM)

#LoadModule mpm_prefork_module libexec/apache24/mod_mpm_prefork.so
#LoadModule mpm_worker_module libexec/apache24/mod_mpm_worker.so

# BARE MINIMUM - REQUIRED

LoadModule authn_core_module libexec/apache24/mod_authn_core.so
LoadModule authz_core_module libexec/apache24/mod_authz_core.so
LoadModule log_config_module libexec/apache24/mod_log_config.so
LoadModule expires_module libexec/apache24/mod_expires.so
LoadModule headers_module libexec/apache24/mod_headers.so
LoadModule version_module libexec/apache24/mod_version.so
LoadModule unixd_module libexec/apache24/mod_unixd.so
LoadModule vhost_alias_module libexec/apache24/mod_vhost_alias.so
LoadModule dir_module libexec/apache24/mod_dir.so
LoadModule rewrite_module libexec/apache24/mod_rewrite.so
LoadModule mime_module  libexec/apache24/mod_mime.so
LoadModule actions_module libexec/apache24/mod_actions.so
LoadModule alias_module libexec/apache24/mod_alias.so
LoadModule authz_host_module libexec/apache24/mod_authz_host.so
LoadModule access_compat_module libexec/apache24/mod_access_compat.so
LoadModule proxy_module libexec/apache24/mod_proxy.so
LoadModule proxy_fcgi_module libexec/apache24/mod_proxy_fcgi.so

# CHOSEN MODULES - EXTENDABLES

LoadModule authz_user_module libexec/apache24/mod_authz_user.so
LoadModule auth_basic_module libexec/apache24/mod_auth_basic.so
LoadModule autoindex_module libexec/apache24/mod_autoindex.so

LoadModule authz_dbm_module libexec/apache24/mod_authz_dbm.so
LoadModule authz_owner_module libexec/apache24/mod_authz_owner.so
LoadModule authnz_fcgi_module libexec/apache24/mod_authnz_fcgi.so


# MOD SECURITY

LoadModule unique_id_module libexec/apache24/mod_unique_id.so
#LoadModule security2_module libexec/apache24/mod_security2.so
#Include /usr/local/etc/modsecurity/*.conf
# THIRD PARTY MODULES

IncludeOptional etc/apache24/modules.d/[0-9][0-9][0-9]_*.conf

<IfModule unixd_module>

User www
Group www

</IfModule>

## Apache 2.4 Daemon Hardening

# Prevent Apache from sending identifying information to a Client
ServerTokens Prod
ServerSignature Off

# REMAINDER ROOT SERVER CONFIG

<IfModule alias_module>

    ScriptAlias /cgi-bin/ "/usr/local/www/apache24/cgi-bin/"

</IfModule>

<IfModule cgid_module>

</IfModule>

<Directory "/usr/local/www/apache24/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

<IfModule headers_module>

</IfModule>

<IfModule mime_module>

    TypesConfig etc/apache24/mime.types

    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

</IfModule>

<IfModule proxy_html_module>
Include etc/apache24/extra/proxy-html.conf

</IfModule>

<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>

Include etc/apache24/Includes/*.conf
Include etc/apache24/Vhosts-Enabled/*.conf


Directory w/ Virtualhosts = /usr/local/etc/apache24/Vhosts-Enabled/

Contents of /usr/local/etc/apache24/Vhosts-Enabled/:


001_www.sharpenyoursword.org.conf

Contents:

Code:
# TLD - SHARPENYOURSWORD.ORG

<VirtualHost sharpenyoursword.org:80>

ServerAdmin admin@sharpenyoursword.org

ServerName sharpenyoursword.org:80

DocumentRoot "/usr/local/www/apache24/data/sysorgmain/"

<Directory "/usr/local/www/apache24/data/sysorgmain/">

    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
</Directory>

<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>

<Files ".ht*">
    Require all denied
</Files>

ErrorLog "/usr/local/www/apache24/logs/error/001_apache24-sharpenyoursword.org-main-error.log"

LogFormat "%h %l %u %t \"%r\" %>s %b" common
CustomLog /usr/local/www/apache24/logs/access/001_apache24-sharpenyoursword.org-access_log common

LogLevel warn

<IfModule log_config_module>

    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
    </IfModule>

</IfModule>

## SHARPENYOURSWORD.ORG
<FilesMatch "\.php$">
    SetHandler  "proxy:fcgi://127.0.0.1:9000/usr/local/www/apache24/data/sysorgmain/"
</FilesMatch>

</VirtualHost>

002_www.sharpenyoursword.net.conf

Contents:

Code:
# TLD - SHARPENYOURSWORD.NET

<VirtualHost sharpenyoursword.net:80>

ServerAdmin admin@sharpenyoursword.net

ServerName sharpenyoursword.net:80

DocumentRoot "/usr/local/www/apache24/data/sysnetmain/"

<Directory "/usr/local/www/apache24/data/sysnetmain/">

    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
</Directory>

<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>
<Files ".ht*">
    Require all denied
</Files>

ErrorLog "/usr/local/www/apache24/logs/error/002_apache24-sharpenyoursword.net-main-error.log"

LogFormat "%h %l %u %t \"%r\" %>s %b" common
CustomLog /usr/local/www/apache24/logs/access/002_apache24-sharpenyoursword.net-access_log common

LogLevel warn

<IfModule log_config_module>

    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
    </IfModule>

</IfModule>

<FilesMatch "\.php$">
    SetHandler  "proxy:fcgi://127.0.0.1:9100/usr/local/www/apache24/data/sysnetmain/"
</FilesMatch>

</VirtualHost>

003_www.thewarriorsdojo.com.conf

Contents:

Code:
# TLD - THEWARRIORSDOJO.COM

<VirtualHost thewarriorsdojo.com:80>

ServerAdmin admin@thewarriorsdojo.com

ServerName thewarriorsdojo.com:80

DocumentRoot "/usr/local/www/apache24/data/twdcommain/"

<Directory "/usr/local/www/apache24/data/twdcommain/">

    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
</Directory>

<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>
<Files ".ht*">
    Require all denied
</Files>

ErrorLog "/usr/local/www/apache24/logs/error/003_apache24-thewarriorsdojo-main-error.log"

LogFormat "%h %l %u %t \"%r\" %>s %b" common
CustomLog /usr/local/www/apache24/logs/access/003_apache24-thewarriorsdojo-access_log common


LogLevel warn

<IfModule log_config_module>

    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
    </IfModule>

</IfModule>

<FilesMatch "\.php$">
    SetHandler  "proxy:fcgi://127.0.0.1:9101/usr/local/www/apache24/data/twdcommain/"
</FilesMatch>

</VirtualHost>

004_www.wethepeopleonline.com.conf

Contents:

Code:
# TLD - WETHEPEOPLEONLINE.COM

<VirtualHost wethepeopleonline.com:80>

ServerAdmin admin@wethepeopleonline.com

ServerName wethepeopleonline.com:80

DocumentRoot "/usr/local/www/apache24/data/wtpocommain/"

<Directory "/usr/local/www/apache24/data/wtpocommain/">

    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
</Directory>

<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>
<Files ".ht*">
    Require all denied
</Files>

ErrorLog "/usr/local/www/apache24/logs/error/004_apache24-wethepeopleonline-main-error.log"

LogFormat "%h %l %u %t \"%r\" %>s %b" common
CustomLog /usr/local/www/apache24/logs/access/004_apache24-wethepeopleonline-access_log common


LogLevel warn

<IfModule log_config_module>

    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
    </IfModule>

</IfModule>

<FilesMatch "\.php$">
    SetHandler  "proxy:fcgi://127.0.0.1:9102/usr/local/www/apache24/data/wtpocommain/"
</FilesMatch>

</VirtualHost>

005_www_uscaselaw.org.conf

Contents:

Code:
# TLD - USCASELAW.ORG

<VirtualHost uscaselaw.org:80>

ServerAdmin admin@uscaselaw.org

ServerName uscaselaw.org:80

DocumentRoot "/usr/local/www/apache24/data/usclorgmain/"

<Directory "/usr/local/www/apache24/data/usclorgmain/">

    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
</Directory>

<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>
<Files ".ht*">
    Require all denied
</Files>

ErrorLog "/usr/local/www/apache24/logs/error/005_apache24-uscaselaw-main-error.log"

LogFormat "%h %l %u %t \"%r\" %>s %b" common
CustomLog /usr/local/www/apache24/logs/access/005_apache24-uscaselaw-access_log common

LogLevel warn

<IfModule log_config_module>

    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
    </IfModule>

</IfModule>

<FilesMatch "\.php$">
    SetHandler  "proxy:fcgi://127.0.0.1:9103/usr/local/www/apache24/data/usclorgmain/"
</FilesMatch>

</VirtualHost>

PHP 7 / PHP-FPM: /usr/local/etc/php-fpm.conf && /usr/local/etc/php-fpm.conf.d/www.conf

/usr/local/etc/php-fpm.conf contents:


Code:
;;;;;;;;;;;;;;;;;;;;;
; FPM Configuration ;
;;;;;;;;;;;;;;;;;;;;;

; All relative paths in this configuration file are relative to PHP's install
; prefix (/usr/local). This prefix can be dynamically changed by using the
; '-p' argument from the command line.

;;;;;;;;;;;;;;;;;;
; Global Options ;
;;;;;;;;;;;;;;;;;;

[global]
; Pid file
; Note: the default prefix is /var
; Default Value: none
pid = run/php-fpm.pid

; Error log file
; If it's set to "syslog", log is sent to syslogd instead of being written
; into a local file.
; Note: the default prefix is /var
; Default Value: log/php-fpm.log
error_log = log/php-fpm.log

; syslog_facility is used to specify what type of program is logging the
; message. This lets syslogd specify that messages from different facilities
; will be handled differently.
; See syslog(3) for possible values (ex daemon equiv LOG_DAEMON)
; Default Value: daemon
;syslog.facility = daemon

; syslog_ident is prepended to every message. If you have multiple FPM
; instances running on the same server, you can change the default value
; which must suit common needs.
; Default Value: php-fpm
syslog.ident = php-fpm

; Log level
; Possible Values: alert, error, warning, notice, debug
; Default Value: notice
;log_level = notice


; If this number of child processes exit with SIGSEGV or SIGBUS within the time
; interval set by emergency_restart_interval then FPM will restart. A value
; of '0' means 'Off'.
; Default Value: 0
;emergency_restart_threshold = 0

; Interval of time used by emergency_restart_interval to determine when
; a graceful restart will be initiated.  This can be useful to work around
; accidental corruptions in an accelerator's shared memory.
; Available Units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
;emergency_restart_interval = 0

; Time limit for child processes to wait for a reaction on signals from master.
; Available units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
;process_control_timeout = 0

; The maximum number of processes FPM will fork. This has been designed to control
; the global number of processes when using dynamic PM within a lot of pools.
; Use it with caution.
; Note: A value of 0 indicates no limit
; Default Value: 0
; process.max = 128

; Specify the nice(2) priority to apply to the master process (only if set)
; The value can vary from -19 (highest priority) to 20 (lowest priority)
; Note: - It will only work if the FPM master process is launched as root
;       - The pool process will inherit the master process priority
;         unless specified otherwise
; Default Value: no set
; process.priority = -19

; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging.
; Default Value: yes
;daemonize = yes

; Set open file descriptor rlimit for the master process.
; Default Value: system defined value
;rlimit_files = 1024

; Set max core size rlimit for the master process.
; Possible Values: 'unlimited' or an integer greater or equal to 0
; Default Value: system defined value
;rlimit_core = 0

; Specify the event mechanism FPM will use. The following is available:
; - select     (any POSIX os)
; - poll       (any POSIX os)
; - epoll      (linux >= 2.5.44)
; - kqueue     (FreeBSD >= 4.1, OpenBSD >= 2.9, NetBSD >= 2.0)
; - /dev/poll  (Solaris >= 7)
; - port       (Solaris >= 10)
; Default Value: not set (auto detection)
;events.mechanism = epoll

; When FPM is built with systemd integration, specify the interval,
; in seconds, between health report notification to systemd.
; Set to 0 to disable.
; Available Units: s(econds), m(inutes), h(ours)
; Default Unit: seconds
; Default value: 10
;systemd_interval = 10

;;;;;;;;;;;;;;;;;;;;
; Pool Definitions ;
;;;;;;;;;;;;;;;;;;;;

; Multiple pools of child processes may be started with different listening
; ports and different management options.  The name of the pool will be
; used in logs and stats. There is no limitation on the number of pools which
; FPM can handle. Your system will tell you anyway :)

; Include one or more files. If glob(3) exists, it is used to include a bunch of
; files from a glob(3) pattern. This directive can be used everywhere in the
; file.
; Relative path can also be used. They will be prefixed by:
;  - the global prefix if it's been set (-p argument)
;  - /usr/local otherwise
include=/usr/local/etc/php-fpm.d/*.conf

/usr/local/etc/php-fpm.d/www.conf contents:

Code:
[global]

pid = run/global-php-fpm.pid
error_log = log/global-php-fpm.log

syslog.facility = daemon
syslog.ident = php-fpm
log_level = notice

emergency_restart_threshold = 2
emergency_restart_interval = 30
process_control_timeout = 60
process.max = 128
daemonize = yes

[sharpenyoursword.org]

user = www
group = www
; this next line needs to match the wording of the httpd setHandler above, I chose your stated domain name
;listen = /var/run/$pool-php-fpm.sock
listen = 127.0.0.1:9000
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

[sharpenyoursword.net]

user = www
group = www
;listen = /var/run/$pool-php-fpm.sock
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

[thewarriorsdojo.com]

user = www
group = www
;listen = /var/run/$pool-php-fpm.sock
listen = 127.0.0.1:9101
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

[wethepeopleonline.com]

user = www
group = www
;listen = /var/run/$pool-php-fpm.sock
listen = 127.0.0.1:9102
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

[uscaselaw.org]

user = www
group = www
;listen = /var/run/$pool-php-fpm.sock
listen = 127.0.0.1:9103
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
 
Please read again what I said in your other thread, specifically this part about how to write the SetHandler line.

Code:
<VirtualHost ip.address:port>
    DocumentRoot "/usr/local/www/apache24/data/website/"
    <FilesMatch "\.php$">
       SetHandler  "proxy:fcgi://127.0.0.1:9100"
    </FilesMatch>
</VirtualHost>

Note that the SetHandler line does not and should not include the directory, it should only contain the IP address and the port of the php-fpm server.

Wrong:
Code:
<FilesMatch "\.php$">
    SetHandler  "proxy:fcgi://127.0.0.1:9102/usr/local/www/apache24/data/wtpocommain/"
</FilesMatch>

Correct:
Code:
<FilesMatch "\.php$">
    SetHandler  "proxy:fcgi://127.0.0.1:9102"
</FilesMatch>
 
Solved! I didn't understand that PHP-FPM daemon automatically knows to throw the PHP pages from the daemonIP:port to the Apache 2.4 Directory Tags.

Thank you as usual! :)
 
Back
Top