PHP file download, download failed, nginx open() nginx / fastcgi_ temp/2/10/0000000102“ failed (13: Permission denied)

summary

The file download failed when testing the project

Check the problem

After investigation, it is found that nginx gives error information
open() "/ home/server/nginx/fastcgi_ Temp/2/10/0000000102 "failed (13: permission denied) while reading upstream
nginx prompts us that we do not have permission to operate

and then we enter the directory /home/server/nginx to check fastcgi_ Temp file owner, our name is the root user of root group

we will check the user group and user name of nginx worker again

ps -ef | grep nginx
# We can see that the worker process of nginx is the www user
root 80246 1 0 10:37 ?       00:00:00 nginx: master process /home/server/nginx/sbin/nginx
www 80247 80246 0 10:37 ?       00:00:00 nginx: worker process
root 82877 82840 0 13:56 pts/7 00:00:00 grep --color=auto nginx
# View the group that the www user is in, and the members of the group
groups www
# Ours is the www user of the www user group
www:www

solve the problem

When we download, the nginx worker process is sending the fastcgi_ Temp does not have permission to write to the cache
so we just need to give fastcgi_ The start-up user with the permission of nginx to modify the temp directory WWW: www

chown -R www:www fastcgi_temp/

Read More: