下载源码包
统一把源码包都放到 /usr/local/src/ 这个目录下。方便自己和其他管理员维护
Apache下载地址
2.2源码包:https://ftp.bit.nl/apache/httpd-2.2.29.tar.gz
最新地址请访问:http://r.aminglinux.com/
[root@evan-01 tmp]# cd /usr/local/src/
[root@evan-01 src]# ll
total 0
[root@evan-01 src]# wget https://ftp.bit.nl/apache/httpd-2.2.29.tar.gz
--2019-09-09 16:40:23-- https://ftp.bit.nl/apache/httpd-2.2.29.tar.gz
Resolving ftp.bit.nl (ftp.bit.nl)... 213.136.12.213, 2001:7b8:3:37::21:3
Connecting to ftp.bit.nl (ftp.bit.nl)|213.136.12.213|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7537230 (7.2M) [application/x-gzip]
Saving to: ‘httpd-2.2.29.tar.gz’
100%[==========================================================================================>] 7,537,230 325KB/s in 24s
2019-09-09 16:40:53 (308 KB/s) - ‘httpd-2.2.29.tar.gz’ saved [7537230/7537230]
[root@evan-01 src]# ls
httpd-2.2.29.tar.gz
[root@evan-01 src]#
解压压缩包
[root@evan-01 src]# tar -zxvf httpd-2.2.29.tar.gz
...(省略解压过程很多内容)
[root@evan-01 src]# ls
httpd-2.2.29 httpd-2.2.29.tar.gz
[root@evan-01 src]#
配置相关选项并生成 Makefile
看下安装文档
[root@evan-01 src]# cd httpd-2.2.29
[root@evan-01 httpd-2.2.29]# ll
total 1144
-rw-r--r--. 1 500 500 14882 Nov 22 2004 ABOUT_APACHE
-rw-r--r--. 1 500 500 18613 Jul 6 2012 acinclude.m4
-rw-r--r--. 1 500 500 56952 Oct 6 2010 Apache.dsw
drwxr-xr-x. 6 500 500 4096 Aug 23 2014 build
-rw-r--r--. 1 500 500 2644 Aug 24 2007 BuildAll.dsp
-rw-r--r--. 1 500 500 2692 Jul 30 2009 BuildBin.dsp
-rwxr-xr-x. 1 500 500 5786 Sep 19 2012 buildconf
-rw-r--r--. 1 500 500 136499 Aug 22 2014 CHANGES
-rw-r--r--. 1 500 500 11701 Feb 28 2012 config.layout
-rwxr-xr-x. 1 500 500 572978 Aug 23 2014 configure
-rw-r--r--. 1 500 500 24665 Jun 28 2013 configure.in
drwxr-xr-x. 9 500 500 124 Aug 23 2014 docs
-rw-r--r--. 1 500 500 403 Nov 22 2004 emacs-style
-rw-r--r--. 1 500 500 1248 May 7 2011 httpd.dep
-rw-r--r--. 1 500 500 4124 Jun 12 2008 httpd.dsp
-rw-r--r--. 1 500 500 8994 May 7 2011 httpd.mak
-rw-r--r--. 1 500 500 12053 Aug 23 2014 httpd.spec
drwxr-xr-x. 2 500 500 4096 Aug 23 2014 include
-rw-r--r--. 1 500 500 4372 Jan 18 2012 INSTALL
-rw-r--r--. 1 500 500 2909 Dec 8 2006 InstallBin.dsp
-rw-r--r--. 1 500 500 5145 Nov 29 2005 LAYOUT
-rw-r--r--. 1 500 500 30119 May 7 2011 libhttpd.dep
-rw-r--r--. 1 500 500 17039 Jan 12 2007 libhttpd.dsp
-rw-r--r--. 1 500 500 28503 May 7 2011 libhttpd.mak
-rw-r--r--. 1 500 500 28690 Jan 19 2008 LICENSE
-rw-r--r--. 1 500 500 8739 Nov 26 2008 Makefile.in
-rw-r--r--. 1 500 500 34759 Jan 20 2014 Makefile.win
drwxr-xr-x. 20 500 500 4096 Aug 23 2014 modules
-rw-r--r--. 1 500 500 828 Jan 3 2014 NOTICE
-rw-r--r--. 1 500 500 12894 Mar 16 2012 NWGNUmakefile
drwxr-xr-x. 9 500 500 149 Aug 23 2014 os
-rw-r--r--. 1 500 500 5954 Jan 10 2007 README
-rw-r--r--. 1 500 500 5332 Oct 14 2009 README.platforms
-rw-r--r--. 1 500 500 2553 Dec 21 2010 README-win32.txt
-rw-r--r--. 1 500 500 10183 Mar 14 2005 ROADMAP
drwxr-xr-x. 3 500 500 4096 Aug 23 2014 server
drwxr-xr-x. 5 500 500 64 Aug 23 2014 srclib
drwxr-xr-x. 4 500 500 4096 Aug 23 2014 support
drwxr-xr-x. 2 500 500 248 Aug 23 2014 test
-rw-r--r--. 1 500 500 8183 Oct 18 2005 VERSIONING
[root@evan-01 httpd-2.2.29]# more INSTALL
APACHE INSTALLATION OVERVIEW
Quick Start - Unix
------------------
For complete installation documentation, see [ht]docs/manual/install.html or
http://httpd.apache.org/docs/2.2/install.html
$ ./configure --prefix=PREFIX
$ make
$ make install
$ PREFIX/bin/apachectl start
NOTES: * Replace PREFIX with the filesystem path under which
Apache should be installed. A typical installation
might use "/usr/local/apache2" for PREFIX (without the
quotes).
* If you are a developer who will be linking your code with
Apache or using a debugger to step through server code,
./configure's --with-included-apr option may be advantageous,
as it removes the possibility of version or compile-option
mismatches with APR and APR-util code. (Many OSes now
include their own version of APR and APR-util.)
* If you are a developer building Apache directly from
Subversion, you will need to run ./buildconf before running
configure. This script bootstraps the build environment and
requires Python as well as GNU autoconf and libtool. If you
build Apache from a release tarball, you don't have to run
buildconf.
* If you want to build a threaded MPM (for instance worker)
on FreeBSD, be aware that threads do not work well with
Apache on FreeBSD versions before 5.4-RELEASE. If you wish
to try a threaded Apache on an earlier version of FreeBSD,
use the --enable-threads parameter to ./configure in
addition to the --with-mpm parameter.
* If you are building directly from Subversion on Mac OS X
(Darwin), make sure to use GNU Libtool 1.4.2 or newer. All
recent versions of the developer tools on this platform
include a sufficiently recent version of GNU Libtool (named
glibtool, but buildconf knows where to find it).
For a short impression of what possibilities you have, here is a
看到了步骤了
$ ./configure --prefix=PREFIX
$ make
$ make install
$ PREFIX/bin/apachectl start
常用的配置选项有 --prefix=PREFIX,它的意思是定义软件包的安装路径
配置目录并安装apache
[root@evan-01 httpd-2.2.29]# ./configure --prefix=/usr/local/apache2.2
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
Configuring Apache Portable Runtime library ...
checking for APR... reconfig
configuring package in srclib/apr now
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
Configuring APR library
Platform: x86_64-unknown-linux-gnu
checking for working mkdir -p... yes
APR Version: 1.5.1
checking for chosen layout... apr
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/usr/local/src/httpd-2.2.29/srclib/apr':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
configure failed for srclib/apr
[root@evan-01 httpd-2.2.29]#
排查问题
看到出现一些 no 预测出了问题,但不确定,这个时候,我们可以判断下是否正确
[root@evan-01 httpd-2.2.29]# echo $?
1
[root@evan-01 httpd-2.2.29]#
出现非0,表示有问题。echo $? 仅对上条命令生效,如果再 echo $? 就会变成0了
[root@evan-01 httpd-2.2.29]# echo $?
1
[root@evan-01 httpd-2.2.29]# echo $?
0
[root@evan-01 httpd-2.2.29]#
checking for gcc... no
checking for cc... no
checking for cl.exe... no
checking for gcc… no,没有安装 gcc 编译器,需要安装一下
安装gcc
[root@evan-01 httpd-2.2.29]# yum install -y gcc
配置目录并安装apache
echo $? 是0,证明没问题
[root@evan-01 httpd-2.2.29]# ./configure --prefix=/usr/local/apache2.2
...(过程略)
[root@evan-01 httpd-2.2.29]# echo $?
0
[root@evan-01 httpd-2.2.29]#
make
echo $? 是0,证明没问题
[root@evan-01 httpd-2.2.29]# make
...(过程略)
[root@evan-01 httpd-2.2.29]# echo $?
0
[root@evan-01 httpd-2.2.29]#
make install
echo $? 是0,证明没问题
[root@evan-01 httpd-2.2.29]# make install
...(过程略)
[root@evan-01 httpd-2.2.29]# echo $?
0
[root@evan-01 httpd-2.2.29]#
查看下,安装成功
[root@evan-01 httpd-2.2.29]# cd /usr/local/apache2.2/
[root@evan-01 apache2.2]# ls
bin build cgi-bin conf error htdocs icons include lib logs man manual modules
[root@evan-01 apache2.2]#