Linux软件管理二:源码包管理

1.源码包

一个软件要在Linux上执行,必须是二进制文件,因此当我们拿到软件源码后,需要将它编译成二进制文件才能在Linux上运行。
源码包的编译用到了linux系统里的编译器,通常源码包都是用C语言开发的,这也是因为C语言为linux上最标准的程序语言。Linux上的C语言编译器叫做gcc,利用它就可以把C语言变成可执行的二进制文件。

源码安装的优点:编译安装过程,可以设定参数按照需求增加功能,进行安装,并且可以指定安装的版本,可以指定安装路径,灵活性比较大。

源码包官方网站,可以获得最新的软件包 :
mysql: http://www.mysql.com/

[root@localhost ~]# wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.27.tar.gz

2.安装源码包

准备工作(去Nginx官网下载Nginx软件的源码包www.nginx.org )

2.1.编译环境如编译器gcc、make

[root@localhost ~]# yum -y install gcc make zlib-devel pcre pcre-devel openssl-devel

gcc:编译工具,编译单个文件
make:可以看成是一个智能的批处理工具,通过调用makefile文件中用户指定的命令来进行编译和链接的。(将这种高级语言写的代码编译成二进制语言)
pcre:支持正则表达式
zlib-devel:有些应用依赖于这个库才能正常运行,因此需要安装zlib-devel
openssl-devel:某些库文件等跟开发相关的东西。

2.2. 准备软件 nginx-1.16.0.tar.gz

2.3. 部署安装Nginx软件服务

(注意:nginx服务和httpd服务有冲突,关闭或者卸载httpd)
实战:

[root@localhost ~]# wget http://nginx.org/download/nginx-1.16.1.tar.gz
[root@localhost ~]# tar xzf nginx-1.16.1.tar.gz
[root@localhost nginx-1.16.1]# ./configure --user=www --group=www --prefix=/usr/local/nginx
[root@localhost nginx-1.16.1]# make  #编译文件
[root@localhost nginx-1.16.1]# make install  #安装文件
[root@localhost ~]# useradd www   #创建nginx用户
[root@localhost ~]# /usr/local/nginx/sbin/nginx  #启动nginx
[root@localhost ~]# systemctl stop firewalld  #关闭防火墙

2.4.停止nginx

[root@localhost nginx-1.16.1]# /usr/local/nginx/sbin/nginx -s stop

访问:
1

3.详解源码安装三步曲

  1. 预编译:指定安装路径,例如 --prefix=/usr/local/nginx
  2. 编译:检查安装环境,例如是否有编译器gcc,是否满足软件的依赖需求 最终生成:Makefile
  3. 安装:软件模块或者功能的启用禁用

相对路径执行安装

[root@localhost ~]# ./configure

按Makefile文件编译,产生可执行的文件。但是这个文件在当前目录中

[root@localhost ~]# make

按Makefile定义的文件路径安装,将产生的可执行文件,安装到合适的位置,相当于拷贝

[root@localhost ~]# make install

4.源码安装错误(企业案例)

错误1: ./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=<path> option. 
解决方案: 
[root@localhost ~]# yum -y install zlib-devel
错误2: ./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=<path> option. 
​解决方案:
[root@localhost ~]# yum -y install openssl-devel
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

TA548464

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

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

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

打赏作者

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

抵扣说明:

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

余额充值