LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-10-2024, 01:29 PM   #1
BrokenLamp
LQ Newbie
 
Registered: May 2024
Posts: 4

Rep: Reputation: 0
Unhappy PHP-FPM permission issue?


Hello.

I have installed PHP-FPM in my system, but I am unable to use it because the corresponding service is unable to start. Here is what the terminal has to say about it:

Code:
userx@nobara-pc:~$ sudo systemctl start php-fpm
Job for php-fpm.service failed because the control process exited with error code.
See "systemctl status php-fpm.service" and "journalctl -xeu php-fpm.service" for details.
userx@nobara-pc:~$ sudo systemctl status php-fpm
× php-fpm.service - The PHP FastCGI Process Manager
     Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; preset: disabled)
    Drop-In: /usr/lib/systemd/system/service.d
             └─10-timeout-abort.conf
     Active: failed (Result: exit-code) since Fri 2024-05-10 15:09:11 -03; 3s ago
    Process: 15879 ExecStart=/usr/sbin/php-fpm --nodaemonize (code=exited, status=78)
   Main PID: 15879 (code=exited, status=78)
        CPU: 16ms

may 10 15:09:10 nobara-pc systemd[1]: Starting php-fpm.service - The PHP FastCGI Process Manager...
may 10 15:09:11 nobara-pc php-fpm[15879]: [10-May-2024 15:09:11] ERROR: failed to open configuration file '/etc/php-fpm.conf': Permission denied (13)
may 10 15:09:11 nobara-pc php-fpm[15879]: [10-May-2024 15:09:11] ERROR: failed to load configuration file '/etc/php-fpm.conf'
may 10 15:09:11 nobara-pc php-fpm[15879]: [10-May-2024 15:09:11] ERROR: FPM initialization failed
may 10 15:09:11 nobara-pc systemd[1]: php-fpm.service: Main process exited, code=exited, status=78/CONFIG
may 10 15:09:11 nobara-pc systemd[1]: php-fpm.service: Failed with result 'exit-code'.
may 10 15:09:11 nobara-pc systemd[1]: Failed to start php-fpm.service - The PHP FastCGI Process Manager.
userx@nobara-pc:~$
Going by what the output here says, I've decided to see what permissions are set for /etc/php-fpm.conf. This is what it says:

Code:
userx@nobara-pc:/etc$ ls -l php-fpm.conf
-rw-r--r-- 1 root root 4908 mar 11 21:00 php-fpm.conf
userx@nobara-pc:/etc$
This is as far as I got, unfortunately. I know that there is some kind of problem with the permissions for this file, but I don't know what the problem exactly is, and I'm not experience enough in Linux yet to know if I can intuit the issue some other way. I've already tried running chmod 777 on the file, but it did not make a difference.

I'm running Nobara (a Fedora derivative) and I've installed PHP-FPM by doing sudo dnf install php-fpm. If there's anything other info that could be relevant, don't hesitate to ask.
 
Old 05-10-2024, 01:49 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,721

Rep: Reputation: 7973Reputation: 7973Reputation: 7973Reputation: 7973Reputation: 7973Reputation: 7973Reputation: 7973Reputation: 7973Reputation: 7973Reputation: 7973Reputation: 7973
Quote:
Originally Posted by BrokenLamp View Post
Hello. I have installed PHP-FPM in my system, but I am unable to use it because the corresponding service is unable to start. Here is what the terminal has to say about it:
Code:
userx@nobara-pc:~$ sudo systemctl start php-fpm
Job for php-fpm.service failed because the control process exited with error code.
See "systemctl status php-fpm.service" and "journalctl -xeu php-fpm.service" for details.
userx@nobara-pc:~$ sudo systemctl status php-fpm
× php-fpm.service - The PHP FastCGI Process Manager
     Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; preset: disabled)
    Drop-In: /usr/lib/systemd/system/service.d
             └─10-timeout-abort.conf
     Active: failed (Result: exit-code) since Fri 2024-05-10 15:09:11 -03; 3s ago
    Process: 15879 ExecStart=/usr/sbin/php-fpm --nodaemonize (code=exited, status=78)
   Main PID: 15879 (code=exited, status=78)
        CPU: 16ms

