在Linux上编译安装apache
=============
在ubuntu上安装
=============
在linux上安装Apache,要首先确保以下程序事先安装
apr
apr-util
pcre
安装步骤如下:
1、安装apr
下载:http://apr.apache.org/download.cgi
tar -zxvf apr-1.4.6.tar.gz
cd apr-1.4.6
./configure --prefix=/usr/local/apr/
make
make install
2、安装apr-util
下载:http://apr.apache.org/download.cgi
tar -zxvf apr-util-1.4.1.tar.gz
cd apr-util-1.4.1
./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr/
make
make install
3、安装pcre
下载:http://sourceforge.net/projects/pcre
unzip -o pcre-8.10.zip
cd pcre-8.10
./configure --prefix=/usr/local/pcre
make
make install
4、安装apache
下载:http://httpd.apache.org/download.cgi
tar -zxvf httpd-2.4.2.tar.gz
cd httpd-2.4.2
./configure --prefix=/usr/local/apache2/ --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre
make
make install
5、配置
vi /usr/local/apache2/conf/httpd.conf
6、启动、关闭
cd /usr/local/apache2/bin
./apachectl -k start
./apachectl -k stop
./apachectl -k restart
如果配置文件中Listen定义的是默认的80端口(或1024以下),那么启动Apache将需要root权限以将它绑定在特权端口上。
=============
在redhat上安装
=============
在redhat上安装可能会在启动apache的时候报错
apache 安装好后 启动出错:
httpd: Syntax error on line 140 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/mod_dir.so into server: /usr/local/apache2/modules/mod_dir.so: undefined symbol: apr_array_clear
由于apache编译时没有指定 --with-included-apr
解决方法:
1、下载的apr和apr-utils源文件夹拷贝到httpd-2.4.2/srclib/, 再进行编译
#cp -rf apr-1.4.6 httpd-2.4.1/srclib/apr
#cp -rf apr-util-1.4.6 httpd-2.4.1/srclib/apr-util
2、在编译httpd时,加上--with-included-apr
./configure --prefix=/usr/local/apache2/ --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre --with-included-apr