打印/下载
安装&配置
虚拟主机

安装

# 安装
dnf install nginx -y
# 开机启动
systemctl enable nginx
systemctl start nginx

配置

vi /etc/nginx/nginx.conf

    user root

    keepalive_timeout 30;

    # Gzip压缩
    gzip on;
    gzip_buffers 4 8k;
    gzip_min_length 1k;
    gzip_types application/javascript text/css application/octet-stream application/pdf image/gif image/jpeg image/png image/x-icon;
    gzip_vary on;

    #include /etc/nginx/conf.d/*.conf;
    include /home/vhosts/*.conf;

配置虚拟主机

# 创建目录
mkdir -p /home/vhosts
# 编辑配置文件
vi /home/vhosts/default.conf
server {
    listen       80 default_server;
    listen       [::]:80 default_server;
    server_name  _;
    root         /home/www/;
    index index.html;

    location / {
    }

    error_page 404 /404.html;
    location = /40x.html {
    }
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    }
}

测试( http://IP/index.html )

# 创建文件
mkdir -p /home/www
echo '<h1>WebMIS</h1>' > /home/www/index.html
chmod -R 777 /home/www/index.html
# 重启Nginx
systemctl restart nginx
{{copy}}