源码包编译安装

源码包编译安装

实战

1.用源码包来安装部署nginx

第一步:基本环境的准备及编译软件的安装

[root@kh3 ~]# yum -y install gcc gcc-c++ make wget

第二步:下载源码包

注释:nginx的包在nginx: download下载

[root@kh3 ~]# wget http://nginx.org/download/nginx-1.24.0.tar.gz

在这里插入图片描述

第三步:解压源码包

在这里插入图片描述

第四步:配置相关选项,并设置Makefile

查看选项:

在这里插入图片描述

//后面的内容省略了,使用 ./configure --help 命令查看可以使用的选项
//一般常用的有 --prefix=PREFIX 这个选项的意思是定义软件包安装到哪里
//建议,源码包都是安装在/opt/目录下

第五步:指定编译参数,生成makefile

在这里插入图片描述
在这里插入图片描述

生成成功!!!

第六步:在makefile的目录进行编译安装

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

第七步:编写环境变量

在这里插入图片描述
在这里插入图片描述

查看80端口:

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

访问:

在这里插入图片描述

但是这样是临时编写的

永久编写环境变量:

在这里插入图片描述

注意事项:

  • 如果安装时不是使用的默认路径,则必须要修改PATH环境变量,以能够识别此程序的二进制文件路径;

    • 修改/etc/profile文件或在/etc/profile.d/目录建立一个以.sh为后缀的文件,在里面定义export PATH=$PATH:/path/to/somewhere
  • 默认情况下,系统搜索库文件的路径只有/lib,/usr/lib

    • 增添额外库文件搜索路径方法:

      • 在/etc/ld.so.conf.d/中创建以.conf为后缀名的文件,而后把要增添的路径直接写至此文件中。此时库文件增添的搜索路径重启后有效,若要使用增添的路径立即生效则要使用ldconfig命令
    • ldconfig:通知系统重新搜索库文件

/etc/ld.so.conf和/etc/ls.so.conf.d/*.conf *//*配置文件

/etc/ld.so.cache *//*缓存文件

-v *//*显示重新搜索库的过程

-p *//*打印出系统启动时自动加载并缓存到内存中的可用库文件名及文件路径映射关系

写入数据库的库文件:

在这里插入图片描述
在这里插入图片描述

头文件:输出给系统

    • 默认:系统在/usr/include中找头文件,若要增添头文件搜索路径,使用链接进行

路径头文件:

在这里插入图片描述

链接:

在这里插入图片描述

  • man文件路径:安装在–prefix指定的目录下的man目录

    • 默认:系统在/usr/share/man中找man文件。此时因为编译安装的时候不是安装到默认路径下,如果要查找man文件则可以使用以下两种方法:

      • man -M /path/to/man_dir command
      • 在/etc/man_db.conf文件中添加一条MANPATH

在这里插入图片描述

源码编译报错信息处理

checking for C compiler … not found ./configure: error: C compiler cc is not found

//解决方案
[root@localhost ~]# yum -y install gcc gcc-c++ make

./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= option.

//解决方案
[root@localhost ~]# yum install -y pcre-devel

./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-
http_gzip_module option, or install the zlib library into the
system, or build the zlib library statically from the source with
nginx by using --with-zlib= option.

//解决方案:
[root@localhost ~]# yum -y install zlib-devel

./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL
library into the system, or build the OpenSSL library statically
from the source with nginx by using --with-openssl= option.

//解决方案
[root@localhost ~]# yum -y install openssl-devel

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值