【问题标题】:I think to have everything set correctly but hen i test my nginx server i get an error我认为一切都设置正确,但是当我测试我的 nginx 服务器时出现错误
【发布时间】:2022-01-05 07:01:16
【问题描述】:

我正在尝试第一次设置 nginx 服务器来部署 laravel 应用程序。

我已经完成了所需的每个步骤,安装了 php、mysql、composer ecc

比我创建一个配置文件如下:

server {
listen 80;
server_name 142.93.111.117;
root /var/www/colosseo60/public;

add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";

index index.html index.htm index.php;

charset utf-8;

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

location = /favicon.ico {return 204; access_log off; log_not_found of
f; }
location = /robots.txt { access_log off; log_not_found of
f; }

error_page 404 /index.php;

location ~ \.php$ {

fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_s

cript_name;

include fastcgi_params;
}

location ~ /\.(?!well-known).* {
deny all;
}
}

然后我也在sites-enabled目录中创建它的副本

但是当我尝试测试我的 nginx 服务器是否正常工作时(sudo nginx -t)我得到了这个错误:

nginx: [emerg] invalid number of arguments in "log_not_found" directive in /etc/nginx/sites-enabled/colosseo60:19
nginx: configuration file /etc/nginx/nginx.conf test failed

现在我试图找到解决此错误的方法大约需要 4 个小时,但似乎我无法在网上找到任何环顾四周。

有没有人可以帮我解决这个问题?

如果有人认为这是一个简单的问题,请提前抱歉,但我是一个完美的菜鸟,我快疯了。

非常感谢

【问题讨论】:

    标签: laravel nginx digital-ocean virtual-server


    【解决方案1】:

    [已解决] 错误是因为每个函数都是从 VIM 编辑器自动剪切的。

    我在配置文件中解决了以下问题:

    server {
    listen 80;
    server_name 142.93.111.117;
    root /var/www/colosseo60/public;
    
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";
    
    index index.html index.htm index.php;
    
    charset utf-8;
    
    location / {
    try_files $uri $uri/ /index.php?$query_string;
    }
    
    location = /favicon.ico {
    return 204;
    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/php8.0-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
    
    include fastcgi_params;
    }
    
    location ~ /\.(?!well-known).* {
    deny all;
    }
    }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-11-11
      • 2020-04-23
      • 1970-01-01
      • 1970-01-01
      • 2016-11-10
      • 2018-08-05
      • 1970-01-01
      相关资源
      最近更新 更多