Linux 环境下nginx源代码安装

1、下载上传并解压安装包

2、安装yum源以及nginx依赖的库

3、生成makefile

4、编译安装

5、启动nginx

6、浏览器验证启动成功

1.下载安装包

系统版本:Redhat 9.0

nginx版本:1.20.2

nginx官网:https://nginx.org/dowanload/

开始安装nginx

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

2.安装yum源以及nginx依赖的库

[root@bfr src]# yum install gcc gcc-c++ pcre  pcre-devel openssl openssl-devel zlib  zlib-devel -y

vim /etc/selinux/config #编辑selinux

配置文件编辑内容如下:

3.生成makefile

[root@bfr src]# cd nginx-1.20.2/  #进入nginx目录,为了执行其他操作
[root@bfr 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@bfr nginx-1.20.2]# yum -y  groupinstall 'Development Tools'
#可以一次性安装很多常用的开发包,包括gcc,g++等编译文件必须的工具

4.编译安装

[root@bfr nginx-1.20.2]# yum -y install pcre pcre-devel #需要指定pcre的路径
[root@bfr nginx-1.20.2]# yum -y install openssl openssl-devel
[root@bfr nginx-1.20.2]# ./configure --prefix=/usr/local/nginx --with-http_ssl_module

#再来重新执行脚本,就不会报错了
[root@bfr nginx-1.20.2]# make && make install #编译安装

5.启动nginx
[root@bfr nginx-1.20.2]# /usr/local/nginx/sbin/nginx
#开启nginx
[root@bfr nginx-1.20.2]# ps -ef |grep nginx  #查看nginx进程

[root@bfr nginx-1.20.2]# chkconfig nginx on #配置开机启动


 

6.浏览器验证成功

#红色加框输入虚拟机IP地址

  • 23
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值