vue ubuntu服务器配置

1.打包vue项目上传到服务器目录 /home/dhwww
没有权限,可以先上传到当前用户目录下,再copy到dhwww文件夹
2.安装Nginx
sudo apt-get install nginx
3.配置Nginx
3.1 查看Nginx目录:

root@VM-4-11-ubuntu:/home# whereis nginx
nginx: /usr/sbin/nginx /usr/lib/nginx /etc/nginx /usr/share/nginx /usr/share/man/man8/nginx.8.gz

3.2 配置

cd /etc/nginx/sites-enabled
vim default

        server_name  localhost;
        root /home/dhwwww/dist;

        # Add index.php to the list if you are using PHP
        index index.html;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ @router; # 指向下面的 @router否则会出现 404
        }

        location @router {

           rewrite ^.*$ /index.html last;

        }

4.重启Nginx
nginx -s reload
5.访问外网地址

posted @   hczhhm  阅读(36)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 实操Deepseek接入个人知识库
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· 【.NET】调用本地 Deepseek 模型
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
点击右上角即可分享
微信分享提示