nginx 启动项目

安装

yum install nginx

配置

在/etc/nginx/conf.d目录下,创建xxx.conf文件
写入

server {
    listen       8081;
    server_name  localhost;
    root         /home/chat-front/dist;  # 替换为你的dist目录绝对路径
    index        index.html;

    location / {
        try_files $uri $uri/ /index.html;
    }

    # 禁用favicon.ico日志(可选)
    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }
}

注意,dist文件夹如果放在/root有可能导致访问失败,报错500,如果报错可以通过tail -n 50 /var/log/nginx/error.log查看日志

posted @ 2025-04-07 17:18  iiiiiiiivan  阅读(184)  评论(0)    收藏  举报