直接介绍如何做:
我们可以下载源代码,也可以下载已经编译好的二进制文件。我下面使用源代码编译出Apache
下载源程序的网站:http://mirror.bit.edu.cn/apache/httpd/
也可以使用wget获得源程序的压缩包:
[]$wget http://mirror.bit.edu.cn/apache/httpd/httpd-2.4.3.tar.bz2
[]$tar -xjf httpd-2.4.3.tar.bz2
切换到解压目录;
[]$cd httpd-2.4.3/
配置安装目录;
[]$./configure --prefix=/home/user/soft/apache
执行配置之后,我遇到如下错误:
checking for APR... no configure: error: APR not found. Please read the documentation.
错误的原因是没有安装APR,所以下载APR (Apache Portable Runtime)并安装;
[]$ cd .. []$ wget http://www.fayea.com/apache-mirror//apr/apr-1.4.6.tar.bz2 []$ tar -xjf apr-1.4.6.tar.bz2 []$ cd apr-1.4.6/ []$ ./configure --prefix=/home/user/soft/apr []$ make []$ make install
[]$ cd ../httpd-2.4.3/ []$ ./configure --prefix=/home/user/soft/apache --with-apr=/home/user/soft/apr
继续遇到错误;
checking for APR-util... no configure: error: APR-util not found. Please read the documentation.
[]$ cd .. []$ wget http://www.fayea.com/apache-mirror//apr/apr-util-1.5.1.tar.bz2 []$ tar -xjf apr-util-1.5.1.tar.bz2 []$ cd apr-util-1.5.1/ []$ ./configure --prefix=/home/user/soft/apr-util --with-apr=/home/user/soft/apr []$ make []$ make install
[]$ cd ../httpd-2.4.3/ []$ ./configure --prefix=/home/user/soft/apache --with-apr=/home/user/soft/apr --with-apr-util=/home/user/soft/apr-util
checking for pcre-config... false configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
[]$ cd .. []$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.21.tar.bz2 []$ tar -xjf pcre-8.21.tar.bz2 []$ cd pcre-8.21/ []$ ./configure --prefix=/home/user/soft/pcre []$ make []$ make install
安装完成之后继续执行Apache的配置;
[]$ cd ../httpd-2.4.3/ []$ ./configure --prefix=/home/user/soft/apache --with-apr=/home/user/soft/apr --with-apr-util=/home/user/soft/apr-util --with-pcre=/home/user/soft/pcre []$ make []$ make install
这里以非ROOT用户启动APACHE,所以对某些配置做下改动
然后切换到apache的bin子目录下,执行以下命令即可:
./apachectl -k start
打开浏览器输入自己的IP即可,然后你会看到显示了一个It works的页面。
O了