网站前端是nuxt框架,后端是php,用宝塔怎么部署,用一个域名的情况下

达到如下图的效果,前后端不分开部署,公用一个域名

网站前端是nuxt框架,后端是php,怎么部署宝塔,用一个域名的情况下

《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
chowjiawei
最佳答案
location /自己取个前缀 {
        alias /var/www/autotest/fontend/dist;  //你的项目
        index index.htm index.html;
        try_files $uri $uri/ /index.html last;
    }

在你的后端nginx中加上去

3个月前 评论
Alone88 3个月前
win27149 (楼主) 3个月前
wuchenge 3个月前
chowjiawei (作者) 3个月前
讨论数量: 7
chowjiawei
location /自己取个前缀 {
        alias /var/www/autotest/fontend/dist;  //你的项目
        index index.htm index.html;
        try_files $uri $uri/ /index.html last;
    }

在你的后端nginx中加上去

3个月前 评论
Alone88 3个月前
win27149 (楼主) 3个月前
wuchenge 3个月前
chowjiawei (作者) 3个月前
唐章明
server {
    listen 80; # 或者你想要监听的端口
    server_name yourdomain.com; # 你的域名

    # Vue项目配置
    location / {
        root /path/to/vue/dist; # Vue项目构建后的文件路径
        try_files $uri$uri/ /index.html; # 处理Vue路由的history模式
    }

    # PHP项目配置,处理/api路径
    location /api {
        proxy_pass http://localhost:8080; # 假设PHP项目运行在本地的8080端口
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }

    # 其他配置...
}
3个月前
server {
    listen 80;
    index index.php index.html index.htm default.php default.htm default.html;
    server_name home.mychat.cloud;
    root 你的dist所在位置;

    location  /api {
        rewrite ^/api/(.*)$ /$1 break;
        proxy_pass http://127.0.0.1:8888; # 设置代理服务器的协议和地址  端口要和后端部署保持一致
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

和gin vue admin 这种框架的部署不是一样

3个月前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!