如何解决404 Not Found CentOS NGINX 数字海洋 Laravel
我用 nginx 在服务器上设置了最新的 centos 8
我有多个项目将在服务器上运行
例如:
var/www/html/project1
var/www/html/project2
var/www/html/project3
我已经配置了我的 NGINX.conf 文件如下
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
log_format scripts '$document_root$fastcgi_script_name > $request';
access_log /var/log/nginx/access.log main;
access_log /var/log/nginx/scripts.log scripts;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /var/www/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
index index.php index.html index.htm;
location / {
try_files $uri /index.html index.php;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass unix:/var/run/php-fpm/www.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
并且服务器在 ipaddress 上运行,因此在服务器名称中我刚刚将 _ 作为服务器名称,它将被视为 localhost 或 ip。
但是当我运行项目时
http://IPADDRESS/project1
http://IPADDRESS/project2
我在配置脚本日志时收到 404 错误。我发现它出错了,如下
/var/log/nginx/scripts.log
/var/www/html/project1/public/404.html > GET /project1/ HTTP/1.1
/var/www/html/project2/public/404.html > GET /project2/ HTTP/1.1
请指导我在 NGINX 配置上哪里出错
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。