一、首先我们装上编译安装的工具包
[root@CentOS6 ~]# yum -y install gccgcc-c++
[root@CentOS6 ~]# yum -y install make
去apache官网下载httpd最新的版本是httpd-2.4.10
安装时我们可以去参考文档http://httpd.apache.org/docs/2.4/
官网给的安装很简单 Overview for the impatient
Download
$ lynx http://httpd.apache.org/download.cgi
Extract
$ gzip -d httpd-NN.tar.gz
$ tar xvf httpd-NN.tar
$ cd httpd-NN
Configure
$ ./configure --prefix=PREFIX
Compile
$ make
Install
$ make install
Customize
$ vi PREFIX/conf/httpd.conf
Test
$ PREFIX/bin/apachectl -k start
NN mustbe replaced with the current version number, and PREFIX must be replaced with the filesystempath under which the server should be installed. If PREFIX is not specified, it defaults to /usr/local/apache2.
Eachsection of the compilation and installation process is described in more detailbelow, beginning with the requirements for compiling and installing Apachehttpd.
这是官网的原话
所以往下看 Requirements
The followingrequirements exist for building Apache httpd: APR and APR-Util
Make sure youhave APR and APR-Util already installed on your system. If you don't, or preferto not use the system-provided versions, download the latest versions of bothAPR and APR-Util from Apache APR, unpack them into ./srclib/apr and ./srclib/apr-util (be surethe directory names do not have version numbers; for example, the APRdistribution must be under ./srclib/apr/) and use ./configure's --with-included-apr option. Onsome platforms, you may have to install the corresponding -dev packagesto allow httpd to build against your installed copy of APR and APR-Util. Perl-CompatibleRegular Expressions Library (PCRE)
This library isrequired but not longer bundled with httpd. Download the source code from http://www.pcre.org,or install a Port or Package. If your build system can't find the pcre-configscript installed by the PCRE build, point to it using the --with-pcre parameter.On some platforms, you may have to install the corresponding -dev package toallow httpd to build against your installed copy of PCRE. Disk Space
Make sure youhave at least 50 MB of temporary free disk space available. After installationthe server occupies approximately 10 MB of disk space. The actual disk spacerequirements will vary considerably based on your chosen configuration options,any third-party modules, and, of course, the size of the web site or sites thatyou have on the server. ANSI-C Compilerand Build System
Make sure youhave an ANSI-C compiler installed. The GNU C compiler (GCC) from the Free Software Foundation(FSF) is recommended. If you don't have GCC then at least makesure your vendor's compiler is ANSI compliant. In addition, your PATH mustcontain basic build tools such as make. Accurate timekeeping
Elements of theHTTP protocol are expressed as the time of day. So, it's time to investigatesetting some time synchronization facility on your system. Usually thentpdate or xntpd programsare used for this purpose which are based on the Network Time Protocol (NTP).See the NTPhomepage for more details about NTP software and public timeservers. Perl 5 [OPTIONAL]
For some of thesupport scripts like apxs or dbmmanage (which are written in Perl) thePerl 5 interpreter is required (versions 5.003 or newer are sufficient). If youhave multiple Perl interpreters (for example, a systemwide install of Perl 4,and your own install of Perl 5), you are advised to use the --with-perl option(see below) to make sure the correct one is used by configure. If no Perl 5 interpreter is found bythe configure script, you will not be able touse the affected support scripts. Of course, you will still be able to buildand use Apache httpd.
因此我们一步步来,
Make sure you have APR and APR-Util already installed onyour system
This library is required but not longer bundled withhttpd
这个库必须安装因为他不再和httpd捆绑安装了
[root@CentOS6 src]#yum-y install pcre-devel 五、Disk Space
Make sure you have at least 50 MB of temporary free diskspace available.
确保你至少有50M可用空间
六、ANSI-C Compiler and Build System
安装基本的库上面已经安装过了
七、Accurate time keeping
保证系统时间正确 八、Perl5 [OPTIONAL]
Per5可选,我们暂时不安装
九、安装apache
次过程我们会遇到configure: WARNING:OpenSSL version is too old
因此
[root@CentOS6 src]# yum install openssl-devel
[root@CentOS6 src]#tar xvf httpd-2.4.10.tar.gz
[root@CentOS6 src]#cd httpd-2.4.10
启动的话,可以
[root@CentOS6 httpd-2.4.10] cd /usr/local/apache/bin
AH00557: httpd:apr_sockaddr_info_get() failed for CentOS6.4.hby.com
AH00558: httpd:Could not reliably determine the server's fully qualified domain name, using127.0.0.1. Set the 'ServerName' directive globally
[root@CentOS6 httpd-2.4.10]vim /etc/httpd/httpd.conf
修改ServerName
ServerName192.168.66.100我改成了我的IP
为了方便在网上找一个httpd的启动脚本这个我就不在写了
十、增加环境变量
[root@CentOS6init.d]# vim /etc/profile.d/httpd.sh
exportPATH=$PATH:/usr/local/apache/bin