PHP safelock failed to create a lockfile

dad-min

Member
May 4, 2022
8
4
3
California
cPanel Access Level
Root Administrator
I checked both System requirements | Adobe Commerce Developer Guide and Installation flow | Adobe Commerce Developer Guide and I didn't see anything about a user. Can you point me to the correct documentation?
Hey sorry, got busy at the day job. I mixed up the names magento dev docs calls the users but see below and link:
******
Production file system ownership for private hosting (two users)
If you use your own server (including a hosting provider’s private server setup), there are two users:
  • The web server user, which runs the Admin and storefront.
    Linux systems typically do not provide a shell for this user; you cannot log in to the Magento server as, or switch to, the web server user.
  • The command-line user, which you log in to your Magento server as or switch to.
    Magento uses this user to run Magento CLI commands and cron.
    The command-line user is also referred to as the file system owner.
Because these users require access to the same files, we recommend you create a shared group to which they both belong. The following procedures assume you have already done this.

******
 

dad-min

Member
May 4, 2022
8
4
3
California
cPanel Access Level
Root Administrator
I checked both System requirements | Adobe Commerce Developer Guide and Installation flow | Adobe Commerce Developer Guide and I didn't see anything about a user. Can you point me to the correct documentation?
Thanks for that - most users use the cPanel user associated with the account:


We can't guarantee the functionality or behavior of any non-cPanel users on the machine.
 

dad-min

Member
May 4, 2022
8
4
3
California
cPanel Access Level
Root Administrator
Again, thanks for the articles and your time. I actually posted the "fix" to my issue earlier without even realizing it:
source /opt/cpanel/ea-php74/enable
The contents of "/opt/cpanel/ea-php74/enable":

export PATH=/opt/cpanel/ea-php74/root/usr/bin:/opt/cpanel/ea-php74/root/usr/sbin${PATH:+:${PATH}}​
export MANPATH=/opt/cpanel/ea-php74/root/usr/share/man:${MANPATH}​

*****
Maybe that can help the first guy that was having a similar error.
Cheers!
 

dad-min

Member
May 4, 2022
8
4
3
California
cPanel Access Level
Root Administrator
Thanks for that - most users use the cPanel user associated with the account:


We can't guarantee the functionality or behavior of any non-cPanel users on the machine.
Hi again...I'm back, lol!

I just wanted to give a quick update because I didn't like the workaround I came up with last time (although it got me through my workday...)

My error code had to do with write access to '/etc'. Specifically, it was a write permission error when creating a .lock file for /etc/userdatadomains

So today I simply put '/etc' into my cPanel user's group (from root:root ---> root:cPanelUser) and changed the permissions on the folder only (non recursively) from 0755 to 0775 so my cPanel group would have write access. This made the error code disappear for good, however I am concerned about possible security risks or other implications to this group change of my '/etc' folder. Any suggestions would be greatly appreciated.

Thanks!
 

JOEsDC-Seth

Registered
May 4, 2022
1
1
1
Kansas City, MO
cPanel Access Level
DataCenter Provider
Again, thanks for the articles and your time. I actually posted the "fix" to my issue earlier without even realizing it:
source /opt/cpanel/ea-php74/enable
The contents of "/opt/cpanel/ea-php74/enable":

export PATH=/opt/cpanel/ea-php74/root/usr/bin:/opt/cpanel/ea-php74/root/usr/sbin${PATH:+:${PATH}}​
export MANPATH=/opt/cpanel/ea-php74/root/usr/share/man:${MANPATH}​

*****
Maybe that can help the first guy that was having a similar error.
Cheers!
This led me to a solution as well, thanks. We had a xinetd service that ran a script using "/usr/local/bin/php". Changing the path to "/opt/cpanel/ea-php74/root/usr/bin/php" resolved the safelock errors. Obviously the path would need to be manually updated to use a different version of PHP down the road, but this is a sufficient workaround for us.
 
  • Like
Reactions: dad-min

omaclay

Registered
May 4, 2011
2
0
51
i aliased php in .bashrc
alias php=/opt/cpanel/ea-php74/root/usr/bin/php

of course, if it were another version of php i'd use that.
unfortunately i have to change all the #! interpreter fields in the php script. it only reads text.
 

cfl_adm

Registered
Dec 14, 2022
1
0
1
US
cPanel Access Level
Root Administrator
Hi, I'm having the same problem. I'm running cPanel 106.0.11 on CentOS 7. I have set in /etc/aliases to send mail for apache to a script that will process e-mail bounces. If I send an e-mail to apache@my_domain the script fails (noted in exim_mainlog) and sends back the following:

[2022-12-13 10:25:55 -0500] warn
PHP:
 safelock: Failed to create a lockfile '/etc/userdatadomains.lock-28c16d1c0139-148bfb5c9-17e78' in the directory '/etc' that isn't writable: Permission denied
<wash, rinse, repeat>
[2022-12-13 10:25:55 -0500] warn [php] safelock: Failed to create a lockfile '/etc/userdatadomains.lock-833962b56758-148bfb5c9-17e78' in the directory '/etc' that isn't writable: Permission denied
[2022-12-13 10:25:55 -0500] warn [php] safelock: waited for lock (/etc/userdatadomains.lock) 90 times
PHP Warning:  require_once(/home/<user>/application/../public_html/includes/pre.bootstrap.globals.php): failed to open stream: Permission denied in /home/<user>/cli/bootstrap.php on line 29
PHP Fatal error:  require_once(): Failed opening required '/home/<user>/application/../public_html/includes/pre.bootstrap.globals.php' (include_path='/home/<user>/application/../library:/home/<user>/library:.:/opt/cpanel/ea-php74/root/usr/share/pear') in /home/<user>/cli/bootstrap.php on line 29

Error in exim_mainlog:

2022-12-14 15:25:11 1p5YJT-0008Rf-Bm ** |/opt/cpanel/ea-php74/root/usr/bin/php -q /home/<user>/cli/_process.forwarded.email.bounce.php <apache@<domain>> R=system_aliases T=address_pipe: Child process of address_pipe transport returned 255 (could mean shell command ended by signal 127 (Unknown signal 127)) from command: /opt/cpanel/ea-php74/root/usr/bin/php

1. this code has been working for years
2. userdatadomains is a cPanel construct and seems to be manipulated somewhere below our code.
3. why is anything trying to write a lock file in /etc ?
4. tried everyting mentioned above, including changing the owner/group of the script to match /etc.
 

friv

Member
Dec 14, 2018
16
0
1
Serbia
cPanel Access Level
Website Owner
Hello cPRex

I have same problem,and from this thread i can't find correct solution for this problem.

Did i need to paste some command in terminal or?

Please check attachment.
 

Attachments