may 10 15:09:10 nobara-pc systemd[1]: Starting php-fpm.service - The PHP FastCGI Process Manager...
may 10 15:09:11 nobara-pc php-fpm[15879]: [10-May-2024 15:09:11] ERROR: failed to open configuration file '/etc/php-fpm.conf': Permission denied (13)
may 10 15:09:11 nobara-pc php-fpm[15879]: [10-May-2024 15:09:11] ERROR: failed to load configuration file '/etc/php-fpm.conf'
may 10 15:09:11 nobara-pc php-fpm[15879]: [10-May-2024 15:09:11] ERROR: FPM initialization failed
may 10 15:09:11 nobara-pc systemd[1]: php-fpm.service: Main process exited, code=exited, status=78/CONFIG
may 10 15:09:11 nobara-pc systemd[1]: php-fpm.service: Failed with result 'exit-code'.
may 10 15:09:11 nobara-pc systemd[1]: Failed to start php-fpm.service - The PHP FastCGI Process Manager.
userx@nobara-pc:~$
Going by what the output here says, I've decided to see what permissions are set for /etc/php-fpm.conf. This is what it says:
Code:
userx@nobara-pc:/etc$ ls -l php-fpm.conf
-rw-r--r-- 1 root root 4908 mar 11 21:00 php-fpm.conf
userx@nobara-pc:/etc$
This is as far as I got, unfortunately. I know that there is some kind of problem with the permissions for this file, but I don't know what the problem exactly is, and I'm not experience enough in Linux yet to know if I can intuit the issue some other way. I've already tried running chmod 777 on the file, but it did not make a difference. I'm running Nobara (a Fedora derivative) and I've installed PHP-FPM by doing sudo dnf install php-fpm. If there's anything other info that could be relevant, don't hesitate to ask.
If this is a totally fresh installation, have you configured that file? Does it contain valid data? Try runing “sudo systemctl cat php-fpm.service” to see what it's running, and try executing that on the command prompt. What does that give?

That file is owned by root; may want to change permissions to 755 ("chmod 755 <whatever file name>"), and change the owner to be your web engine user ("chown apache (or whatever) /etc/php-fpm.conf"). Could also be related to selinux or apparmor.
 
Old 05-10-2024, 03:50 PM   #3
BrokenLamp
LQ Newbie
 
Registered: May 2024
Posts: 4

Original Poster
Rep: Reputation: 0
The contents of php-fpm.conf are untouched by me and they do appear to be valid.

This is the output I get from sudo systemctl cat php-fpm.service:

Code:
userx@nobara-pc:~$ sudo systemctl cat php-fpm.service
# /usr/lib/systemd/system/php-fpm.service
# It's not recommended to modify this file in-place, because it
# will be overwritten during upgrades.  If you want to customize,
# the best way is to use the "systemctl edit" command.

