CentOS7和8下安装Nginx1.21.1

1、下载链接:http://nginx.org/download/
在这里插入图片描述
2、解压

tar -zxvf nginx-1.21.1.tar.gz

3、解压目录移至 /usr/local

mv nginx-1.21.1 /usr/local/

4、安装

./configure --prefix=/usr/local/nginx   //指定文件夹
make && make install

5、启动

cd /usr/local/nginx/sbin
./nginx

6、常见问题
(1)编译时报错:

./configure: error: the HTTP rewrite module requires the PCRE library.

在这里插入图片描述
解决方法:

yum -y install pcre-devel openssl openssl-devel

如果离线无法用yum安装pcre,下载以下rpm包进行安装:
pcre-8.32-17.el7.x86_64.rpm
pcre-devel-8.32-17.el7.x86_64.rpm
zlib-1.2.7-18.el7.x86_64.rpm
zlib-devel-1.2.7-18.el7.x86_64.rpm
运行安装命令:rpm -ivh xxxxx.rpm
rpm包可以在以下链接查找下载:
https://pkgs.org/
(2)报错:ginx: [emerg] the “ssl” parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:50
解决方法:
在源码目录执行:

./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

运行命令:

make

停止nginx,备份:

cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak

将./objs/nginx覆盖原来的nginx

cp ./objs/nginx /usr/local/nginx/sbin/nginx
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

奔跑吧邓邓子

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值