nginx配置椽子取代apache2
我在笔记本电脑上运行apache2作为web服务器,然后我决定改用nginx -安装nginx-php(fastcgi-fpm)而不删除apache -使用下一个规则配置/etc/nginx/site enabled/defaultnginx配置椽子取代apache2,nginx,Nginx,我在笔记本电脑上运行apache2作为web服务器,然后我决定改用nginx -安装nginx-php(fastcgi-fpm)而不删除apache -使用下一个规则配置/etc/nginx/site enabled/default root /var/www; index index.html index.htm index.php; location /doc/ { alias /usr/share/doc/; autoindex on; allow 127
root /var/www;
index index.html index.htm index.php;
location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
deny all;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-cgi alone:
fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
#fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
在浏览器中键入nig localhost,其响应为403禁止
键入127.0.0.1:9000此网页不可用
12.0.0.1禁止
我发现这是一个权限问题,但我运行chmod777var/www
和apache2在运行显示网站时
那么,我的配置有什么问题,或者我遗漏了什么呢?如果上述内容是默认文件的唯一内容,那么我想知道为什么nginx会启动。您必须创建一个服务器块:
server {
listen 80;
server_name _;
root /var/www;
index index.html index.htm index.php;
location /doc/ {
alias /usr/share/doc;
autoindex on;
allow 127.0.0.1;
deny all;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
}
}
在(重新)启动之前,请始终使用
nginx-t
检查您的配置。您应该配置一个错误日志文件,因为这可能有助于调试内容:error\u log/var/log/nginx/your.site.com/error.log warn代码>。您可以使用debug
而不是warn
来获取全部消息。操作系统的风格是什么?您可以检查/var/log/nginx/
吗?还可以检查php fpm
日志。error.log文件显示,对于键入localhost:[error]5231#0:*1重写或内部重定向循环,而对于键入localhost/website#folder:[error]5231#0:*2目录索引/var/www/禁止,客户端:127.0.0.1,服务器:localhost,请求:“GET/HTTP/1.1”,主机:“localhost”[error]5231#0:*2在内部重定向到“/index.html”时重写或内部重定向循环,客户端:127.0.0.1,服务器:localhost,请求:“GET/favicon.ico HTTP/1.1”,主机:“localhost”nginx-t nginx:[警报]无法打开错误日志文件:open()“/var/log/nginx/error.log”失败(13:权限被拒绝)2013/06/19 12:30:15[warn]3549#0:只有在主进程以超级用户权限运行时,“user”指令才有意义,在/etc/nginx/nginx.conf:1 nginx中被忽略:配置文件/etc/nginx/nginx.conf语法正常2013/06/19 12:30:15[emerg]3549#0:open()“/var/run/nginx.pid”失败(13:权限被拒绝)nginx:configuration file/etc/nginx/nginx.conf测试失败检查/var/log/nginx/error.log的权限,并始终以su
或root用户身份执行所有与nginx相关的命令。