phpfm not work

Started by ownerserv, May 01, 2024, 05:42:52 PM

Previous topic - Next topic

ownerserv

phpfm not work any site getmassge

and file /opt/alt/php-fpm83/usr/var/sockets/
olnly file (cwpsvc.sock - nobody.sock)

[Wed May 01 20:26:34.432274 2024] [proxy:error] [pid 1558366:tid 140555311548160] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /opt/alt/php-fpm83/usr/var/sockets/a7walmas.sock (*:80) failed
[Wed May 01 20:26:34.432309 2024] [proxy_fcgi:error] [pid 1558366:tid 140555311548160] [client 185.191.171.13:47462] AH01079: failed to make connection to backend: httpd-UDS

overseer

If you added PHP-FPM 8.3, you have to move forward the user config files from 8.1 or 8.2, editing their contents to reflect the proper version...

cp /opt/alt/php-fpm82/usr/etc/php-fpm.d/users/user.conf /opt/alt/php-fpm83/usr/etc/php-fpm.d/users/user.conf
nano /opt/alt/php-fpm83/usr/etc/php-fpm.d/users/user.conf

Change the socket and slowlog references to the new 8.3 version:
[user]
listen = /opt/alt/php-fpm83/usr/var/sockets/frogstew.sock
listen.allowed_clients = 127.0.0.1

;listen.owner = "user"
listen.group = "nobody"
listen.mode = 0660
user = "user"
group = "user"

;request_slowlog_timeout = 15s
;slowlog = /opt/alt/php-fpm83/usr/var/log/php-fpm-slowlog-user.log

pm = ondemand
pm.max_children = 4
pm.max_requests = 4000
pm.process_idle_timeout = 15s

;listen.backlog = -1
;request_terminate_timeout = 0s
rlimit_files = 131072
rlimit_core = unlimited
catch_workers_output = yes

env[HOSTNAME] = $HOSTNAME
env[TMP] = /home/user/tmp
env[TMPDIR] = /home/user/tmp
env[TEMP] = /home/user/tmp
env[PATH] = /usr/local/bin:/usr/bin:/bin

JM_Stoorvogel

@overseer: how come these templates aren't automatically generated? If a user now choses to switch to php-fpm from php-cgi, the website doesn't work anymore.

And there's no way to do this automatically.

Am I missing something? Seems like a big issue to me.

overseer

I guess when you're establishing a major new branch version of PHP, it can be expected that you will need to do some housekeeping. This does give you control over what versions of PHP are available to which users. This perl one-liner takes care of updating the user conf for you:
cp -R /opt/alt/php-fpm82/usr/etc/php-fpm.d/users /opt/alt/php-fpm83/usr/etc/php-fpm.d
perl -p -i -e 's/82/83/' /opt/alt/php-fpm83/usr/etc/php-fpm.d/users/*.conf
service php-fpm83 restart

JM_Stoorvogel

How about this in a crontab:


#!/bin/bash

#script for updating php-fpm scripts for users on CWPro7

templatefile=/usr/local/cwpsrv/htdocs/resources/conf/web_servers/vhosts/php-fpm/default.tpl

template=`cat $templatefile`


for i in /opt/alt/php-fpm*; do
        phpver=${i: -2}
        targetdir="/opt/alt/php-fpm${phpver}/usr/etc/php-fpm.d/users"

        for u in /home/*; do
                if [ -d "$u" ]; then
                        user=${u/\/home\//}
                        targetfile=${targetdir}/${user}.conf

                        content=${template//%phpfpmver%/php-fpm${phpver}}
                        content=${content//%backend%/$user}
                        content=${content//%username%/$user}
                        content=${content//%home%//home}

                        echo "$content" > $targetfile
                fi
        done

        systemctl restart php-fpm${phpver}
done


it can probably be adjusted and better, with update en overwrite modes, but it works well...