您的位置:首页 > 其它

RHEL6基础二十四之RHEL软件包管理③源码安装

2013-11-07 13:57 330 查看
一、概述Linux系统中的软件大都是开源软件,这些软件总是以源码的形式最先发布,之后才会逐渐出现rpm、deb等封装包。下载应用程序的最新源码并编译安装,可以在程序功能、安全补丁等方面得到及时更新
对于RPM格式封装的应用程序,当作者在编译源代码程序的时候,有可能绑定了许多功能,安装时被绑定的其它功能也一并安装到Linux主机上,这样就可能造成一些安全隐患。因为RPM软件包的更新并没有源代码。通过对程序源代码进行重新配置并编译安装后,可以定制更灵活、更丰富的功能
当需要对现有的程序源代码进行适当修改,以便增加新的功能时,也必须释放出该软件的源代码,进行修改后再重新编译安装
二、编译安装
[b]编译安装的基本步骤[/b]
解包---tar
解包,释放出源代码文件

配置---./configure
该过程的主要作用是生成makefile文件。配置工作通常由源代码目录中的“configure”脚本文件来完成,配置结果将保存到源码目录中的makefile文件中。如果在配置过程中出现错误,通常是缺少相关的依赖软件包所致,一般只需根据提示安装对应的软件即可,“./configure”表示执行当前目录下的configure脚本文件,不同的应用程序其配置参数会存在区别,具体配置参数可以在源代码目录中执行“./configure --help”进行查看,但是有一个“--prefix”参数却是大多数开源软件所通用的,该配置参数用于指定软件包安装的目标文件夹。
[root@justin nagios-4.0.1]# ./configure -h
`configure' configures this package to adapt to many kinds of systems.
Usage: ./configure [OPTION]... [VAR=VALUE]...
...
Installation directories:
--prefix=PREFIX         install architecture-independent files in PREFIX
[/usr/local/nagios]
--exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
[PREFIX]
...
Fine tuning of the installation directories:
--bindir=DIR            user executables [EPREFIX/bin]
--sbindir=DIR           system admin executables [EPREFIX/sbin]
...
Optional Packages:
--with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
--without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
--with-nagios-user=<user>
sets user name to run nagios
--with-nagios-group=<grp>
sets group name to run nagios
--with-command-user=<user>
sets user name for command access
--with-command-group=<grp>
sets group name for command access
...
Report bugs to the package provider.
[root@justin nagios-4.0.1]#






编译---make

将源代码文件转变为二进制可执行程序,编译的过程主要是根据makefile文件中的配置信息,将源代码编译、连接成可执行程序
检测---make test / make check

顾名思义,这一步就是对上一步 make 的检查了,要确保 make 是没有错误的,也就是这一步的 test、check要全部是 OK 的,error 为0;这步可省略

[b]安装---make install[/b]
编译完成以后,就可以执行“make install”命令将软件的执行程序、配置文件等相关文件复制到Linux系统中了,即应用程序的最后“安装”过程

三、源码编译安装程序的卸载
很多source的Makefile都有写uninstall规则,如果原先的source还在,可直接在Souce里make uninstall&&make clean,然后重新configure......如果没有uninstall规则一句一句看Makefile里install部分他都干了些什么,然后挨个删除
编译安装ntfs-3g

[root@justin src]# wget http://tuxera.com/opensource/ntfs-3g_ntfsprogs-2013.1.13.tgz [root@justin src]# tar zxvf ntfs-3g_ntfsprogs-2013.1.13.tgz -C /usr/local/
[root@justin src]# cd /usr/local/ntfs-3g_ntfsprogs-2013.1.13
[root@justin ntfs-3g_ntfsprogs-2013.1.13]# yum -y install gcc
[root@justin ntfs-3g_ntfsprogs-2013.1.13]# ./configure --prefix=/usr/local/ntfs
[root@justin ntfs-3g_ntfsprogs-2013.1.13]# make && make install
[root@justin ntfs-3g_ntfsprogs-2013.1.13]# ntfs-3g
ntfs-3g: No device is specified.
ntfs-3g 2013.1.13 integrated FUSE 27 - Third Generation NTFS Driver
Configuration type 1, XATTRS are on, POSIX ACLS are off
Copyright (C) 2005-2007 Yura Pakhuchiy
Copyright (C) 2006-2009 Szabolcs Szakacsits
Copyright (C) 2007-2012 Jean-Pierre Andre
Copyright (C) 2009 Erik Larsson
Usage:    ntfs-3g [-o option[,...]] <device|image_file> <mount_point>
Options:  ro (read-only mount), windows_names, uid=, gid=,
umask=, fmask=, dmask=, streams_interface=.
Please see the details in the manual (type: man ntfs-3g).
Example: ntfs-3g /dev/sda1 /mnt/windows
News, support and information:  http://tuxera.com [root@justin ntfs-3g_ntfsprogs-2013.1.13]#
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息