ubuntu下编译安装apache

时间:2021-04-17 22:16:58
ubuntu下编译安装apache

官网http://httpd.apache.org/download.cgi下载apache源码包后

/*解包*/
gzip -d httpd-2_x_NN.tar.gz
tar -xf httpd-2_x_NN.tar /*编译并安装*/
cd httpd-2_x_NN
./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-dav --enable-mainer-mode --enable-rewrite
make make install

编译apache出现的问题:configure: error: APR not found . Please read the documentation

下载APR包并解包(http://archive.apache.org/dist/apr/)

./configure --prefix=/usr/local/apr
make
sudo make install

同理解决APR-util not found问题,上面同一连接下载APR-util包并解压

./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr
make sudo make install

 

pcre缺失问题,可直接通过源安装

apt-get install libpcre3-dev

也可以像上面那样编译安装,下载链接(http://sourceforge.net/projects/pcre/files/pcre/)

./configure --prefix=/usr/local/pcre
make
sudo make install

  

编译时若提示error: You need a C++ compiler for C++ support.说明系统没有C/C++编译环境,使用以下环境安装:

sudo apt-get install build-essential

  

编译apache出现make[2]: *** [exports.lo] 错误 1

将apr和apr-util源码复制到apache源码的srclib文件夹中,并分别以apr和apr-util命名,configure后面加上--with-included-apr,并重新make

//
./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-included-apr
//

  

重新configure编译有时候经常出现一些莫名其妙的报错,这时候可以尝试make clean清理原来的configure,重新编译

安装完成后,执行如下命令启动apache

sudo /usr/local/apache2/bin/apachectl start

浏览器访问127.0.0.1,页面显示 it works!

搞定