nginx vue php 第一个站点配置

24 篇文章 0 订阅
17 篇文章 1 订阅

单独使用nginx

server {
        listen       8080;
        server_name  nlocal.ijisq.com;
        root /Users/xhcheng/ghworkspace/ijisq-front/dist;
        location / {
            try_files $uri $uri/ /index.html;
        }
        location /api {
            rewrite ^/api/(.*)$ /$1 break;
            proxy_pass http://127.0.0.1:8899;
        }
        location /pay {
            rewrite ^/pay/(.*)$ /paysdk/$1 break;
            #rewrite ^/pay/(.*)$ /paysdk/$1 permanent;
            proxy_pass http://127.0.0.1:8899;
        }
}
server {
        listen 8899;
        server_name 127.0.0.1;
        root /Users/xhcheng/bobworkspace/ijisq-api/public;
        location / {
            rewrite ^/(.*)$ /index.php/$1 last;
            break;
        }
        location /paysdk/ {
            alias /Users/xhcheng/bobworkspace/ijisq-api/thirdparty/paysdk/;
            index index.php;
        }
        location ~ ^/paysdk/.+\.php$ {
            root /Users/xhcheng/bobworkspace/ijisq-api/thirdparty/;
            rewrite /paysdk/(.*\.php?) /$1 break;
            include fastcgi.conf;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME /Users/xhcheng/bobworkspace/ijisq-api/thirdparty/paysdk$fastcgi_script_name;
        }
        location ~ .+\.php($|/) {
            set $script $uri;
            set $path_info "/";
            if ($uri ~ "^(.+\.php)(/.+)") {
               set $script $1;
               set $path_info $2;
            }

            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php?IF_REWRITE=1;
            include fastcgi.conf;
        }
}

使用nginx+apache

server {
        listen       8080;
        server_name  nlocal.ijisq.com;
        root /Users/xhcheng/ghworkspace/ijisq-front/dist;
        location / {
            try_files $uri $uri/ /index.html;
        }
        location /api {
            rewrite ^/api/(.*)$ /$1 break;
            proxy_pass http://local.ijisq-api.com;
        }
        location /pay {
            rewrite ^/pay/(.*)$ /paysdk/$1 permanent;
            proxy_pass http://local.ijisq-api.com;
        }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
配置Nginx以托管Vue.js应用程序,您可以遵循以下步骤: 1. 安装Nginx:首先,确保您的服务器上已安装Nginx。您可以使用适合您操作系统的包管理器来安装Nginx。 2. 创建Vue.js应用程序:在您的服务器上,使用Vue CLI或其他方式创建Vue.js应用程序。确保在构建应用程序时生成了静态文件。 3. 配置Nginx:打开Nginx配置文件,通常位于 `/etc/nginx/nginx.conf` 或 `/etc/nginx/sites-available/default`。编辑该文件以进行以下配置更改: ```nginx server { listen 80; # Nginx监听的端口,可以根据需要进行更改 server_name your_domain.com; # 替换为您的域名或服务器IP地址 root /path/to/your/vue-app/dist; # 替换为您Vue.js应用程序构建后的静态文件目录 index index.html; location / { try_files $uri $uri/ /index.html; } } ``` 在上述配置中,请注意替换以下内容: - `listen`:指定Nginx监听的端口。 - `server_name`:指定您的域名或服务器IP地址。 - `root`:指定您Vue.js应用程序构建后生成的静态文件目录的路径。 4. 保存并退出配置文件后,重新启动Nginx服务:执行以下命令来重新启动Nginx服务,以使配置生效: ```bash sudo systemctl restart nginx ``` 5. 测试:在浏览器中访问您的域名或服务器IP地址,应该能够看到您的Vue.js应用程序已经成功部署在Nginx上。 这是一个简单的配置示例,您可以根据自己的需求进行更改和扩展。请确保您的服务器防火墙已经允许通过Nginx的监听端口进行访问。 希望这可以帮助您成功配置Nginx来托管Vue.js应用程序!如有其他疑问,请随时提问。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值