Nginx用户无法访问Ubuntu文件夹。

huangapple go评论66阅读模式
英文:

Nginx user cannot access Ubuntu folder

问题

我正在Ubuntu服务器上运行Nginx。如下所示,Nginx无权访问我的项目文件夹。

sudo -u www-data stat /home/mainuser/projectname/
stat: cannot statx '/home/mainuser/projectname/': Permission denied

我知道这是一个特定于此项目文件夹和用户的问题,因为

sudo -u www-data stat /home/mainuser/

sudo -u mainuser stat /home/mainuser/projectname/

也可以正常运行。

我一直在尝试遵循这个线程 ,所以我尝试了以下解决方案... 我尝试设置

sudo chmod 755 /home/mainuser/projectname/

sudo chown -R :www-data /home/mainuser/projectname/

当我运行ls -l时,

我可以看到这些权限已应用于目录

total 4
drwxr-xr-x 7 mainuser www-data 4096 May 28 05:13 projectname

但仍然,Nginx的www-data用户无权访问该目录。我漏掉了什么,如何为这个目录授予该用户访问权限?

编辑:

我创建了另一个目录/test,即使在sudo chmod 777 test/之后,我也没有权限以Nginx用户身份访问它。

英文:

I'm running Nginx on a Ubuntu server. Nginx does not have permission to access my project folder as show below.

sudo -u www-data stat /home/mainuser/projectname/
stat: cannot statx '/home/mainuser/projectname/': Permission denied

I know it's an issue specific to this project folder and user because

sudo -u www-data stat /home/mainuser/

and

sudo -u mainuser stat /home/mainuser/projectname/

also runs fine.

I've been trying to follow this thread and so I've tried the following solutions... I tried setting

sudo chmod 755 /home/mainuser/projectname/

and

sudo chown -R :www-data /home/mainuser/projectname/

and when I run ls -l

I can see these permissions have been applied to the directory

total 4
drwxr-xr-x 7 mainuser www-data 4096 May 28 05:13 projectname

But still the Nginx www-data user does not have permissions to access the dir. What am I missing, how do I give this user access to this directory?

EDIT:

I made another dir /test and even after sudo chmod 777 test/ I do not have permission to access it as the Nginx user either.

答案1

得分: 0

上游目录“mainuser”缺少权限。

尽管

sudo -u www-data stat /home/mainuser/

起作用,但以下命令出现权限错误,让我明白了情况。

sudo -u www-data ls /home/mainuser/

之后,运行sudo chmod :www-data /home/mainuser修复了它。

英文:

The upstream directory mainuser was missing permissions.

Even though

sudo -u www-data stat /home/mainuser/

worked, the following gave a permission error which clued me in.

sudo -u www-data ls /home/mainuser/

After that sudo chmod :www-data /home/mainuser fixed it

huangapple
  • 本文由 发表于 2023年6月5日 07:06:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/76402751.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定