Stefano Prina
2024-07-06 14:00:01 UTC
Hello All,
I am Stefano from Torino, Italy; I am just new to this list, nice to
virtually meet all of you : )
I am writing to you because I need support for a strange issue I' am facing.
I am trying to create a debian container to run some php app for a side
project, the idea is to use nginx and php-fpm,
the procedure I am using is :
[host] $ podman run -ti -p 8090:80 debian:12-slim
[container]$apt update && apt install vim nginx php-fpm
edit`/etc/nginx/sites-enabled/default` de-commenting the php part
      # pass PHP scripts to FastCGI server
       #
       location ~ \.php$ {
               include snippets/fastcgi-php.conf;
               # With php-fpm (or other unix sockets):
               fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
               # With php-cgi (or other tcp sockets):
               #fastcgi_pass 127.0.0.1:9000;
       }
[container]$/etc/init.d/nginx start
[container]$ /etc/init.d/php8.2-fpm start
edit`/var/www/html/info.php using the content:`
<?php
phpinfo();
?>
connectinghttp://localhost:8080 I get the default nginx page
connectinghttp://localhost:8080/info.php I got Access denied.
and the logs report :
[container]$ tail -n 2 /var/log/nginx/error.log
2024/07/06 13:19:45 [error] 7365#7365: *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:
/var/www/html/info.php (Permission denied)" while reading resp
onse header from upstream, client: 127.0.0.1, server: _, request: "GET
/info.php HTTP/1.1", upstream:
"fastcgi://unix:/var/run/php/php8.2-fpm.sock:", host: "localhost:8090"
2024/07/06 13:19:45 [error] 7365#7365: *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:
/var/www/html/info.php (Permission denied)" while reading resp
onse header from upstream, client: 127.0.0.1, server: _, request: "GET
/info.php HTTP/1.1", upstream:
"fastcgi://unix:/var/run/php/php8.2-fpm.sock:", host: "localhost:8090"
It is strange because I the file /var/www/html/info.php exists and have
to much open permission 0:)
[container]$ls -l /var/www/html/info.php
-rwxrwxrwx 1 root root 20 Jul  6 13:03 /var/www/html/info.php
the socket /var/run/php/php8.2-fpm.sock exist and it seems ok:
[container]$ls -l /var/run/php/php8.2-fpm.sock
srw-rw---- 1 www-data www-data 0 Jul  6 13:14 /var/run/php/php8.2-fpm.sock
all the workers seem running using the right user:
[container]$ps -aux
USER Â Â Â Â Â Â PID %CPU %MEM Â Â Â VSZ Â Â RSS TTY Â Â Â Â Â STAT START Â Â TIME COMMAND
root         1  0.0  0.0   4188  3216 pts/0    Ss   12:58   0:00 bash
root      7255  0.0  0.0 201548  8448 ?        Ss   13:14   0:00
php-fpm: master process (/etc/php/8.2/fpm/php-fpm.conf)
www-data  7256  0.0  0.0 201548 10792 ?        S    13:14   0:00
php-fpm: pool www
www-data  7257  0.0  0.0 201548 10664 ?        S    13:14   0:00
php-fpm: pool www
root      7364  0.0  0.0  10336  1512 ?        Ss   13:19   0:00 nginx:
master process /usr/sbin/nginx
www-data  7365  0.0  0.0  10960  4104 ?        S    13:19   0:00 nginx:
worker process
www-data  7366  0.0  0.0  10960  4244 ?        S    13:19   0:00 nginx:
worker process
www-data  7367  0.0  0.0  10688  2684 ?        S    13:19   0:00 nginx:
worker process
www-data  7368  0.0  0.0  10688  2684 ?        S    13:19   0:00 nginx:
worker process
www-data  7369  0.0  0.0  10688  2684 ?        S    13:19   0:00 nginx:
worker process
www-data  7370  0.0  0.0  10688  2684 ?        S    13:19   0:00 nginx:
worker process
www-data  7371  0.0  0.0  10688  2684 ?        S    13:19   0:00 nginx:
worker process
www-data  7372  0.0  0.0  10688  2684 ?        S    13:19   0:00 nginx:
worker process
www-data  7373  0.0  0.0  10688  2684 ?        S    13:19   0:00 nginx:
worker process
www-data  7374  0.0  0.0  10688  2684 ?        S    13:19   0:00 nginx:
worker process
www-data  7375  0.0  0.0  10688  2684 ?        S    13:19   0:00 nginx:
worker process
www-data  7376  0.0  0.0  10688  2684 ?        S    13:19   0:00 nginx:
worker process
root      7386  0.0  0.0   8060  4248 pts/0    R+   13:51   0:00 ps -aux
So I have the feeling I am missing something stupid... but what ??
Can you help me ?
Thanks in advance
Stefano
I am Stefano from Torino, Italy; I am just new to this list, nice to
virtually meet all of you : )
I am writing to you because I need support for a strange issue I' am facing.
I am trying to create a debian container to run some php app for a side
project, the idea is to use nginx and php-fpm,
the procedure I am using is :
[host] $ podman run -ti -p 8090:80 debian:12-slim
[container]$apt update && apt install vim nginx php-fpm
edit`/etc/nginx/sites-enabled/default` de-commenting the php part
      # pass PHP scripts to FastCGI server
       #
       location ~ \.php$ {
               include snippets/fastcgi-php.conf;
               # With php-fpm (or other unix sockets):
               fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
               # With php-cgi (or other tcp sockets):
               #fastcgi_pass 127.0.0.1:9000;
       }
