网站首页 > 精选文章 / 正文
通常在CentOS上我们采用默认方式安装nginx:yum install nginx,安装完成后,进行server配置,然后将测试网页上传到服务器对应的目录下,启动nginx服务。
这时候,我们从后台可以看到nginx服务已经启动了,但是访问网站就是无法显示测试网页index.html的信息,返回页面仍然是nginx的测试页面,到底是怎么回事呢?
[root@hamster1 ~]# ps -ef | grep nginx
root 6310 5816 0 20:45 pts/0 00:00:00 grep --color=auto nginx
root 20882 1 0 12月18 ? 00:00:00 nginx: master process nginx
nginx 21094 20882 0 12月18 ? 00:00:00 nginx: worker process
其实很简单,我们只需要在配置文件中注释下面这一行,并重启nginx服务即可:
#include /etc/nginx/conf.d/*.conf;
全部的配置文件如下:
nginx version: nginx/1.20.2
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
#include /etc/nginx/conf.d/*.conf;
server {
listen 80;
server_name xxxx.com;
location / {
root /data/www;
index index.html;
}
}
}
Tags:nginx指定配置文件重启
猜你喜欢
- 2025-06-15 Nginx配置前后端服务(nginx配置前端项目)
- 2025-06-15 nginx访问403报错(nginx域名访问403)
- 2025-06-15 在Centos 8 上 部署 .Net Core 应用程序
- 2025-06-15 nginx 80端口重定向到443端口(ingress-nginx 修改80端口)
- 2025-06-15 uwsgi+nginx项目部署(nginx部署项目步骤)
- 2025-06-15 从零开始搭建HTTPS服务(https建立)
- 2025-06-15 Nginx部署Vue项目以及解决刷新页面404
- 2025-06-15 Nginx动态配置upstream(nginx动态配置文件)
- 2025-06-15 实战录 | 今天聊聊Nginx反向代理使用
- 2025-06-15 彻底搞懂容器启动、停止、调试的每一个细节!