繁体   English   中英

从上游读取响应 header 时主脚本未知

[英]Primary script unknown while reading response header from upstream

I am setting up new laravel project with nginx server configuration,in sites-available and sites-enabled files i have setup the laravel project details and i added host name in etc/hosts location also,when i hit url( http://hrmcc .test/ )在浏览器中我面临浏览器正文中找不到文件的消息,你能帮我解决这个问题吗

error in log

2022/08/17 13:24:34 [error] 4801#4801: *4 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 127.0.0.1, server: hrmcc.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "hrmcc.test"

sites-available && sites-enabled

server {
listen 80;
server_name hrmcc.test;
root /home/deploy/hrm_v3.2/public;

index index.html index.htm index.php;

charset utf-8;

location / {
try_files $uri $uri/ /index.php?$query_string;
}



location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }

access_log off;
error_log /var/log/nginx/hrmc-error.log error;

sendfile off;

client_max_body_size 100m;

location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;


fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
}


}

浏览器出错

尝试使用默认的 Laravel NGINX 配置。

server {
    listen 80;
    listen [::]:80;
    server_name example.com;
    root /home/deploy/hrm_v3.2/public;
 
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-Content-Type-Options "nosniff";
 
    index index.php;
 
    charset utf-8;
 
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
 
    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }
 
    error_page 404 /index.php;
 
    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }
 
    location ~ /\.(?!well-known).* {
        deny all;
    }
}

这应该有效。 确保您的 php-fpm 套接字存在于您的配置中的位置。 还要确保通过运行nginx -t来测试您的配置。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM