CentOS 安装 Nginx 并配置开机自启(简洁版)
前言简单记录一下 CentOS 安装 Nginx、配置代理、设置开机自启纯干货复制即用。一、安装 Nginxyum install -y nginx二、启动 Nginxsystemctl start nginx三、设置开机自启重要systemctl enable nginx四、修改 Nginx 配置vi /etc/nginx/nginx.conf直接替换成下面内容nginxworker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; location / { proxy_pass http://127.0.0.1:8443; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } }五、重启 Nginx 生效systemctl restart nginx六、放行 80 端口防火墙开启才执行firewall-cmd --add-servicehttp --permanent firewall-cmd --reload常用命令启动systemctl start nginx 停止systemctl stop nginx 重启systemctl restart nginx 查看状态systemctl status nginx 开机自启systemctl enable nginx 关闭自启systemctl disable nginx