[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target

[Service]
Type=notify
ExecStart=/usr/sbin/php-fpm --nodaemonize
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true
RuntimeDirectory=php-fpm
RuntimeDirectoryMode=0755

[Install]
WantedBy=multi-user.target


# /usr/lib/systemd/system/service.d/10-timeout-abort.conf
# This file is part of the systemd package.
# See https://fedoraproject.org/wiki/Changes/Shorter_Shutdown_Timer.
#
# To facilitate debugging when a service fails to stop cleanly,
# TimeoutStopFailureMode=abort is set to "crash" services that fail to stop in
# the time allotted. This will cause the service to be terminated with SIGABRT
# and a coredump to be generated.
#
# To undo this configuration change, create a mask file:
#   sudo mkdir -p /etc/systemd/system/service.d
#   sudo ln -sv /dev/null /etc/systemd/system/service.d/10-timeout-abort.conf

[Service]
TimeoutStopFailureMode=abort
userx@nobara-pc:~$
Typing in /usr/sbin/php-fpm --nodaemonize in the terminal gets me:

Code:
[10-May-2024 17:21:47] ERROR: failed to open configuration file '/etc/php-fpm.conf': Permission denied (13)
[10-May-2024 17:21:47] ERROR: failed to load configuration file '/etc/php-fpm.conf'
[10-May-2024 17:21:47] ERROR: FPM initialization failed
So essentially the same as before.

Quote:
Originally Posted by TB0ne View Post
That file is owned by root; may want to change permissions to 755 ("chmod 755 <whatever file name>"), and change the owner to be your web engine user ("chown apache (or whatever) /etc/php-fpm.conf"). Could also be related to selinux or apparmor.
Changing permissions and owner resulted in still the same error as earlier. Permissions are complicated.

I suppose the last recourse is SELinux and AppArmor... I'm flying blind here, as I've never had to mess with either of those before.
 
Old 05-10-2024, 05:10 PM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,721

Rep: Reputation: 7973Reputation: 7973Reputation: 7973Reputation: 7973Reputation: 7973Reputation: 7973Reputation: 7973Reputation: 7973Reputation: 7973Reputation: 7973Reputation: 7973
Quote:
Originally Posted by BrokenLamp View Post
The contents of php-fpm.conf are untouched by me and they do appear to be valid. This is the output I get from sudo systemctl cat php-fpm.service:
Code:
userx@nobara-pc:~$ sudo systemctl cat php-fpm.service
# /usr/lib/systemd/system/php-fpm.service
# It's not recommended to modify this file in-place, because it
# will be overwritten during upgrades.  If you want to customize,
# the best way is to use the "systemctl edit" command.

[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target

[Service]
Type=notify
ExecStart=/usr/sbin/php-fpm --nodaemonize
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true
RuntimeDirectory=php-fpm
RuntimeDirectoryMode=0755

[Install]
WantedBy=multi-user.target


# /usr/lib/systemd/system/service.d/10-timeout-abort.conf
# This file is part of the systemd package.
# See https://fedoraproject.org/wiki/Changes/Shorter_Shutdown_Timer.
#
# To facilitate debugging when a service fails to stop cleanly,
# TimeoutStopFailureMode=abort is set to "crash" services that fail to stop in
# the time allotted. This will cause the service to be terminated with SIGABRT
# and a coredump to be generated.
#
# To undo this configuration change, create a mask file:
#   sudo mkdir -p /etc/systemd/system/service.d
#   sudo ln -sv /dev/null /etc/systemd/system/service.d/10-timeout-abort.conf

[Service]
TimeoutStopFailureMode=abort
userx@nobara-pc:~$
Typing in /usr/sbin/php-fpm --nodaemonize in the terminal gets me:
Code:
[10-May-2024 17:21:47] ERROR: failed to open configuration file '/etc/php-fpm.conf': Permission denied (13)
[10-May-2024 17:21:47] ERROR: failed to load configuration file '/etc/php-fpm.conf'
[10-May-2024 17:21:47] ERROR: FPM initialization failed
So essentially the same as before. Changing permissions and owner resulted in still the same error as earlier. Permissions are complicated.
What are the permissions/owner on the file now?
Quote:
I suppose the last recourse is SELinux and AppArmor... I'm flying blind here, as I've never had to mess with either of those before.
As a test to see if that's the culprit, you can run:
Code:
sudo systemctl stop apparmor
...then try. Are you running apache or nginx? Apache mod_php would be my go-to in this case.
 
Old 05-10-2024, 07:07 PM   #5
BrokenLamp
LQ Newbie
 
Registered: May 2024
Posts: 4

Original Poster
Rep: Reputation: 0
Still nothing...

Code:
userx@nobara-pc:~$ sudo systemctl stop apparmor
userx@nobara-pc:~$ sudo systemctl start php-fpm
Job for php-fpm.service failed because the control process exited with error code.
See "systemctl status php-fpm.service" and "journalctl -xeu php-fpm.service" for details.
userx@nobara-pc:~$ sudo systemctl status php-fpm
× php-fpm.service - The PHP FastCGI Process Manager
     Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; preset: disabled)
    Drop-In: /usr/lib/systemd/system/service.d
             └─10-timeout-abort.conf
     Active: failed (Result: exit-code) since Fri 2024-05-10 20:50:54 -03; 4s ago
    Process: 31769 ExecStart=/usr/sbin/php-fpm --nodaemonize (code=exited, status=78)
   Main PID: 31769 (code=exited, status=78)
        CPU: 10ms

may 10 20:50:54 nobara-pc systemd[1]: Starting php-fpm.service - The PHP FastCGI Process Manager...
may 10 20:50:54 nobara-pc php-fpm[31769]: [10-May-2024 20:50:54] ERROR: failed to open configuration file '/etc/php-fpm.conf': Permission denied (13)
may 10 20:50:54 nobara-pc php-fpm[31769]: [10-May-2024 20:50:54] ERROR: failed to load configuration file '/etc/php-fpm.conf'
may 10 20:50:54 nobara-pc php-fpm[31769]: [10-May-2024 20:50:54] ERROR: FPM initialization failed
may 10 20:50:54 nobara-pc systemd[1]: php-fpm.service: Main process exited, code=exited, status=78/CONFIG
may 10 20:50:54 nobara-pc systemd[1]: php-fpm.service: Failed with result 'exit-code'.
may 10 20:50:54 nobara-pc systemd[1]: Failed to start php-fpm.service - The PHP FastCGI Process Manager.
userx@nobara-pc:~$
I've tried this with both php-fpm.conf being reverted to its original permissions (chmod 644 and chown 0:0) and with the altered permissions from earlier (chmod 755 and chown apache:apache) and I'm still getting the same permission issue. Maybe my PC is just haunted. I've never had such a stubborn problem before in Linux.

Quote:
Are you running apache or nginx? Apache mod_php would be my go-to in this case.
Apache. I have nil experience setting up a web server, the tutorials I read used Apache and other info I found online recommended using PHP-FPM with Apache versions above 2.4.
 
Old 05-11-2024, 09:47 AM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,721

Rep: Reputation: 7973Reputation: 7973Reputation: 7973Reputation: 7973Reputation: 7973Reputation: 7973Reputation: 7973Reputation: 7973Reputation: 7973Reputation: 7973Reputation: 7973
Quote:
Originally Posted by BrokenLamp View Post
Still nothing...

Code:
userx@nobara-pc:~$ sudo systemctl stop apparmor
userx@nobara-pc:~$ sudo systemctl start php-fpm
Job for php-fpm.service failed because the control process exited with error code.
See "systemctl status php-fpm.service" and "journalctl -xeu php-fpm.service" for details.
userx@nobara-pc:~$ sudo systemctl status php-fpm
× php-fpm.service - The PHP FastCGI Process Manager
     Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; preset: disabled)
    Drop-In: /usr/lib/systemd/system/service.d
             └─10-timeout-abort.conf
     Active: failed (Result: exit-code) since Fri 2024-05-10 20:50:54 -03; 4s ago
    Process: 31769 ExecStart=/usr/sbin/php-fpm --nodaemonize (code=exited, status=78)
   Main PID: 31769 (code=exited, status=78)
        CPU: 10ms

