Reputation: 149
I have installed nginx version: nginx/1.19.1
, PHP 7.4.8 (fpm-fcgi)
and PHP 7.4.8 (cli)
.
My nginx server-Block-configuration:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name x.x.x.x;
location / {
try_files $uri $uri/ =404;
}
# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
I test http://x.x.x.x/info.php its give me error
Nginx-logs error:
2020/07/30 10:30:10 [crit] 24996#24996: *1 connect() to unix:/var/run/php/php7.2-fpm.sock failed (13: Permission denied) while connecting to upstream, client: 37.111.128.199, server: 54.175.13.25, request: "GET /info.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.2-fpm.sock:", host: "54.175.13.25"
Gives me permission-denied error so Why this happed?
Upvotes: 3
Views: 4344
Reputation: 61
I can't comment yet so I am writing this as an answer.
What you did is one way.
The other way is to change the user in /etc/php/7.4/fpm/pool.d/www.conf
:
user = nginx
group = nginx
listen.owner = nginx
listen.group = nginx
Personally, I would prefer changing the user for php-fpm rather than changing the user for nginx.
Cheers.
Upvotes: 1
Reputation: 149
Take alot of time to resolving
I resolved by changing in the etc/nginx/nginx.conf {user nginx} to {user www-data} its actually permission issue then save and restart the nginx(sudo systemctl restart nginx).
user www-data;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/sites-enabled/*;
}
Upvotes: 5