php web用户权限,php-Nginx本地Web服务器的所有权和权限

我在设置本地Nginx环境时遇到问题.我已经在网上阅读了无数的教程,并且一切似乎都使我的大脑有些混乱.

作业系统:OSX 10.11.4 El Capitan

Nginx的:1.8.1

PHP-FPM:5.5.31

我的网络根目录的文件目录如下所示:

/webserver

/webverver/PHPinfo.PHP

/webserver/example

/webserver/example/index.PHP

我可以使用curl或在访问本地主机的Web浏览器中访问默认的“欢迎使用Nginx”页面.如果我随后浏览,则会得到文件的索引,但是PHP文件将尝试下载而不是执行.如果我尝试访问在local.example.com(已添加到我的主机文件)中创建的示例站点,那么我会使用curl获得403 Forbidden标头返回,并使用网络浏览器返回一个简单易用的“拒绝访问” .

我对文件权限和目录所有权不是很了解,有人可以建议我如何配置所有内容吗?建议我运行以下命令,但到目前为止它什么都没有改变:

须藤chmod -R 755 / Users / nickcorin / webserver

除“信号已启动”日志外,我的错误日志中没有任何日志.

这是我目前的配置:

Nginx.conf

#user nobody;

worker_processes 1;

error_log logs/error.log;

error_log logs/error.log notice;

error_log logs/error.log info;

#pid logs/Nginx.pid;

events {

worker_connections 1024;

}

http {

include 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 logs/access.log main;

sendfile on;

tcp_nopush on;

keepalive_timeout 65;

#gzip on;

server {

listen 80;

server_name localhost;

location / {

root /Users/nickcorin/webserver;

autoindex on;

}

# redirect server error pages to the static page /50x.html

#

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root html;

}

}

include servers/*;

}

服务器/示例

upstream PHP {

server 127.0.0.1:9000;

}

server {

listen 80;

root /Users/nickcorin/webserver/example;

server_name local.example.com;

index index.PHP index.html index.htm;

autoindex on;

location ~ \.PHP${

try_files $uri $uri/ /index.PHP?$args ;

index index.html index.htm index.PHP;

fastcgi_param PATH_INFO $fastcgi_path_info;

fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.PHP;

fastcgi_split_path_info ^(.+\.PHP)(/.+)$;

fastcgi_intercept_errors on;

include fastcgi_params;

}

}

**编辑-Nginx文件夹权限&流程负责人**

我在日志文件夹/usr/local/var / Nginx上运行ls -la,结果如下:

drwxr-xr-x 4 nickcorin admin 136 Apr 20 23:53 .

drwxr-xr-x 5 nickcorin admin 170 Apr 20 21:47 ..

-rw-r--r-- 1 root admin 4718 Apr 21 08:06 access.log

-rw-r--r-- 1 nickcorin admin 480 Apr 21 10:28 error.log

这是我的网络服务器根目录上的结果:

drwxr-xr-x 4 nickcorin staff 136 Apr 22 12:23 .

drwx-----x+ 54 nickcorin staff 1836 Apr 22 10:01 ..

drwxr-xr-x 3 nickcorin staff 102 Apr 20 22:14 example

-rw-r--r--@ 1 nickcorin staff 23 Apr 19 11:58 info.PHP

这是ps aux的结果| grep Nginx:

root 756 0.0 0.0 2466616 480 ?? Ss 12:24PM 0:00.00 Nginx: master process Nginx

nickcorin 759 0.0 0.0 2445080 820 s000 S+ 12:24PM 0:00.00 grep Nginx

nobody 757 0.0 0.0 2475832 1044 ?? S 12:24PM 0:00.00 Nginx: worker process

**编辑#2-虚拟主机配置文件**

我设法解决了我的问题,现在一切似乎进展顺利.我必须将虚拟主机配置文件编辑为此:

server {

listen 80;

listen [::]:80 ipv6only=on;

server_name local.example.com;

root /Users/nickcorin/webserver/example;

index index.PHP index.html index.htm;

location ~ \.PHP${

try_files $uri =404;

fastcgi_split_path_info ^(.+\.PHP)(/.+)$;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.PHP;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

}

我还通过以下两行修复了我的权限:

sudo chown -R nickcorin /Users/nickcorin/webserver (Web Server Root)

sudo chmod 755 /Users/nickcorin/webserver/example (Virtual Host Root)

谢谢所有帮助我弄清楚这个问题的人:)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值