Nuxt SSR 阿里云部署之nginx代理--详解篇

前言:由于很多小伙伴私信我,关于阿里云部署NUXT 应用的问题,在这里具体详细的介绍一下

我的服务器版本是CentOS7

所需工具: Xftp5   Xshell5(有远程仓库的就不需要Xftp5 直接推到你的服务器)
步骤: 1 安装配置 nvm(node)2 mysql  3  配置 nginx(Tengine)4 pm2 启动

一.  安装配置nvm 安装node: 点击地址

二.  安装mysql点击地址

     安装完毕 设置密码  source mysql.sql  导入你的sql文件

三.  配置nginx

    1、 下载tengine包,将tengine-2.2.0.tar.gz下载到 /usr/soft目录中。

    2、 解压tengine包到 /usr/src中:

        cd /usr/src
        cp /usr/soft/tengine-2.2.0.tar.gz ./
        tar -zxvf tengine-2.2.0.tar.gz
        rm -rf tengine-2.2.0.tar.gz

    3、 安装必须组件

         yum -y install gcc gcc-c++
      PCRE:
         cd /usr/src
         tar zxvf pcre-8.39.tar.gz
        ./configure --prefix=/usr/local/pcre-8.39
        make && make install
     OpenSSL:
        cd /usr/src
       tar zxvf openssl-1.0.2.tar.gz
       ./config --prefix=/usr/local/openssl-1.0.2
       make && make install
    Zlib:
       cd /usr/src
       wget www.zlib.net/zlib-1.2.11…
       tar zxvf zlib-1.2.11.tar.gz
      ./configure --prefix=/usr/local/zlib-1.2.11
       make && make install

  4、 设置软链接和开机启动服务

      ln -s /etc/init.d/nginx /usr/bin/nginx
     chmod 755 nginx
     chkconfig --add nginx
     chkconfig nginx on  

   5、 nginx 配置文件

    worker_processes 1;
    error_log logs/error.log;
    error_log logs/error.log notice;
    error_log logs/error.log info;
    pid logs/nginx.pid;
    events {
       use epoll;
       worker_connections 1024;
     }
    http {
       include mime.types;
       default_type application/octet-stream;
      sendfile on;
      keepalive_timeout 65;
     #gzip on;
     include /usr/local/nginx/conf/conf_site/*.conf; // 单独  include  conf文件
   }


  6、 include的conf配置 

    server{
       listen 80;
       location / {
         deny all;
        }
    }
   upstream maven_domain_com {
       server localhost:8000; // 自己的服务器ip
    }
   server{
        listen 80;  // 监听80端口
        server_name maven.domains.com; // 自己的二级域名
        location / {
           proxy_pass http://maven_domains_com/nexus/;
           proxy_set_header Host $host;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       } 
       location /nexus/ {
           proxy_pass http://maven_domain_com/nexus/;
           proxy_set_header Host $host;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       }
    }

7. 启动nginx

   cd /usr/local/nginx/  

   ./nginx

四. 整理代码放到服务器

打开Xftp  左上角 新建 会话

 

然后打开


选择刚才新建的


连接成功 之后 进入服务器的 root 账户的 根目录 (下图)

五 启动项目

把你的项目直接拖拽到你想放置的目录,

切换到项目

npm install 安装包的依赖 (可能会出各种包兼容问题)

如果出现包兼容问题,把package.json 文件的包的版本前 的^去掉

然后删除 rm -f -r  ./node_modules

清除 包缓存  npm  clear  cache

然后安装yarn  npm install  yarn -g

重新用yarn 安装一次

 yarn install

安装pm2

yarn add pm2

先执行 npm run dev

然后执行 pm2 start bulid/main.js

执行 pm2 list # 显示所有进程状态

显示online  就表示已经启动

如果访问不通 可以查看下 pm2 logs 



也可以执行 pm2 monit # 监视所有进程


现在 输入你的域名进行访问把~~~~


成功部署~~~ 

已经部署成功的开源项目 点击连接



另外推荐一个 node项目 压力测试模块:autocannon





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值