ZBLOG

还原nginx默认配置

nginx默认配置文件的路径通常是在/etc/nginx/nginx.conf。以下是一个还原nginx默认配置文件的示例:

# nginx.conf

user www-data;
worker_processes auto;
pid /run/nginx.pid;

events {
    worker_connections 768;
}

http {
    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;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    gzip on;
    
    # 配置服务器
    server {
        listen 80;      # 监听端口

        root /usr/share/nginx/html;   # 网站根目录
        
        index index.html index.htm;   # 默认首页文件名
        
        server_name localhost;        # 域名或IP地址

        location / {
            try_files $uri $uri/ =404;   # 处理请求
        }

        error_page 404 /404.html;       # 错误页面
       
        location = /404.html {
            internal;
        }

        error_page 500 502 503 504 /50x.html;     # 错误页面
       
        location = /50x.html {
            internal;
        }
        
    }
}

这只是一个基本的默认配置,你可以根据需要进行自定义修改。请注意备份原有的配置文件以防止数据丢失或出现问题。


内容由零声教学AI助手提供,问题来源于学员提问

本站部分文章来源于网络,版权归原作者所有,如有侵权请联系站长删除。
转载请注明出处:https://golang.0voice.com/?id=9095

分享:
扫描分享到社交APP
上一篇
下一篇
发表列表
游客 游客
此处应有掌声~
评论列表

还没有评论,快来说点什么吧~

联系我们

在线咨询: 点击这里给我发消息

微信号:3007537140

上班时间: 10:30-22:30

关注我们
x

注册

已经有帐号?