英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论