[container]$/etc/init.d/nginx start
[container]$ /etc/init.d/php8.2-fpm start
edit`/var/www/html/info.php using the content:`
<?php
phpinfo();
?>
connectinghttp://localhost:8080 I get the default nginx page
connectinghttp://localhost:8080/info.php I got Access denied.
and the logs report :
[container]$ tail -n 2 /var/log/nginx/error.log
2024/07/06 13:19:45 [error] 7365#7365: *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:
/var/www/html/info.php (Permission denied)" while reading resp
onse header from upstream, client: 127.0.0.1, server: _, request: "GET
/info.php HTTP/1.1", upstream:
"fastcgi://unix:/var/run/php/php8.2-fpm.sock:", host: "localhost:8090"
2024/07/06 13:19:45 [error] 7365#7365: *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:
/var/www/html/info.php (Permission denied)" while reading resp
onse header from upstream, client: 127.0.0.1, server: _, request: "GET
/info.php HTTP/1.1", upstream:
"fastcgi://unix:/var/run/php/php8.2-fpm.sock:", host: "localhost:8090"
It is strange because I the file /var/www/html/info.php exists and have
to much open permission 0:)
[container]$ls -l /var/www/html/info.php
-rwxrwxrwx 1 root root 20 Jul  6 13:03 /var/www/html/info.php
the socket /var/run/php/php8.2-fpm.sock exist and it seems ok:
[container]$ls -l /var/run/php/php8.2-fpm.sock
srw-rw---- 1 www-data www-data 0 Jul  6 13:14 /var/run/php/php8.2-fpm.sock
all the workers seem running using the right user:
[container]$ps -aux
USER Â Â Â Â Â Â PID %CPU %MEM Â Â Â VSZ Â Â RSS TTY Â Â Â Â Â STAT START Â Â TIME COMMAND
root         1  0.0  0.0   4188  3216 pts/0    Ss   12:58   0:00 bash
root      7255  0.0  0.0 201548  8448 ?        Ss   13:14   0:00
php-fpm: master process (/etc/php/8.2/fpm/php-fpm.conf)
www-data  7256  0.0  0.0 201548 10792 ?        S    13:14   0:00
php-fpm: pool www
www-data  7257  0.0  0.0 201548 10664 ?        S    13:14   0:00
php-fpm: pool www
root      7364  0.0  0.0  10336  1512 ?        Ss   13:19   0:00 nginx:
master process /usr/sbin/nginx
www-data  7365  0.0  0.0  10960  4104 ?        S    13:19   0:00 nginx:
worker process
www-data  7366  0.0  0.0  10960  4244 ?        S    13:19   0:00 nginx:
worker process
www-data  7367  0.0  0.0  10688  2684 ?        S    13:19   0:00 nginx:
worker process
www-data  7368  0.0  0.0  10688  2684 ?        S    13:19   0:00 nginx:
worker process
www-data  7369  0.0  0.0  10688  2684 ?        S    13:19   0:00 nginx:
worker process
www-data  7370  0.0  0.0  10688  2684 ?        S    13:19   0:00 nginx:
worker process
www-data  7371  0.0  0.0  10688  2684 ?        S    13:19   0:00 nginx:
worker process
www-data  7372  0.0  0.0  10688  2684 ?        S    13:19   0:00 nginx:
worker process
www-data  7373  0.0  0.0  10688  2684 ?        S    13:19   0:00 nginx:
worker process
www-data  7374  0.0  0.0  10688  2684 ?        S    13:19   0:00 nginx:
worker process
www-data  7375  0.0  0.0  10688  2684 ?        S    13:19   0:00 nginx:
worker process
www-data  7376  0.0  0.0  10688  2684 ?        S    13:19   0:00 nginx:
worker process
root      7386  0.0  0.0   8060  4248 pts/0    R+   13:51   0:00 ps -aux
So I have the feeling I am missing something stupid... but what ??
Can you help me ?
Thanks in advance
Stefano