7-源代码编译安装——安装源代码包
2016.6.4
确认源代码编译环境
安装前:
- gcc --version
[root@test1 Packages]# gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- make --version
[root@test1 Packages]# make --version
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program built for x86_64-redhat-linux-gnu
[root@test1 Packages]#
yum安装lrzsz用来从主机上传httpd到虚拟机
[root@test1 ~]# yum install lrzsz
Loaded plugins: fastestmirror, refresh-packagekit, security
Determining fastest mirrors
* base: www.ftp.ne.jp
* extras: www.ftp.ne.jp
* updates: www.ftp.ne.jp
updates | 3.4 kB 00:00
updates/primary_db | 748 kB 00:01
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package lrzsz.x86_64 0:0.12.20-27.1.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================
Package Arch Version Repository Size
========================================================================================================
Installing:
lrzsz x86_64 0.12.20-27.1.el6 base 71 k
Transaction Summary
========================================================================================================
Install 1 Package(s)
Total download size: 71 k
Installed size: 159 k
Is this ok [y/N]: y
Downloading Packages:
lrzsz-0.12.20-27.1.el6.x86_64.rpm | 71 kB 00:00
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
Userid : CentOS-6 Key (CentOS 6 Official Signing Key) <[email protected]>
Package: centos-release-6-5.el6.centos.11.1.x86_64 (@anaconda-CentOS-201311272149.x86_64/6.5)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
Installing : lrzsz-0.12.20-27.1.el6.x86_64 1/1
Verifying : lrzsz-0.12.20-27.1.el6.x86_64 1/1
Installed:
lrzsz.x86_64 0:0.12.20-27.1.el6
Complete!
[root@test1 ~]#
编译安装流程
下载源代码安装包文件
步骤1:tar解包
用途:解压并释放源代码包到指定的目录
步骤2:./configure配置
用途:设置安装目录、安装模块等选项
步骤3:make编译
用途:生成可执行的二进制文件
步骤4:make install 安装
用途:复制二进制文件到系统,配置应用环境
测试及应用维护软件
步骤1.解包
- 习惯上将软件包释放到/usr/src/ 目录
- 解包后的源代码文件位置:/usr/src/软件名-版本号/
- 示例:
- tar zxf httpd-2.2.15.tar.gz -C /usr/src/
将下载好的安装包传送到虚拟机当中
[root@test1 test]# rz
[root@test1 test]# ls
Desktop Documents Downloads httpd-2.2.15.tar.gz Music Pictures Public Templates Videos
[root@test1 test]#
解压缩
[root@test1 test]# tar xzf httpd-2.2.15.tar.gz -C /usr/src
[root@test1 test]# cd /usr/src
[root@test1 src]# ls
debug httpd-2.2.15 kernels
[root@test1 src]#
步骤2.
- 使用源码目录中的configure脚本
- 执行“./configure --help”可查看帮助
Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local/apache2]
- 典型的配置选项:
- --prefix=软件安装目录
- 示例:
- cd /usr/src/httpd-2.2.15/
- ./configure --prefix=/usr/local/apache
httpd-2.2.15文件夹中的内容
[root@test1 httpd-2.2.15]# ls -lh
total 1.2M
-rw-r--r-- 1 test test 15K Nov 22 2004 ABOUT_APACHE
-rw-r--r-- 1 test test 19K Nov 24 2008 acinclude.m4
-rw-r--r-- 1 test test 55K Mar 1 2010 Apache.dsw
drwxr-xr-x 5 test test 4.0K Mar 2 2010 build
-rw-r--r-- 1 test test 2.6K Aug 24 2007 BuildAll.dsp
-rw-r--r-- 1 test test 2.7K Jul 30 2009 BuildBin.dsp
-rwxr-xr-x 1 test test 5.7K Jul 12 2006 buildconf
-rw-r--r-- 1 test test 106K Mar 2 2010 CHANGES
-rw-r--r-- 1 test test 11K Nov 22 2004 config.layout
-rwxr-xr-x 1 test test 642K Mar 2 2010 configure
-rw-r--r-- 1 test test 24K Dec 2 2008 configure.in
drwxr-xr-x 9 test test 4.0K Mar 2 2010 docs
-rw-r--r-- 1 test test 403 Nov 22 2004 emacs-style
-rw-r--r-- 1 test test 4.1K Jun 12 2008 httpd.dsp
-rw-r--r-- 1 test test 18K Mar 2 2010 httpd.spec
drwxr-xr-x 2 test test 4.0K Mar 2 2010 include
-rw-r--r-- 1 test test 4.7K Sep 19 2008 INSTALL
-rw-r--r-- 1 test test 2.9K Dec 8 2006 InstallBin.dsp
-rw-r--r-- 1 test test 5.1K Nov 29 2005 LAYOUT
-rw-r--r-- 1 test test 17K Jan 12 2007 libhttpd.dsp
-rw-r--r-- 1 test test 29K Jan 19 2008 LICENSE
-rw-r--r-- 1 test test 8.6K Nov 26 2008 Makefile.in
-rw-r--r-- 1 test test 34K Mar 1 2010 Makefile.win
drwxr-xr-x 20 test test 4.0K Mar 2 2010 modules
-rw-r--r-- 1 test test 828 Jan 6 2009 NOTICE
-rw-r--r-- 1 test test 12K Nov 30 2009 NWGNUmakefile
drwxr-xr-x 9 test test 4.0K Mar 2 2010 os
-rw-r--r-- 1 test test 5.9K Jan 10 2007 README
-rw-r--r-- 1 test test 5.3K Oct 14 2009 README.platforms
-rw-r--r-- 1 test test 2.6K Aug 6 2009 README-win32.txt
-rw-r--r-- 1 test test 10K Mar 14 2005 ROADMAP
drwxr-xr-x 3 test test 4.0K Mar 2 2010 server
drwxr-xr-x 5 test test 4.0K Mar 2 2010 srclib
drwxr-xr-x 4 test test 4.0K Mar 2 2010 support
drwxr-xr-x 2 test test 4.0K Mar 2 2010 test
-rw-r--r-- 1 test test 8.0K Oct 18 2005 VERSIONING
[root@test1 httpd-2.2.15]#
./configure
[root@test1 httpd-2.2.15]# ./configure --prefix=/usr/local/apache
步骤3.编译
- 执行make命令
make
[root@test1 httpd-2.2.15]# make
...//省略
make[1]: Leaving directory `/usr/src/httpd-2.2.15'
[root@test1 httpd-2.2.15]#
```bash
[root@test1 httpd-2.2.15]# ls -lh
total 1.3M //make之后文件夹的大小发生变化
-rw-r--r-- 1 test test 15K Nov 22 2004 ABOUT_APACHE
-rw-r--r-- 1 test test 19K Nov 24 2008 acinclude.m4
-rw-r--r-- 1 test test 55K Mar 1 2010 Apache.dsw
drwxr-xr-x 5 test test 4.0K Jun 30 16:51 build
-rw-r--r-- 1 test test 2.6K Aug 24 2007 BuildAll.dsp
-rw-r--r-- 1 test test 2.7K Jul 30 2009 BuildBin.dsp
-rwxr-xr-x 1 test test 5.7K Jul 12 2006 buildconf
-rw-r--r-- 1 test test 106K Mar 2 2010 CHANGES
-rw-r--r-- 1 test test 11K Nov 22 2004 config.layout
-rw-r--r-- 1 root root 50K Jun 30 16:51 config.log //新增加的
-rwxr-xr-x 1 root root 89 Jun 30 16:51 config.nice //新增加的
-rwxr-xr-x 1 root root 40K Jun 30 16:51 config.status //新增加的
-rwxr-xr-x 1 test test 642K Mar 2 2010 configure
-rw-r--r-- 1 test test 24K Dec 2 2008 configure.in
drwxr-xr-x 9 test test 4.0K Mar 2 2010 docs
-rw-r--r-- 1 test test 403 Nov 22 2004 emacs-style
-rw-r--r-- 1 test test 4.1K Jun 12 2008 httpd.dsp
-rw-r--r-- 1 test test 18K Mar 2 2010 httpd.spec
drwxr-xr-x 2 test test 4.0K Jun 30 16:51 include
-rw-r--r-- 1 test test 4.7K Sep 19 2008 INSTALL
-rw-r--r-- 1 test test 2.9K Dec 8 2006 InstallBin.dsp
-rw-r--r-- 1 test test 5.1K Nov 29 2005 LAYOUT
-rw-r--r-- 1 test test 17K Jan 12 2007 libhttpd.dsp
-rw-r--r-- 1 test test 29K Jan 19 2008 LICENSE
-rw-r--r-- 1 root root 8.8K Jun 30 16:51 Makefile
-rw-r--r-- 1 test test 8.6K Nov 26 2008 Makefile.in
-rw-r--r-- 1 test test 34K Mar 1 2010 Makefile.win
drwxr-xr-x 20 test test 4.0K Jun 30 16:51 modules
-rw-r--r-- 1 root root 3.8K Jun 30 16:51 modules.c
-rw-r--r-- 1 test test 828 Jan 6 2009 NOTICE
-rw-r--r-- 1 test test 12K Nov 30 2009 NWGNUmakefile
drwxr-xr-x 9 test test 4.0K Jun 30 16:51 os
-rw-r--r-- 1 test test 5.9K Jan 10 2007 README
-rw-r--r-- 1 test test 5.3K Oct 14 2009 README.platforms
-rw-r--r-- 1 test test 2.6K Aug 6 2009 README-win32.txt
-rw-r--r-- 1 test test 10K Mar 14 2005 ROADMAP
drwxr-xr-x 3 test test 4.0K Jun 30 16:51 server
drwxr-xr-x 5 test test 4.0K Jun 30 16:51 srclib
drwxr-xr-x 4 test test 4.0K Jun 30 16:51 support
drwxr-xr-x 2 test test 4.0K Jun 30 16:51 test
-rw-r--r-- 1 test test 8.0K Oct 18 2005 VERSIONING
[root@test1 httpd-2.2.15]#
第一次可能是没有make,可能是make了两次,总之是有些错误
第二次make
步骤4.安装
- 执行make install命令
[root@test1 httpd-2.2.15]# make install
... //中间部分省略
make[2]: *** [libaprutil-1.la] Error 1
make[2]: Leaving directory `/usr/src/httpd-2.2.15/srclib/apr-util'
make[1]: *** [install-recursive] Error 1
make[1]: Leaving directory `/usr/src/httpd-2.2.15/srclib'
make: *** [install-recursive] Error 1
[root@test1 httpd-2.2.15]#
启动Apache:/usr/local/apache/bin/apachectl start
[root@test1 bin]# apachectl start
httpd: apr_sockaddr_info_get() failed for test1
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[root@test1 bin]#
vim /usr/local/apache/conf/httpd.conf
[root@test1 bin]# vim /usr/local/apache/conf/httpd.conf
#
ServerAdmin [email protected]
#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80
ServerName www.jason.com:80
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/usr/local/apache/htdocs"
#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
"/usr/local/apache/conf/httpd.conf" 410L, 13366C 98,1 22%
运行
[root@test1 bin]# apachectl start
httpd: apr_sockaddr_info_get() failed for test1
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
httpd (pid 56156) already running
[root@test1 bin]# vim /usr/local/apache/conf/httpd.conf
更改ServerName
[root@test1 bin]# apachectl start
httpd: apr_sockaddr_info_get() failed for test1
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
httpd (pid 59274) already running
[root@test1 bin]# lynx 127.0.0.1
运行lynx 127.0.0.1 查看本机Apache运行状态
没有解决的问题:不知道如何处理“httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName”