标签:linux软件包管理
C语言源代码编译安装三步骤:1、./configure
(1) 通过选项传递参数,指定启用特性、安装路径等;执行时会参考用户的指定以及Makefile.in文件生成Makefile
(2) 检查依赖到的外部环境,如依赖的软件包
2、make 根据Makefile文件,构建应用程序
3、make install 复制文件到相应路径
Quick Start - Unix
$ ./configure --prefix=PREFIX
$ make
$ make install
$ PREFIX/bin/apachectl start 指定路径开启软件
1编译安装准备
(1)查看相同软件并卸载,下载源码(建议官网下载) ,rz传入 建议放在/usr/local/src里并解包 。以httpd-2.2.34.tar.bz2 为例
[root@centos7 ~]#cd /usr/local/src
[root@centos7 src]#tar -xf httpd-2.2.34.tar.bz2 默认解压在当前目录
[root@centos7 src]#ls
httpd-2.2.34 httpd-2.2.34.tar.bz2
[root@centos7 httpd-2.2.34]#ls 显示开发工具
ABOUT_APACHE buildconf emacs-style INSTALL LICENSE os srclib
acinclude.m4 CHANGES httpd.dep InstallBin.dsp Makefile.in README support
Apache.dsw config.layout httpd.dsp LAYOUT Makefile.win README.platforms test
build configure httpd.mak libhttpd.dep modules README-win32.txt VERSIONING
BuildAll.dsp configure.in httpd.spec libhttpd.dsp NOTICE ROADMAP
BuildBin.dsp docs include libhttpd.mak NWGNUmakefile server
configure Makefile.in 开发工具
(2)安装"开发包组"提供开发组件
[root@centos7 httpd-2.2.34]#yum grouplist "Developmet Tools"
2看说明
[root@centos7 httpd-2.2.34]#cat INSTALL
[root@centos7 httpd-2.2.34]#cat README
3生成Makefile
cd进入configure脚本所在目录
[root@centos7 httpd-2.2.34]#./configure --help
Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local/apache2] 默认安装目录路径 建议指定目录方便管理
……
[root@centos7 httpd-2.2.34]#./configure --prefix=/app/httpd22 --enable-ssl 指定目录路径 启用功能加密
checking for OpenSSL version... checking openssl/opensslv.h usability... no
……
no OpenSSL headers found
checking for SSL-C version... checking sslc.h usability... no
checking sslc.h presence... no
checking for sslc.h... no
no SSL-C headers found
configure: error: ...No recognized SSL/TLS toolkit detected 缺openssl-devel包
[root@centos7 httpd-2.2.34]#echo $?
1 外部环境出错
检查依赖的外部环境
[root@centos7 httpd-2.2.34]#yum install openssl-devel.x86_64 安装所缺少依赖的包
[root@centos7 httpd-2.2.34]#./configure --prefix=/app/httpd22 --enable-ssl 再次执行使其完成
[root@centos7 httpd-2.2.34]#echo $?
0 完成
[root@centos7 httpd-2.2.34]#ll
……
-rw-r--r--. 1 root root 8954 Aug 5 10:59 Makefile ./configure执行时参考用户的指定以及Makefile.in生成Makefile
-rw-r--r--. 1 1001 1001 8739 Nov 26 2008 Makefile.in
-rw-r--r--. 1 1001 1001 34759 Jan 20 2014 Makefile.win
……
[root@centos7 httpd-2.2.34]#make && make install 开始编译 安装生成到指定目录 指定目录自动生成
[root@centos7 httpd-2.2.34]#ls /app/httpd22
bin build cgi-bin conf error htdocs icons include lib logs man manual modules
[root@centos7 httpd-2.2.34]#pwd
/usr/local/src/httpd-2.2.34 可删除当前目录
4软件配置 (PREFIX/bin/apachectl start 生效配置文件路径)
(1)安装后的配置
二进制程序目录导入至PATH环境变量中
编辑文件/etc/profile.d/NAME.sh export PATH=/PATH/TO/BIN:$PATH
./etc/profile.d/NAMEsh 使配置文件实现
(2)导入库文件路径
编 辑/etc/ld.so.conf.d/NAME.conf 添加新的库文件所在目录至此文件中 让系统重新生成缓存: ldconfig
(3)导入帮助手册
编辑/etc/man.config|man_db.conf文件 添加一个MANPATH
centos6 | centos7
[root@centos7 bin]#ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 5 192.168.122.1:53 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 128 127.0.0.1:631 *:* 80端口未开启
LISTEN 0 32 :::21 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 128 ::1:631 :::*
httpd提供web服务 端口为80端口
准备环境变量
[root@centos7 httpd22]#echo 'export PATH=/app/httpd22/bin:$PATH'>/etc/profile.d/httpd22.sh
(单引号防止变量展开生效 自己路径放前面防止系统的配置文件先生效)
[root@centos7 httpd22]#./etc/profile.d/httpd22.sh
[root@centos7 httpd22]#echo $PATH
/app/httpd22/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@centos7 httpd22]#which apachectl
/app/httpd22/bin/apachectl
[root@centos7 httpd22]#apachectl start 启动命令 配置文件/app/httpd22/bin
[root@centos7 httpd22]#ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 5 192.168.122.1:53 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 128 127.0.0.1:631 *:*
LISTEN 0 128 :::80 :::* 80端口打开
LISTEN 0 32 :::21 :::*
LISTEN 0 128 :::22 :::*
导入库文件路径
[root@centos7 man]#vim /etc/man_db.conf 修改httpd的man帮助文档
MANDATORY_MANPATH /app/httpd22/man
总结步骤如下
标签:linux软件包管理
原文地址:http://blog.51cto.com/13157015/2044479