Ubuntu12.04下安装apache2.4过程(源代码编译安装方式)
首先需要下载apache源代码及相关软件,下载地址分别是:
apache:http://httpd.apache.org/download.cgi
apr/apr-util:http://apr.apache.org/download.cgi
pcre:http://ftp.exim.llorien.org/pcre/
apache不用说了,apr/apr-util/pcre都是安装apache所必须的软件。
首先编译安装apache
[root@localhost apache]# tar jxvf httpd-2.4.1.tar.bz2 //解压apache的压缩包
[root@localhost apache]# cd httpd-2.4.1 //定位到httpd-2.4.1 文件夹下
[root@localhost httpd-2.4.1]# ls //查看显示httpd-2.4.1 文件夹下内容
[root@localhost httpd-2.4.1]#./configure --help | more //查看安装apache配置参数
[root@localhost httpd-2.4.1]#./configure --prefix=/usr/local/apache --enable-so // 配置apache路径 ,后面跟 --enable-so 参数表示让apache核心装载DSO
[root@localhost httpd-2.4.1]# make //编译apache
到了这里会报错
configure: error: APR not found. Please read the documentation
此时,安装下载的apr
[root@localhost apache]# tar -zxf apr-1.4.6.tar.gz
[root@localhost apache]# cd apr-1.4.6
[root@localhost apr-1.4.6]# ./configure --prefix=/usr/local/apr
[root@localhost apr-1.4.6]# make
[root@localhost apr-1.4.6]# make install
重新编译apache,又报错
configure: error: APR-util not found. Please read the documentation
要安装下载的apr-util
[root@localhost apache]# tar -zxf apr-util-1.4.1.tar.gz
[root@localhost apache]# cd apr-util-1.4.1
[root@localhost apr-util-1.4.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
[root@localhost apr-util-1.4.1]# make
[root@localhost apr-util-1.4.1]# make install
如果此时编译apache会报错
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
嘿嘿,安装pcre吧,这里必须安装C++编译环境(ubuntu 下是g++)
[root@localhost apache]# apt-get install g++
安装后安装pcre
[root@localhost apache]#unzip -o pcre-8.30.zip
[root@localhost apache]#cd pcre-8.30
[root@localhost pcre-8.30]#./configure --prefix=/usr/local/pcre
[root@localhost pcre-8.30]#make
[root@localhost pcre-8.30]#make install
此时就可以安心的安装apache了,cd到apache源代码目录,运行
[root@yahoo httpd-2.3.12-beta]# ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre
后面的参数不可少,且一定要是前面安装相关软件的路径
[root@localhost httpd-2.4.1]# make
[root@localhost httpd-2.4.1]# make install
ok,apache安装完成。。
到这里完了吗?没有,需要配置apache,最简单的配置:
[root@localhost httpd-2.4.1]# vim ../conf/httpd.conf
修改 #ServerName xxxxxxxx 为 ServerName localhost
兄弟,可以收工了^_^#.
独立博客:http://www.120313.com