概念:
源码包指的是开发编写好的程序源代码,但并没有将其编译为一个能正常使用的二进制工具。
c --> 源代码编译操作–<<二进制文件>>直接运行
为什么需要源码包:
1.部分软件官网仅提供源码包,需要自行编译并安装。
2部分软件在新版本有一些特性还没来得及制作成rpm包时,可以自行编译软件使用其新特性
3.源码包–>打包成一个rpm格式; rpm方式安装标准;
如何获取:
见的软件包都可以在官网获取源码包,比如 apache nginx mysql nginx
http://nginx.org/en/download.html
http://httpd.apache.org/download.cgi
https://www.zabbix.com/cn/download
此方法不是百分百通用于所有源码包,建议拿到源码包解压后,进入到目录找相关的README帮助文档
下面通过编译nginx源码包演示编译过程。
yum install -y make gcc wget
wget http://nginx.org/download/nginx-1.18.0.tar.gz
解压
root@localhost yum.repos.d]# tar -xf nginx-1.18.0.tar.gz
[root@localhost yum.repos.d]# cd nginx-1.18.0/
[root@localhost nginx-1.18.0]# ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src
yum install -y make gcc pcre pcre-devel zlib-devel openssl openssl-devel
./configure --prefix=/opt/nginx-1.18.0
然后生成了makefile的记录
Configuration summary
+ using system PCRE library
+ OpenSSL library is not used
+ using system zlib library
nginx path prefix: "/opt/ngnix-1.18.0"
nginx binary file: "/opt/ngnix-1.18.0/sbin/nginx"
nginx modules path: "/opt/ngnix-1.18.0/modules"
nginx configuration prefix: "/opt/ngnix-1.18.0/conf"
nginx configuration file: "/opt/ngnix-1.18.0/conf/nginx.conf"
nginx pid file: "/opt/ngnix-1.18.0/logs/nginx.pid"
nginx error log file: "/opt/ngnix-1.18.0/logs/error.log"
nginx http access log file: "/opt/ngnix-1.18.0/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
./configure --prefix=/usr/bin/local/nginx-1.18.0/ --with-http_stub_status_module --with-http_ssl_module
make&&make install
ln -s /usr/bin/local/nginx-1.18.0/sbin/nginx /usr/bin/nignx
编译ok