PHP8 and php_fpm on FBSD14

I run 14.2-RELEASE-p3 amd64
I've tried both php installed with pkg and compiled from ports but everytime when I add
Code:
LoadModule php_module         libexec/apache24/libphp.so
to httpd.conf apache it wouldn't and when I try to start php-fpm I get:
Code:
# service php_fpm start
Performing sanity check on php-fpm configuration:
/usr/local/etc/rc.d/php_fpm: WARNING: failed precmd routine for php_fpm
Both commands
Code:
root@...#/usr/local/bin/php -m
root@...#/usr/local/bin/php -i
root@...# php -r 'phpinfo();'
root@...#
don't display a single word.
FPM gives me this
Code:
# /usr/local/sbin/php-fpm -v
PHP 8.4.6 (fpm-fcgi) (built: Apr 21 2025 14:20:34) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.4.6, Copyright (c) Zend Technologies
and
Code:
# /usr/local/sbin/php-fpm -i
gives me full version of phpinfo()

Where to look for error?
 
The php_module is www/mod_php84 and is the exact opposite of what you're trying to achieve. Do not load this module, uninstall it, you don't need it. It's mutually exclusive with PHP-FPM (mod_php needs mpm_prefork; PHP-FM needs mpm_event).

In order to get PHP-FPM working you'll need to switch Apache from mpm_prefork_module (enabled by default) to mpm_event_module.

httpd.conf:
Code:
LoadModule mpm_event_module libexec/apache24/mod_mpm_event.so         #<---- enable
#LoadModule mpm_prefork_module libexec/apache24/mod_mpm_prefork.so    #<--- disable
#LoadModule mpm_worker_module libexec/apache24/mod_mpm_worker.so

Then create a /usr/local/etc/apache24/modules.d/001_php-fpm.conf:
Code:
LoadModule proxy_module libexec/apache24/mod_proxy.so
LoadModule proxy_fcgi_module libexec/apache24/mod_proxy_fcgi.so

<IfModule proxy_fcgi_module>
  <IfModule dir_module>
     DirectoryIndex index.php
  </IfModule>
  <FilesMatch "\.(php|phtml|inc)$">
     SetHandler "proxy:fcgi://127.0.0.1:9000"
  </FilesMatch>
</IfModule>

That should do it.
 
The php_module is www/mod_php84 and is the exact opposite of what you're trying to achieve. Do not load this module, uninstall it, you don't need it. It's mutually exclusive with PHP-FPM (mod_php needs mpm_prefork; PHP-FM needs mpm_event).

In order to get PHP-FPM working you'll need to switch Apache from mpm_prefork_module (enabled by default) to mpm_event_module.

httpd.conf:
Code:
LoadModule mpm_event_module libexec/apache24/mod_mpm_event.so         #<---- enable
#LoadModule mpm_prefork_module libexec/apache24/mod_mpm_prefork.so    #<--- disable
#LoadModule mpm_worker_module libexec/apache24/mod_mpm_worker.so

Then create a /usr/local/etc/apache24/modules.d/001_php-fpm.conf:
Code:
LoadModule proxy_module libexec/apache24/mod_proxy.so
LoadModule proxy_fcgi_module libexec/apache24/mod_proxy_fcgi.so

<IfModule proxy_fcgi_module>
  <IfModule dir_module>
     DirectoryIndex index.php
  </IfModule>
  <FilesMatch "\.(php|phtml|inc)$">
     SetHandler "proxy:fcgi://127.0.0.1:9000"
  </FilesMatch>
</IfModule>

That should do it.
Thought of that but I still get:

# service php_fpm start
Performing sanity check on php-fpm configuration:
/usr/local/etc/rc.d/php_fpm: WARNING: failed precmd routine for php_fpm
 
What's in /usr/local/etc/php-fpm.conf?
I did clean install from the ports and left config files untouched. So from the installation, just three lines ale uncommented
Code:
[global]
pid = run/php-fpm.pid
include=/usr/local/etc/php-fpm.d/*.conf

Accordingly in /usr/local/etc/php-fpm.d/www.conf
Code:
[www]
user = www
group = www
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
 
The precmd stage of the start script does a configuration check, it looks like that's failing.

What does /usr/local/sbin/php-fpm -t output?
 
Unless something's changed between 8.2 and 8.4, it should output the configuration test is correct, or not.
Code:
# /usr/local/sbin/php-fpm -t
[22-Apr-2025 14:15:56] NOTICE: configuration file /usr/local/etc/php-fpm.conf test is successful
 
Unless something's changed between 8.2 and 8.4, it should output the configuration test is correct, or not.
Code:
# /usr/local/sbin/php-fpm -t
[22-Apr-2025 14:15:56] NOTICE: configuration file /usr/local/etc/php-fpm.conf test is successful
===> Cleaning for php82-8.2.28
root@...:/usr/ports/lang/php82 # /usr/local/sbin/php-fpm -t
root@...:/usr/ports/lang/php82 #

No luck so far :(

===> Cleaning for php81-8.1.32
root@...:/usr/ports/lang/php81 #
root@...:/usr/ports/lang/php81 # /usr/local/sbin/php-fpm -t
root@...:/usr/ports/lang/php81 #

Not at all. The only thing that works is this

root@...:/usr/ports/lang/php81 # /usr/local/sbin/php-fpm -i
phpinfo()
PHP Version => 8.1.32.... and the rest of phpinfo();
 
Back
Top