may 10 20:50:54 nobara-pc systemd[1]: Starting php-fpm.service - The PHP FastCGI Process Manager...
may 10 20:50:54 nobara-pc php-fpm[31769]: [10-May-2024 20:50:54] ERROR: failed to open configuration file '/etc/php-fpm.conf': Permission denied (13)
may 10 20:50:54 nobara-pc php-fpm[31769]: [10-May-2024 20:50:54] ERROR: failed to load configuration file '/etc/php-fpm.conf'
may 10 20:50:54 nobara-pc php-fpm[31769]: [10-May-2024 20:50:54] ERROR: FPM initialization failed
may 10 20:50:54 nobara-pc systemd[1]: php-fpm.service: Main process exited, code=exited, status=78/CONFIG
may 10 20:50:54 nobara-pc systemd[1]: php-fpm.service: Failed with result 'exit-code'.
may 10 20:50:54 nobara-pc systemd[1]: Failed to start php-fpm.service - The PHP FastCGI Process Manager.
userx@nobara-pc:~$
I've tried this with both php-fpm.conf being reverted to its original permissions (chmod 644 and chown 0:0) and with the altered permissions from earlier (chmod 755 and chown apache:apache) and I'm still getting the same permission issue. Maybe my PC is just haunted. I've never had such a stubborn problem before in Linux.
644 and 0:0 are probably going to give you problems. Since you're running...
Quote:
Apache. I have nil experience setting up a web server, the tutorials I read used Apache and other info I found online recommended using PHP-FPM with Apache versions above 2.4.
...apache, what user is the web server running as? Some run as apache..some www-run, or some other user. Make sure that user owns the file and it's 755. And did you try turning off selinux and testing it that way?

