Nginx源码安装

系统版本:Redhat 8.0

nginx版本:1.20.2

要安装nginx,需要先有yum源。要进入/etc/yum.repos.d 安装yum源

wget http://mirrors.aliyun.com/repo/Centos-8.repo
 yum clean all 
 yum makecache 
 yum repolist 

关闭防火墙和SElinux

systemctl stop firewalld.service #关闭防火墙
vim /etc/selinux/config #编辑selinux 

setenforce 0 #临时生效,关闭selinux
getenforce #查看selinux为什么状态,为Permissive 就是关闭状态

开始安装nginx

[root@Wang]cd /usr/local/src/ #将nginx安装在/usr/local/src/
[root@Wang src]# wget http://nginx.org/download/nginx-1.20.2.tar.gz #下载nginx压缩
[root@Wang src]# ls
nginx-1.20.2.tar.gz  
[root@Wang src]# tar -xf nginx-1.20.2.tar.gz  #解压
[root@Wang src]# ls
nginx-1.20.2  nginx-1.20.2.tar.gz  

[root@Wang src]# cd nginx-1.20.2/ #进入nginx目录,为了执行其他操作
[root@Wang nginx-1.20.2]# ./configure --prefix=/usr/local/nginx --with-http_ssl_module 
checking for OS
 + Linux 4.18.0-193.el8.x86_64 x86_64
checking for C compiler ... not found

./configure: error: C compiler cc is not found

#这时候告诉我们缺少C编译环境,因为nginx是c语言编写的,所有需要安装c编译环境
[root@Wang nginx-1.20.2]# yum -y  groupinstall 'Development Tools'
#可以一次性安装很多常用的开发包,包括gcc,g++等编译文件必须的工具
[root@Wang nginx-1.20.2]# yum -y install pcre pcre-devel #需要指定pcre的路径
[root@Wang nginx-1.20.2]# yum -y install openssl openssl-devel
[root@Wang nginx-1.20.2]# ./configure --prefix=/usr/local/nginx --with-http_ssl_module
#再来重新执行脚本,就不会报错了
[root@Wang nginx-1.20.2]# make && make install #编译安装
[root@Wang nginx-1.20.2]# /usr/local/nginx/sbin/nginx #开启nginx
[root@Wang nginx-1.20.2]# ps -ef |grep nginx  #查看nginx进程

进入浏览器查看nginx主页

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值