CentOS7安装Nginx

1、下载nginx下载地址

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

2、解压

tar -zvxf nginx-1.20.1.tar.gz 

3、预编译
进入解压后的目录 nginx-1.20.1进行预编译 ./configure --prefix=/opt/nginx 注意:–prefix是指定安装目录(建议指定)


出现错误 ./configure: error: C compiler cc is not found
image
解决方法:yum -y install gcc gcc-c++


出现错误 ./configure: error: the HTTP gzip module requires the zlib library.
image
解决方法: yum -y install zlib-devel


出现错误./configure: error: the HTTP rewrite module requires the PCRE library. image

解决方法: yum -y install pcre-devel


这里表示已成功预编译
image
4、编译
make
出现错误:-bash: make: 未找到命令 (-bash: make: command not found)
image
解决方法: yum -y install make autoconf
5、安装

make install

安装结束后进入 /opt/nginx/sbin (前面指定安装目录地址/sbin)
image
然后启动 ./nginx 这条命令成功没有输出
image
查看启动状态 ps -ef |grep nginx
image
然后打开浏览器访问
image
如果出现访问不了,尝试关闭防火墙 systemctl stop firewalld.service 再访问。

永久关闭防火墙 systemctl disable firewalld.service
image

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值