操作系统:Cent OS 6.4 64位
我在我的服务器上安装了nginx以及PHP和MySQL,我在nginx配置文件中进行了配置,设置了服务器名称并在端口80上进行了监听。
但是,我第一次尝试通过URL访问服务器,我收到了错误
“与*的连接被中断了。”
这是我在/etc/nginx/conf.d/default.conf中的配置文件(注意:我已经将服务器名设置为子域。)
#
# The default server
#
server {
listen 80;
server_name *;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
location ~ \.php$ {
proxy_pass http://127.0.0.1;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root /usr.share/nginx/html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
任何想法为什么?或者我在哪里可以找到问题?
答案 0 :(得分:0)
只是猜测。
您不能简单地在同一台机器上运行Apache和Nginx,它们都在端口80上监听。
Can two applications listen to the same port?
该消息表示建立websocket连接存在问题。检查是否已正确配置nginx以允许通过Websocket连接。
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
使用
检查日志sudo tail -f /var/log/nginx/access.log /var/log/nginx/error.log