Linux中安装Nginx、项目部署集群搭建、多站点反向代理

一:安装依赖(已安装可忽略此步骤)

yum -y install gcc gcc-c++ automake pcre pcre-devel zlib zlib-devel open openssl-devel  

二:下载nginx安装包

wget http://nginx.org/download/nginx-1.16.1.tar.gz 

三:解压nginx

1.编译如果提示./configure: error: the HTTP rewrite module requires the PCRE library.,则执行yum -y install pcre-devel后重新编译
2.提示./configure: error: the HTTP gzip module requires the zlib library.,则执行yum install -y zlib-devel后重新编译

// 1.解压nginx
tar -zxvf nginx-1.16.1.tar.gz

// 2.解压完成后,切换到nginx目录
cd nginx-1.16.1/

// 3.需要使用https执行指令
./configure  --with-http_ssl_module
// or 不需要使用https执行
./configure 

四:执行安装命令

// 1.执行安装命令
make && make install

// 2.查看编译参数
./configure --help | more 

五:开放访问端口80(可自定义,可忽略)

// 不同centos 系统指令有差别
/sbin/iptables -I INPUT  -p tcp --dport 80 -j ACCEPT

六:更改nginx.conf文件

// 1.切换到conf目录
cd usr/local/nginx/conf

// 2.编辑redis.conf
vi redis.conf

1.修改端口号,这里默认使用的8088,因为80可能会让apahce占用

2.修改location,注释掉暂用不到的页面参数,添加proxy_pass,后跟需要跳转的地址

3.保存

// 保存
:wq

七:查看配置文件是否正确

cd /usr/local/nginx/sbin

./nginx -t

结果:

八:运行

// 切换到sbin文件夹下
cd /usr/local/nginx/sbin
// 默认配置文件启动
./nginx

// 指定配置文件启动
./nginx -c  /usr/local/nginx/conf/nginx.conf

// 停止指令
./nginx -s stop

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值