首页 > 代码库 > UNIX/Linux 系统管理技术手册阅读(十)
UNIX/Linux 系统管理技术手册阅读(十)
2016.11.4 9:30-10:15
Adding new software
If you do need to install additional software, you first need to determine the canonical name of the relevant software package. For example, you’d need to translate “I want to install locate” to “I need to install the findutils package,” or translate “I need named” to “I have to install BIND.” A variety of system-specific indexes on the web can help with this, but Google is usually just as effective. For example, a search for “locate command” takes you directly to several relevant discussions. If you’re on a UNIX system, throw in the name of the operating system as well.
1.12.2 增加新软件
如果需要安装额外的软件,首先要确定相关软件包的标准名称。例如,需要把“我想装locate”转移为“我需要安装findutils软件包”,或者把“我要named”转移为“我必须安装BIND”。在网上各种针对特定系统的索引能够帮助做转换,但是Google通常更有效。例如,搜索“locate命令”,就能直接找到若干与之相关的讨论。如果是在UNIX系统上,那么还需要输入操作系统的名字。
Once you know the name of the relevant software, you can download and install it. The complete installation is usually a single command on Linux systems and on Solaris systems that have pkgutil installed. For HP-UX and AIX you’ll have to download either a prebuilt binary package or the project’s original source code. If the latter, try to locate the project’s official web page through Google and download the source code from one of the project’s mirrors.
一旦知道了相关软件的确切名称,就可以下载并安装它。在Linux和安装了pkutil的Solaris系统上,整个安装过程通常用一条命令就够了,对于HP-UX和AIX而言,则要么下载预编译好的二进制软件包,要么下载项目的源代码。如果是后者,需要通过Google定位该项目的正式网站,然后从项目的镜像站点之一下载源代码。
The following examples show the installation of the wget command on each ofour example systems. It’s a nifty GNU utility that turns HTTP and FTP downloads into atomic commands—very useful for scripting. wget is installed by default on each of our example Linux systems, but the commands shown below can be used for both initial installation and later updates.
Ubuntu uses APT, the Debian Advanced Package Tool:
ubuntu# apt-get install wget
The SUSE version is
suse# yast --install wget
The Red Hat version is
redhat# yum install wget
On a Solaris system with pkutil already installed (see blastwave.org for instructions on setting this up)
solaris# /opt/csw/bin/pkgutil --install wget
<multiple pages of output as seven packages are installed>
For HP-UX, we found an appropriate binary package on hpux.connect.org.uk and
downloaded it to the /tmp directory. The commands to unpack and install it were
hpux# gunzip /tmp/wget-1.11.4-hppa-11.31.depot.gz
hpux# swinstall -s /tmp/wget-1.11.4-hppa-11.31.depot wget
下面的例子展示了在我们的每一种示例系统上安装wget命令。它是一个很棒的GNU工具,能够把HTTP和FTP下载变成单条命令---对于脚本编程来说非常有用。我们所举的每种Linux系统默认都安装了wget,但是下面给出的命令用于初始化安装和后续升级。
The package depot on the swinstall command line must be specified as a full path starting with /; otherwise, swinstall tries to find the file on the network. The wget at the end tells swinstall which package to install from within the depot file.
在swinstallw不像话地里出现的depot软件包必须用/开头的完整路径;否则,swinstall就会到网络上找文件。最后的wget告诉swinstall从depot文件里安装哪个软件包。
Unfortunately, the installation is not really as easy as it first appears. The installed
version of wget won’t actually run because several of the libraries on which it depends have not been installed:
hpux$ wget http://samba.org/samba/docs/Samba3-HOWTO.pdf
/usr/lib/dld.sl: Can‘t open shared library: /usr/local/lib/libcrypto.sl
/usr/lib/dld.sl: No such file or directory
[HP ARIES32]: Core file for 32 bit PA-RISC application
[HP ARIES32]: /usr/local/bin/wget saved to /tmp/core.wget.
遗憾的是,这个安装各种没有乍看上去那么简单。装好的wget版本实际上无法运行,因为没有装它所依赖的几个库。
swinstall does have some dependency management built in, but its abilities unfortunately do not extend to Internet repositories. You’ll have to read the fine print and install all the appropriate prerequisite packages (in this case, six more) to make things right.
swinstall内置有依赖关系的管理机制,但是遗憾的是,它的这种功能不能延伸到Internet上的软件库里。用户不得不根据提示安装预装的软件包(本例中有6个之多)以达到最终目录。
Building software from source code
There is in fact at least one binary wget package available for AIX in RPM format. A Google search for “aix wget rpm” should turn up some good leads. After downloading, the installation command would be a simple
aix# rpm --install wget-1.11.4-1.aix5.1.ppc.rpm
1.12.3 从源代码编译软件
实际上,wget到少存在一种可用于AIX的二进制软件包,它是RPM格式的。用Google搜索“aix wget rpm”应该就能找到一些不错的线索。下载下载之后,安装命令很简单
aix# rpm --install wget-1.11.4-1.aix5.1.ppc.rpm
But just for illustration, let’s build the AIX version of wget from the original source code.
但是为了演示,我们从源代码开始编译AIX版本的wget。
Our first chore is to find the code, but that’s easy: the first Google result for “wget”
takes us right to the project page at GNU, and the source tarball is just a link away.
After downloading the current version into the /tmp directory, we unpack, configure, build, and install it:
aix# cd /tmp; gunzip wget-1.11.4.tar.gz
aix# tar xfp wget-1.11.4.tar
aix# cd wget-1.11.4
aix# ./configure --disable-ssl --disable-nls # See comments below
configure: configuring for GNU Wget 1.11.4
checking build system type... rs6000-ibm-aix
…
config.status: creating src/config.h
config.status: executing default commands
generating po/POTFILES from ./po/POTFILES.in
creating po/Makefile
aix# make
<several pages of compilation output>
aix# make install
<about a page of output>
我们的第一项任务是找到代码,这很容易:用google搜索“wget”得到的第一个结果就正好把我们指向GNU的wget项目,再点一下就能找到源代码的tar包。反当前版本的代码下载到/tmp目录里,再解开、配置和安装:
This configure/make/make install sequence is common to the majority of UNIX and Linux software and works on all systems as long as you have the development environment and any package-specific prerequisites installed. However, it’s always a good idea to check the package’s INSTALL or README file for specifics.
对于大多数UNIX和Linux软件来说,都可以依次执行configure/make/make install三条命令,只要已经安装了开发环境以及预先要求的软件包,就会得到结果。不过,最好查看软件包的INSTALL或者README文件,了解该软件的特别之处。
In this case, the --disable-ssl and --disable-nls options to configure omit some wget features that depend on other libraries that haven’t been installed. In real life, you’d probably want to install the prerequisites. Use configure --help to see all the configuration options. Another useful configure option is --prefix=directory, which lets you put the software somewhere other than /usr/local.
在这个例子里,configure命令的两个选项--disable-ssl和--disable-nls省略了wget的一些特性,这些特性要依赖其他一些还没有安装的库。在实际中,用户可能想还是安装要求预装的那些库。使用confiugre--help查看所有的配置选项。另一个有用的配置选项是--perfix=directory,这个选项可以把软件安装到/usr/local之外的其他目录里。
本文出自 “赵东伟的博客” 博客,请务必保留此出处http://zhaodongwei.blog.51cto.com/4233742/1869234
UNIX/Linux 系统管理技术手册阅读(十)