nginx php-fpm FastCGI sent in stderr: ... (Permission denied)??
All, I'm an Apache shop, but thought I would explore nginx with php-fpm. So I've installed nginx and php-fpm on Tumbleweed. I've configured to use Unix sockets and tried with fastcgi://127.0.0.1:9000 redirect, but I get the same error trying to process .php pages each time. The php install works fine from the cli, e.g. it processes <?php phpinnfo(); ?> fine. It's just serving php pages through nginx where things are not working. Serving html pages is fine. nginx runs as user:group nginx:nginx and php-fpm has been configured accordingly. The nginx.conf is: https://paste.opensuse.org/pastes/4aa5986f180c The php-fpm pool (Default name www) [www] user = nginx group = nginx php_value[session.save_path] = /var/lib/php8/sessions listen = '/run/php-fpm/php-fpm.sock' listen.owner = nginx listen.group = nginx listen.mode = 0660 pm = dynamic pm.max_children = 5 pm.start_servers = 2 pm.min_spare_servers = 1 pm.max_spare_servers = 3 NOTE: I have uninstalled and blacklisted the system-user-wwwrun package because I do not run the servers as user:group www:wwwrun. The nginx user and group are created just fine by the install, e.g. user: nginx:x:461:461:User for nginx:/var/lib/nginx:/usr/sbin/nologin group: nginx:x:461:david The socket dir created is: # l /run/php-fpm/ total 0 drwxr-xr-x 2 root root 60 Nov 20 18:15 . drwxr-xr-x 45 root root 1100 Nov 20 18:08 .. srw-rw---- 1 nginx nginx 0 Nov 20 18:15 php-fpm.sock The document root with simple test index.(html|php) and the phpinfo() test in tphp.php is: # l /srv/http/htdocs/ total 36 drwxrwxr-x 3 root david 4096 Nov 20 16:26 . drwxr-xr-x 4 root root 4096 Oct 3 01:22 .. drwxrwxr-x 2 root david 4096 Sep 28 02:04 gif -rw-r--r-- 1 root root 497 Oct 3 01:22 50x.html -rw-r--r-- 1 david david 3262 Oct 10 2009 favicon.ico -rw-r--r-- 1 david david 522 Nov 20 16:26 index.html -rw-r--r-- 1 david david 510 Nov 20 15:58 index.php -rw-r--r-- 1 root root 2356 Sep 28 02:04 info2html.css -rw-r--r-- 1 david david 20 May 21 2019 tphp.php The permissions on /var/lib/nginx are: # l /var/lib/nginx/ total 28 drwxr-x--- 7 nginx nginx 4096 Nov 18 04:59 . drwxr-xr-x 59 root root 4096 Nov 20 03:37 .. drwxr-x--- 2 nginx nginx 4096 Oct 3 01:22 fastcgi drwxr-x--- 2 nginx nginx 4096 Oct 3 01:22 proxy drwxr-x--- 2 nginx nginx 4096 Oct 3 01:22 scgi drwxr-x--- 2 nginx nginx 4096 Oct 3 01:22 tmp drwxr-x--- 2 nginx nginx 4096 Oct 3 01:22 uwsgi Both nginx and php-fpm services are happily running: # scs nginx ● nginx.service - The nginx HTTP and reverse proxy server Loaded: loaded (/usr/lib/systemd/system/nginx.service; 5:185mdisabled; preset: 5:185mdisabled) Active: active (running) since Wed 2024-11-20 18:08:14 CST; 21min ago Invocation: a04be26ff80b4ec0b5b1748a8701d16c Process: 12485 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS) Main PID: 12487 (nginx) Tasks: 5 (limit: 9439) CPU: 83ms CGroup: /system.slice/nginx.service ├─12487 "nginx: master process /usr/sbin/nginx -g daemon off;" ├─12488 "nginx: worker process" ├─12489 "nginx: worker process" ├─12490 "nginx: worker process" └─12491 "nginx: worker process" Nov 20 18:08:13 wizard systemd[1]: Starting The nginx HTTP and reverse proxy server... Nov 20 18:08:14 wizard nginx[12485]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok Nov 20 18:08:14 wizard nginx[12485]: nginx: configuration file /etc/nginx/nginx.conf test is successful Nov 20 18:08:14 wizard systemd[1]: Started The nginx HTTP and reverse proxy server. # scs php-fpm ● php-fpm.service - The PHP FastCGI Process Manager Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; 5:185mdisabled; preset: 5:185mdisabled) Active: active (running) since Wed 2024-11-20 18:15:29 CST; 14min ago Invocation: cfbbc45ed51c486db553470af40609d7 Main PID: 12724 (php-fpm) Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0.00req/sec" Tasks: 3 (limit: 9439) CPU: 174ms CGroup: /system.slice/php-fpm.service ├─12724 "php-fpm: master process (/etc/php8/fpm/php-fpm.conf)" ├─12725 "php-fpm: pool www" └─12726 "php-fpm: pool www" Nov 20 18:15:29 wizard systemd[1]: Starting The PHP FastCGI Process Manager... Nov 20 18:15:29 wizard systemd[1]: Started The PHP FastCGI Process Manager. The nginx and php-fpm worker processes and pools are all running as the correct user:group (nginx:nginx), e.g. # ps uafx | grep 'php\|nginx' ... root 12487 0.0 0.1 14912 10432 ? Ss 18:08 0:00 nginx: master process /usr/sbin/nginx -g daemon off; nginx 12488 0.0 0.0 15360 4560 ? S 18:08 0:00 \_ nginx: worker process nginx 12489 0.0 0.0 15360 3832 ? S 18:08 0:00 \_ nginx: worker process nginx 12490 0.0 0.0 15360 3832 ? S 18:08 0:00 \_ nginx: worker process nginx 12491 0.0 0.0 15360 3652 ? S 18:08 0:00 \_ nginx: worker process root 12724 0.0 0.3 64692 31328 ? Ss 18:15 0:00 php-fpm: master process (/etc/php8/fpm/php-fpm.conf) nginx 12725 0.0 0.1 64692 11088 ? S 18:15 0:00 \_ php-fpm: pool www nginx 12726 0.0 0.1 64692 11088 ? S 18:15 0:00 \_ php-fpm: pool www Attempting to access a php file I get the following error regardless whether php-fpm is configured to use Unix sockets or 127.0.0.1:9000, e.g. one message from each configuration: 2024/11/20 18:01:31 [error] 12133#12133: *1 FastCGI sent in stderr: "PHP message: PHP Warning: PHP Request Startup: Failed to open stream: Permission denied in Unknown on line 0; Unable to open primary script: /srv/http/htdocs/index.php (Permission denied)" while reading response header from upstream, client: 127.0.0.1, server: wizard.3111skyline.com, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "wizard.3111skyline.com" 2024/11/20 18:08:23 [error] 12488#12488: *1 FastCGI sent in stderr: "PHP message: PHP Warning: PHP Request Startup: Failed to open stream: Permission denied in Unknown on line 0; Unable to open primary script: /srv/http/htdocs/index.php (Permission denied)" while reading response header from upstream, client: 127.0.0.1, server: wizard.3111skyline.com, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm/php-fpm.sock:", host: "wizard.3111skyline.com" I've tried changing every possible permission on the source, the socket, recreating the socket with 0666 perms instead of 0660, loosening perms on /var/lib/nginx/... and any other insane guess I found on the internet regarding "nginx php permission denied", but nothing works. I have been working through https://nginx.org/en/docs/, but there doesn't seem to be anything I can find "wrong" with what I've done (obviously there is). Anybody good with the nginx config that wouldn't mind helping me figure out where I've screwed this up? -- David C. Rankin, J.D.,P.E.
On 11/20/24 6:44 PM, David C. Rankin wrote:
All,
I'm an Apache shop, but thought I would explore nginx with php-fpm. So I've installed nginx and php-fpm on Tumbleweed. I've configured to use Unix sockets and tried with fastcgi://127.0.0.1:9000 redirect, but I get the same error trying to process .php pages each time. The php install works fine from the cli, e.g. it processes <?php phpinnfo(); ?> fine.
Gaaarrrggghhh!!!! Disregard. It was fricking AppArmor..... # aa-complain '/etc/apparmor.d/php-fpm' was all it took. Nothing like 3 hours down the drain... -- David C. Rankin, J.D.,P.E.
participants (1)
-
David C. Rankin