antdPro项目部署到nginx

部署前准备

在完成你的antd项目之后,从coding或者你的git服务器上克隆项目到本地

$ git clone 你的项目
$ cd project
$ npm install

成功下载完所有配置文件之后执行,再次确认你的项目可以正确访问

$ npm start

即可自动打开浏览器的8000端口,成功运行该项目,如果没有自动弹出则访问localhost:8000/

部署配置

在项目中的.roadhogrc文件中删除以下配置

"proxy": {
  "/api": {
  "target": 你的后台服务地址,
  "changeOrigin": true,
  "pathRewrite": { "^/api" : "" }
  }
}

之后进入命令行,执行编译操作

$ npm run build

执行完之后会在主目录下生成dist文件夹,里面包含index.html、index.js、index.css以及资源文件夹static。
打包完成后,把dist文件夹上传至服务器上即可访问,这里用的是nginx服务器。

nginx简介

Nginx(发音同 engine x)是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行。

本项目采用 Nginx 作为 Web 服务器。

安装nginx

由于服务器是ubuntu系统,这里仅展示在ubuntu系统下安装过程,其他操作系统可自行查找

登录服务器之后执行,下载nginx安装包

$ sudo wget http://nginx.org/download/nginx-1.2.2.tar.gz

然后解压

$ sudo  tar -xzvf nginx-1.2.2.tar.gz

进入解压之后的文件夹

$ cd nginx-1.2.2
$ ./configure

如果一切顺利的话,执行

$ make
$ make install

完成安装,可以在/usr/local文件下找到nginx文件夹

然后访问服务器即可看到

welcome nginx

nginx安装常见问题

  • 缺少pcre

执行./configure之后,出现

./configure: error: the HTTP rewrite module requires the PCRE library. You can either disable the module by using --without-http_rewrite_module option, or install the PCRE library into the system, or build the PCRE library statically from the source with nginx by using --with-pcre=<path> option.

即提示缺少pcre library

$ sudo apt-get undate
$ sudo apt-get install libpcre3 libpcre3-dev
  • 缺少gcc-c++和libtool

执行./configure之后,出现

libtool: compile: unrecognized option `-DHAVE_CONFIG_H'
libtool: compile: Try `libtool --help' for more information.
make[1]: *** [pcrecpp.lo] Error 1
make[1]: Leaving directory `/usr/local/src//pcre-8.31'
make: *** [all] Error 2root@wolfdog-virtual-machine:~/work/pcre-8.12$ libtool -help -DHAVE_CONFIG_H
The program 'libtool' is currently not installed.  You can install it by typing:
sudo apt-get install libtool

即提示缺少libtool和gcc-c++

$ sudo apt-get install libtool
$ sudo apt-get install gcc-c++
  • 缺少zlib库

执行./configure之后,出现

./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.

其提示缺少zlib库

$ sudo apt-get install openssl libssl-dev libperl-dev

nginx配置

nginx的配置文件在/usr/local/nginx/conf文件夹下,其主要的配置文件是nginx.conf文件,编辑该文件

$ vi nginx.conf

具体配置在nginx配置博客中作详细说明

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值