您的位置:首页 > 运维架构 > Nginx

"Primary script unknown" while reading response header from upstream, client: 192.168.1.102, server:

2017-07-13 13:22 543 查看
配置好了nginx和php,结果访问报这个错,经排查,是我的默认nginx配置文件解析php那里没有写root,我之前以为只要上面写有就可以,因此把php那里删掉了。

贴一下正确的配置文件:

default.conf


server {
listen       80;
server_name  localhost 192.168.1.100;

#charset koi8-r;
#access_log  /var/log/nginx/host.access.log  main;

location / {
root   /usr/share/nginx/html;
index  index.php index.html index.htm;
}

#error_page  404              /404.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_index  index.php;
fastcgi_pass   127.0.0.1:9000;
include        fastcgi_params;
fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
#    deny  all;
#}
}


nginx.conf

[root@minimal my.cnf.d]# cat /etc/nginx/nginx.conf

user  www-data www-data;
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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  nginx php server
相关文章推荐