-1

我正在尝试第一次设置 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 个小时,我试图找到解决此错误的方法,但似乎我无法在网上找到任何环顾四周。

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

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

太感谢了

4

1 回答 1

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;
}
}

于 2021-11-27T18:43:10.617 回答