我在尝试通过Access denied
或http://dev
地址访问WebServer时收到http://devserver
消息。我不知道我的Nginx配置有什么问题。以下是config.php
和default
网站配置:
/etc/nginx/nginx.conf
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/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 /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
## Load virtual host conf files. ##
include /etc/nginx/sites-enabled/*;
}
此文件具有指向/etc/nginx/sites-enabled
的符号链接,因此已启用:
/etc/nginx/sites-available/default
server {
listen 80 default;
listen [::]:80 default ipv6only=on;
# Make site accessible from http://localhost/ or server IP-address
server_name dev devserver;
server_name_in_redirect off;
charset utf-8;
root /var/www/html;
index index.php index.html index.htm;
location / {
# First attempt to serve request as file, then
# as directory, then trigger 404
try_files $uri $uri/ =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT /var/www/html;
# send bad requests to 404
fastcgi_intercept_errors on;
include fastcgi_params;
}
}
我在使用Nginx 1.6.2的CentOS 6.6和使用PHP-FPM的PHP 5.5.18。我也禁用SELinux,我唯一拥有的是Iptables。其他网站运行良好,网站我指的是任何指向root
目录的网站,例如这是一个Symfony2项目:
server {
server_name newsite.dev newsite.webvm newsite;
root /var/www/html/newsite.dev/web;
location / {
# try to serve file directly, fallback to app.php
try_files $uri /app.php$is_args$args;
}
location ~ ^/(app|app_dev|config)\.php(/|$) {
#fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
}
access_log /var/log/nginx/newsite.dev/access.log;
error_log /var/log/nginx/newsite.dev/error.log;
}
在这种情况下,调用http://newsite.dev
或http://newsite.webvm
或http://newsite
我会得到预期的结果,但第一个网站却没有用,而我不知道还能做什么,所以任何有关配置的帮助或建议以及为什么不提供内容?