Solved [Messenger Service with DirectAdmin] Docs missinformation for PHP-FPM

Ohm J

Verified User
Joined
Aug 16, 2019
Messages
1,865
Anyone using docs from


becarefully, it not state any information about PHP-MODE, as php-fpm doesn't work with this docs. It will trigger error "Permission denied",

Anyone using PHP-FPM, you must generate php handle for "csf" user and config "MESSENGERV3PHPHANDLER" inside "/etc/csf.conf" to use "csf" socket handle like


#/etc/csf/messenger/php-fpm.conf
Code:
[csf]
user = $pool
group = $pool
listen = /usr/local/php81/sockets/$pool.sock
listen.owner = $pool
listen.group = apache
listen.mode = 660
pm = ondemand
pm.max_children = 10
pm.process_idle_timeout = 20
pm.max_requests = 500
php_admin_value[open_basedir] = /home/csf/:/tmp/:/var/tmp/:/opt/alt/php81/usr/share/pear/:/dev/urandom:/usr/local/php81/lib/:/usr/local/php81/lib/:/usr/local/php82/lib/:/usr/local/php56/lib/:/usr/local/php74/lib/:/usr/local/lib/php/:/var/log/lfd_messenger.log
security.limit_extensions = .php .php52 .php53 .php54 .php55 .php56 .php60 .php70 .php71 .phtml .inc .php81

#/etc/csf/messenger/php-handle.conf
Code:
<If "-f %{REQUEST_FILENAME}">
        AddHandler "proxy:unix:/usr/local/php81/sockets/csf.sock|fcgi://localhost" .inc .php .phtml .php81
    </If>

#/etc/csf/csf.conf
#Find and replace
Code:
MESSENGERV3PHPHANDLER="Include /etc/csf/messenger/php-handle.conf"


becarefully, this will overwritten from custombuild, this is just example. Anyone want to use please make file at
"./directadmin/custombuild/custom/fpm/conf
#To generate php-handle for "csf" user
#/usr/local/php81/etc/php-fpm.conf
add this to last line
Code:
include=/etc/csf/messenger/php-fpm.conf


restart relate service.
Code:
service php-fpm81 reload
csf -ra
 
Last edited:
#update information on line
FROM
Code:
MESSENGERV3PHPHANDLER="/etc/csf/messenger/php-handle.conf"

TO
Code:
MESSENGERV3PHPHANDLER="Include /etc/csf/messenger/php-handle.conf"
 
Last edited:
Hello comunity
I'm new using Direct admin, and I'm happy to contribute.
I found this forum thread because after setting up MessengerV3, it kept showing the following error.
##################################################################################################################
Got error 'PHP message: PHP Warning: file_put_contents(/home/csf/unblock.txt): Failed to open stream: Permission denied in /home/csf/public_html/index.php on line 250PHP message: PHP Warning: file_put_contents(/var/log/lfd_messenger.log): Failed to open stream: Permission denied in /home/csf/public_html/index.php on line 251', referer:
###################################################################################################################
I couldn't fix the error even by giving more permissions than recommended in the CSF configuration documentation at https://docs.directadmin.com/operat...g/csf.html#messenger-service-with-directadmin
After much searching, I found the CSF installation documentation at https://download.configserver.com/csf/readme.txt
As indicated in the Messenger v2 and v3, the permissions and owners have to be the following:
/home/csf/ (Owner csf:csf, Permissions 711)
/home/csf/public_html/ (Owner csf:nobody, Permissions 711)
The first one was correct, but the second one had the wrong group, apparently CSF when creating the directory /home/csf/public_html under directadmin remains as the owner group of public_html apache.
When changing the apache group to nobody as indicated in the installation text, it started to work correctly.
I hope it is useful to those who, despite following your recommendations, continue to have problems with the Messenger configuration.
Greetings and thanks for the help.
 
Hi zEitEr-4
Thank you for your time and the modified tutorial, as soon as I have a little time I will try it and let you know how it works.Again, thank you for your time and dedication.
Kind regards
 
Hello zEitEr
I read your new tutorial, and I have some doubts.
MESSENGER_USER = "webapps"
Means that /home/csf/public_html/ needs to be owned by apache?
Thanks for your time.
Best regards
 
Hi again zEitEr.
I tried your article on MESSENGERV3 (https://help.poralix.com/articles/csf-lfd-messenger-v3-with-directadmin-and-apache) configuration and It doesn't work, I get the following errors:

[Mon Mar 10 17:21:36.335221 2025] [proxy_fcgi:error] [pid 1606311:tid 1606758] [remote 186.189.103.37:50272] AH01071: Got error 'PHP message: PHP Fatal error: Uncaught Error: Object of class stdClass could not be converted to string in /var/www/html/public_html/index.php:260\nStack trace:\n#0 {main}\n thrown in /var/www/html/public_html/index.php on line 260', referer: https://domain.tld


[Mon Mar 10 17:22:07.880261 2025] [proxy_fcgi:error] [pid 1606311:tid 1606912] [remote 186.189.103.37:50278] AH01071: Got error 'PHP message: PHP Warning: file_put_contents(/var/www/html/unblock.txt): Failed to open stream: Permission denied in /var/www/html/public_html/index.php on line 250', referer: https://domain.tld

The permissions for groups and users of /home/csf/public_html are 711 webapps access, same on var/www/html
I don't know if they are correct.
Thanks you for your time
 
Bash:
touch /var/www/html/unblock.txt
chmod 600 /var/www/html/unblock.txt
chown -R webapps: /var/www/html/unblock.txt

rm -vf /var/www/html/public_html/index.php

service lfd restart
 
@Hostelaciones
For "csf" user.

You should already see my instruction step by step, as you see... I manual general "csf" php-fpm pool and put "MESSENGERV3PHPHANDLE" for correct handle. That's why it's working without any problem.

And I thought, I can generate this pool by just create "csf" user via directadmin, but this will generate useless credential connection from outside like FTP, dovecot, SMTP service and waste the server resource.
 
Back
Top