1. 下载apache:http://mirror.esocc.com/apache//httpd/httpd-2.4.6.tar.gz
2. 将下载的文件放到/usr/local/work(如果没有则用mkdir新建)。
3. 解压:tar zvxf httpd-2.3.6.tar.gz
4. 进入httpd目录httpd-2.3.6
5. ./configure -prefix=/usr/local/apache2-enable-module=so
6. 如果出现configure: error: APR not found.Please read the documentation.则表示还需要安装以下三个包:apr(http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz) , apr-util(http://archive.apache.org/dist/apr/apr-util-1.3.12.tar.gz),pcre(ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.33.tar.gz)
7. 安装apr包:
a. 解压apr包:tar -zvxf apr-1.4.5.tar.gz
b. cd apr-1.4.5
c. ./configure –prefix=/usr/local/apr(如果没有apr目录,最好mkdir创建)
d. make
e. make install
f. 如果apr下面有东西表示安装成功。注意,以上需要管理员权限
8. 安装apr-util包:
a. 解压apr-util包:tar –zvxf apr-util-.1.3.12.tar.gz
b. cd apr-util-.1.3.12
c. ./configure –prefix=/usr/local/apr-util(if nothe dir, mkdir to create) --with-apr=/usr/local/apr/bin/apr-1-config
d. make
e. make install
9. 安装pcre包:(出现该提示configure: error:pcre-config for libpcre not found. PCRE is required and available)
a. 解压apr-util包:tar –zvxf pcre-8.33.tar.gz
b. cd pcre-8.33
c. ./configure –prefix=/usr/local/pcre(if no thedir, mkdir to create) --with-apr=/usr/local/apr/bin/apr-1-config
d. make
e. make install
f. 在make的时候出现了缺少g++,sudo apt-get g++;
10. 最后安装httpd:
./configure –prefix=/usr/local/httpd –with-apr=/usr/local/apr/bin/apr-1-config –with-apr-util=/usr/local/apr-util/bin/apu-1-config–with-pcre=/usr/local/pcre/bin/pcre-config
11. 启动httpd:/usr/local/httpd/bin/apachetl -k start|stop|restart
12. 如果出现(98)Address already in use: AH00072:make_sock: could not bind to address 0.0.0.0:80.说明80端口被占用了。你可以通过netstat -ltnp查看已用的端口。然后在conf/httpd.conf 下找到listen80(默认端口)把80改成可用的端口。
13. 配置rc.local将apache的服务加入设置开机自启动:echo ‘/usr/local/httpd/bin/apachectl–k start’ >> /etc/rc.d/rc.local