CentOS7安装Nginx及./configure: error: the HTTP rewrite module requires the PCRE library.错误解决

Nginx简介

Nginx是一个高性能的Http和反向代理Web服务器,同时也提供了IMAP/POP3/SMTP服务。

  • 占用内存少,并发能力强;
  • 官方给出数据,最高支持5W个并发连接数的相应。

Nginx作用

  1. 反向代理:代理服务器;正向代理:代理客服端
  2. 负载均衡:内置策略和扩展策略
    • 内置策略:
      • 轮训:将请求依次发到指定服务器,每个服务机会均等
      • 加权轮训(权重):权重越高,接收请求越多,
      • Ip hash:对客户端请求的ip进行hash操作,根据hash结果,将同一个客户端ip的请求分发给同一台服务器进行处理,解决Session不共享问题,但是服务器挂掉,数据将丢失。(建议使用Redis做Session共享)
    • 扩展策略:略
  3. 动静分离:

Nginx安装

下载地址:http://nginx.org/en/download.html

Windows安装
  1. 下载解压即可使用
Linux安装

如果未安装gcc 和gcc-c++可能需要先安装

yum -y install gcc
yum -y install gcc-c++

开始安装具体步骤如下:

whereis nginx #检查是否安装Nginx

tar -zxvf 安装包 #解压安装包

./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,具体命令如下:

yum -y install pcre-devel openssl openssl-devel

安装成功后,继续操作=

./configure #自动配置

make #执行make命令

make install #执行make install 

whereis nginx #查看安装目录/usr/local/nginx

cd /usr/local/nginx/sbin 

./nginx #启动nginx 访问ip:80/

如果出现Linux可以访问失败,则查看端口是否开放

firewall-cmd --list-ports
#8080/tcp

firewall-cmd --zone=public --add-port=80/tcp --parmanent #开启80端口

systemctl restart firewalled.service #重启防火墙

firewall-cmd --list-ports #查看端口
Nginx常用命令
./nginx #启动
./nginx -s stop #停止
./nginx -s quit #安全退出
./nginx -s reload #重新加载配置文件
ps -ef|grep nginx  #查看Nginx进程

Nginx使用

后期补充

刚开始学习Nginx,如果不对之处,请各位大佬指正!
此文章根据视频自己总结,视频链接:狂神说

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值