Home > Backend Development > PHP Tutorial > 403-forbidden - Nginx+PHP-fpm网站目录权限问题

403-forbidden - Nginx+PHP-fpm网站目录权限问题

WBOY
Release: 2016-06-06 20:31:06
Original
4054 people have browsed it

系统:ArchLinux(桌面环境)

我想把网站的root路径设为

<code>/home/myusername/www
</code>
Copy after login
Copy after login

但是出现了403 Forbidden错误

<code>2015/05/31 16:41:44 [error] 12879#0: *1 "/home/myusername/www/index.php" is forbidden (13: Permission denied), client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "127.0.0.1"
</code>
Copy after login
Copy after login

nginx.conf已经设置无误
php-fpm和nginx的用户都是http(用户组为http),这是默认的
而我把root路径设为/usr/share/nginx/html(这是nginx安装后的默认目录)的话就没有问题(成功执行php文件)。

我尝试把/home/myusername/www的所有者改为http(http)也是不行。

是不是root文件夹的权限设置还是不对呢?求大家指教如何设置权限?

回复内容:

系统:ArchLinux(桌面环境)

我想把网站的root路径设为

<code>/home/myusername/www
</code>
Copy after login
Copy after login

但是出现了403 Forbidden错误

<code>2015/05/31 16:41:44 [error] 12879#0: *1 "/home/myusername/www/index.php" is forbidden (13: Permission denied), client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "127.0.0.1"
</code>
Copy after login
Copy after login

nginx.conf已经设置无误
php-fpm和nginx的用户都是http(用户组为http),这是默认的
而我把root路径设为/usr/share/nginx/html(这是nginx安装后的默认目录)的话就没有问题(成功执行php文件)。

我尝试把/home/myusername/www的所有者改为http(http)也是不行。

是不是root文件夹的权限设置还是不对呢?求大家指教如何设置权限?

网站目录和文件设置权限,保证Nginx和PHP-FPM能够读取访问这些文件.
cd /home/myusername/www
find -type d -exec chmod 755 {} \;
find -type f -exec chmod 644 {} \;

chmod 777 文件夹

<code>shell</code><code>chown -R http:http /home/myusername/www
</code>
Copy after login

chown -R http:http xxx

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template