本文主要是介绍Linux中使用Ngin部署Web项目过程,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
安装所需插件
- 安装gcc
yum -y install gcc
- 安装pcre、pcre-devel
yum install -y pcre pcre-devel
- 安装zlib
yum install -y zlib zlib-devel
- 安装openssl
yum install -y openssl openssl-devel
安装nginx
- 下载nginx安装包
wget http://nginx.org/download/nginx-1.9.9.tar.gz
- 解压安装包
tar -zxvf nginx-1.9.9.tar.gz
- 切换到解压的文件目前下,执行三个命令
#http
./configure
#https(推荐)
./configure --prefix=/usr/local/nginx --with-http_ssl_module
make
make install
- 切换到/usr/local/nginx安装目录
cd /usr/local/nginx
- 配置nginx的配置文件nginx.conf文件(端口,反代理)
location / {root html;index index.html index.htm;try_files $uri $uri/ /index.html; #前端路由时 history 必填;
}location /api {proxy_pass https://www.192.168.0.1.com; #代理目标地址
}
- 启动nginx服务
./nginx
这篇关于Linux中使用Ngin部署Web项目过程的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!