You can also copy that config file somewhere else, and try to start php-fpm from the command-line, and specifying that other config file to see if the error follows. Something else...is php itself installed? Also have to question nobara versus a more mainstream distro like Fedora or (if this is a long-term server), Rocky or Ubuntu LTS.
 
Old 05-11-2024, 06:42 PM   #7
BrokenLamp
LQ Newbie
 
Registered: May 2024
Posts: 4

Original Poster
Rep: Reputation: 0
I've decided to examine this problem from a different angle: I've installed Nobara inside a VM. Then, without making any further customizations, I installed httpd and php again. Then, rebooted the VM and then tried to start the php-fpm service again. And it STILL did not work! I got the SAME error as before, despite the VM instance of Nobara being fresh off the install ISO! Then I tried again with a VM running LMDE and it worked (though I don't believe it's actually using PHP-FPM despite me installing the package and starting the service, but it doesn't matter so long as php code is being loaded properly).

This tells me that perhaps Nobara itself is the issue - perhaps there's some modification done to the distro that interferes with how PHP-FPM sets or reads file permissions (and if it's a Nobara-specific issue, that'd also explain why search engines can't find other people with this same problem). That is unfortunate, but now I have this LMDE VM that I can use instead. It's not the best solution, but it is a solution, and it works perfectly fine for my purposes: a simple private site that won't be accessed from the outside world and that I can use to experiment with PHP and JS code. So the LMDE VM is good enough.

Even if the permission problem was not fixed in the end, still thank you for taking the time to try to help me.

Last edited by BrokenLamp; 05-11-2024 at 06:45 PM.
 
Old 05-12-2024, 10:11 AM   #8
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,721

Rep: Reputation: 7973Reputation: 7973Reputation: 7973Reputation: 7973Reputation: 7973Reputation: 7973Reputation: 7973Reputation: 7973Reputation: 7973Reputation: 7973Reputation: 7973
Quote:
Originally Posted by BrokenLamp View Post
I've decided to examine this problem from a different angle: I've installed Nobara inside a VM. Then, without making any further customizations, I installed httpd and php again. Then, rebooted the VM and then tried to start the php-fpm service again. And it STILL did not work! I got the SAME error as before, despite the VM instance of Nobara being fresh off the install ISO! Then I tried again with a VM running LMDE and it worked (though I don't believe it's actually using PHP-FPM despite me installing the package and starting the service, but it doesn't matter so long as php code is being loaded properly).

This tells me that perhaps Nobara itself is the issue - perhaps there's some modification done to the distro that interferes with how PHP-FPM sets or reads file permissions (and if it's a Nobara-specific issue, that'd also explain why search engines can't find other people with this same problem). That is unfortunate, but now I have this LMDE VM that I can use instead. It's not the best solution, but it is a solution, and it works perfectly fine for my purposes: a simple private site that won't be accessed from the outside world and that I can use to experiment with PHP and JS code. So the LMDE VM is good enough.

Even if the permission problem was not fixed in the end, still thank you for taking the time to try to help me.
Sometimes 'edge' distros have problems others don't. Sticking with something more mainstream can be helpful.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Issues with dependencies when installing php70-fpm. I have newer versions of the dependencies installed, but php70-fpm requires older KurtisKewl *BSD 9 05-02-2017 01:23 PM
LXer: Using Multiple PHP Versions (PHP-FPM & FastCGI) With ISPConfig 3 (Ubuntu 12.04) LXer Syndicated Linux News 0 03-10-2013 08:40 AM
request shipping php-fpm with php in -current repo cowyn Slackware 1 04-03-2011 05:29 PM
LXer: Installing Nginx With PHP 5.3 And PHP-FPM On Ubuntu Lucid Lynx (10.04) LXer Syndicated Linux News 0 06-14-2010 11:42 PM
LXer: Installing PHP 5.3, Nginx And PHP-fpm On Ubuntu/Debian LXer Syndicated Linux News 0 02-10-2010 05:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration