nginx - Nginx:本地站点加载一段时间,然后以“找不到服务器”中止
问题描述
我刚刚在我的机器上安装了 nginx,并想用一个非常简单的 index.html 对其进行测试。但是,该站点加载了几秒钟,然后以“未找到服务器”中止。这是我的 nginx.conf:
user http;
worker_processes auto;
worker_cpu_affinity auto;
events {
multi_accept on;
worker_connections 1024;
}
http {
charset utf-8;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
server_tokens off;
log_not_found off;
types_hash_max_size 4096;
client_max_body_size 16M;
# MIME
include mime.types;
default_type application/octet-stream;
# logging
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log warn;
# load configs
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
server{
listen 80;
listen [::]:80;
server_name test.local;
root /home/marvw/Programme/Privat/Test;
location / {
index index.php index.html index.htm;
}
}
}
比较奇怪的是,错误和访问日志都是空的。我仔细检查了 URL,它绝对是正确的。Nginx 运行没有任何错误,这是我的 systemd 状态输出:
Active: active (running) since Sat 2019-12-21 00:45:40 +01; 7min ago
Process: 2171 ExecStart=/usr/bin/nginx -g pid /run/nginx.pid; error_log stderr; (code=exited, status=0/SUCCESS)
Main PID: 2172 (nginx)
Tasks: 9 (limit: 4915)
Memory: 7.9M
CGroup: /system.slice/nginx.service
├─2172 nginx: master process /usr/bin/nginx -g pid /run/nginx.pid; error_log stderr;
├─2173 nginx: worker process
├─2174 nginx: worker process
├─2175 nginx: worker process
├─2176 nginx: worker process
├─2177 nginx: worker process
├─2178 nginx: worker process
├─2179 nginx: worker process
└─2180 nginx: worker process
Dez 21 00:45:40 <<personal information>> systemd[1]: Starting A high performance web server and a reverse proxy server...
Dez 21 00:45:40 <<personal information>> systemd[1]: Started A high performance web server and a reverse proxy server.
解决方案
尝试添加test.local
到您的主机或将其更改为localhost
. “找不到服务器”不是 Nginx 问题。
推荐阅读
- javascript - 尝试使用 JavaScript 添加删除功能,当我单击它时需要删除整个表单。顺便说一句,我正在使用引导程序
- python - 查找字符串中所有占位符的pythonic方法
- firebase - 将类组件的“上传图像到firebase”代码修改为功能组件
- php - 使用 mysqli_fetch 的原因是什么?
- java - 如何制作一个简单的 gradle 构建脚本来编译 java 程序?
- r - 在 R 中有效地重塑非标准虚拟编码矩阵或表格
- javascript - map() 中的 reactjs-jsx 计数索引
- python - 如果文件与给定的文件名匹配,如何打开文件(使用语音识别获得的文件名)
- go - 在 Go Gorm 中添加具有多对多反向引用的记录
- python-3.x - Jupyter Notebook:终端不可用