Ubuntu 下配置apache和APR

软件环境:ubuntu14.04  虚拟机Vmware  软件:http://httpd.apache.org/  httpd-2.2.29.tar.gz  不需要单独下载APR。

1.解压apache源码
# tar xvzf httpd-2.2.29.gz
# cd httpd-2.2.29
2.安装apr
# cd srclib/apr
# ./configure --prefix=/usr/local/apr //配置到指定目录
# make
# make install %需要再root模式下运行 前面加sudo
3.安装apr-util
# cd ../apr-util/
# ./configure --prefix=/usr/local/apr-util 
    --with-apr=/usr/local/apr
# make
# make install %需要root权限 前面加sudo
# cd ../../
4.安装apache

#./configure --prefix=/usr/local/apache2 --enable-modules=so --enable-mods-shared=all --enable-proxy --enable-proxy-connect --enable-proxy-ftp --enable-proxy-http --enable-proxy-ajp --enable-proxy-balancer --enable-rewrite--enable-status --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ 
%如果有错误
mod_deflate has been requested but can not be built due to prerequisite failures(ubuntu centent) 那是没有安装zlib包。centos下可以采用yum install zlib-devel, ubuntu下可以采用apt-get install zlib1g-dev.

# make
# make install 同上

5. 安装tomcat-native.tar.gz  //暂时没配
# cd /opt/tomcat/bin
# tar zxvf tomcat-native.tar.gz
# cd tomcat-native-src/jni/native
# ./configure --with-apr=/usr/local/apr

6. 添加环境变量

# vim /etc/profile
添加:export LD_LIBRARY_PATH=/usr/local/apr/lib

7. 启动与停止

启动:sudo /usr/local/apache2/bin/httpd -k start

启动时提示:

httpd: Could not determine the servers fully qualified domain name, using 127.0.0.1 for ServerName.
解决办法1是在http.conf中加一行:%%http.conf在/usr/local/apache2/conf/下
ServerName 127.0.0.1:80

或者2.找到#ServerName www.example.com:80   把#去掉,再重启apache即可没事了。

否则,只能在本地用127.0.0.1访问,不能使别的电脑访问网站

停止:sudo /usr/local/apache2/bin/httpd -k stop

 

 

上一篇:Java第六课--方法的语法,调用与重载


下一篇:Xamarin.Android开发实践(一)