您的位置:首页 > 运维架构 > Apache

CentOS Apache编译安装及APR not found错误排除

2015-07-07 10:44 441 查看

【今日推荐】:为什么一到面试就懵逼!>>>

(1)CentOS Apache安装设置编译器及编译参数

CentOS Apache安装还是比较常用的,于是我研究了一下CentOS Apache安装,在这里拿出来和大家分享一下,希望对大家有用。CentOS是一个开源软件贡献者和用户的社区。下面介绍CentOS Apache安装。

1.下载:apache2.2.4

[root@localhost ~]# cd /usr/local/src/
[root@localhost src]#  wget
http://archive.apache.org/dist/httpd/httpd-2.2.4.tar.gz
[root@localhost src]# chmod +x httpd-2.2.4.tar.gz
[root@localhost src]# tar -zxvf httpd-2.2.4.tar.gz

2.CentOS Apache安装设置编译器的编译参数

[root@localhost src]# cd httpd-2.2.4
[root@localhost httpd-2.2.4]# ./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite=share --enable-proxy=share --enable-proxy-ajp=share --enable-dav=share --enable-dav-fs
#注解:
--prefix=/usr/local/apache2 
设置CentOS Apache安装目录。这里设定安装在/usr/local/apache2下,今后如果要卸载或者升级CentOS Apache时,直接删除这个目录即可。
--enable-so 
指定允许DSO(动态共享对像)
--enable-rewrite=share 
开启Rewrite支持,以实现URL静态化,建议开启。
--enable-dav-fs
开启WebDAV支持,svn服务器等需要。附:《什么是webDAV?及如何应用?》
其它的额外设置请使用./configure --help来查看。

3.CentOS Apache安装和编译

[root@localhost httpd-2.2.4]# make; make install
#如果没有错误的话,那么Apache就已经安装在/usr/local/apache2目录中了

4.启动服务

[root@localhost httpd-2.2.4]# /usr/local/apache2/bin/apachectl start

5.确定启动状

[root@localhost apache2]# netstat -utl

Active Internet connections (only servers)
Proto    Recv-Q    Send-Q    Local Address    Foreign Address    State
tcp    0    0    *:http    *:*    LISTEN
#看到上面这行就表示你的CentOS Apache已经启动。
#用浏览器访问,看到It works!,说明CentOS Apache安装成功了,恭喜您!

(2)解决编译Apache出现的问题:configure: error: APR not found

在编译的过程中遇到了,APR not found这一错误。解决方法如下:

#./configure --prefix……检查编辑环境时出现:

checking for APR... no
configure: error: APR not found .  Please read the documentation

解决办法:

1.下载所需软件包:

wget http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz  
wget http://archive.apache.org/dist/apr/apr-util-1.3.12.tar.gz 
wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.10/pcre-8.10.zip   

2.编译安装:

卸载已经安装的软件包

yum remove apr-util-devel apr apr-util-mysql apr-docs apr-devel apr-util apr-util-docs 

重新编译安装,具体步骤如下:

  a:解决apr not found问题>>>>>>

[root@xt test]# tar -zxf apr-1.4.5.tar.gz 
[root@xt test]# cd  apr-1.4.5   
[root@xt apr-1.4.5]# ./configure --prefix=/usr/local/apr 
[root@xt apr-1.4.5]# make && make install  

  b:解决APR-util not found问题>>>>

[root@xt test]# tar -zxf apr-util-1.3.12.tar.gz

[root@xt test]# cd apr-util-1.3.12   

[root@xt apr-util-1.3.12]# ./configure --prefix=/usr/local/apr-util

>-with-apr=/usr/local/apr/bin/apr-1-config

[root@xt apr-util-1.3.12]# make && make install 


  c:解决pcre问题>>>>>>>>>

[root@xt test]#unzip -o pcre-8.10.zip 
[root@xt test]#cd pcre-8.10

[root@xt pcre-8.10]#./configure --prefix=/usr/local/pcre   [root@xt pcre-8.10]#make && make install 

3.最后编译Apache时加上:

--with-apr=/usr/local/apr \

--with-apr-util=/usr/local/apr-util/ \

 --with-pcre=/usr/local/pcre

成功编译完成~

(3)Apache启动时,显示Could not reliably determine the server's fully qualified domain name

启动apache遇到错误:httpd: Could not reliably determine the server's fully qualified domain name
[root@server httpd-2.2.4]# /usr/local/apache/bin/apachectl start
 
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

错误提示很明显,就是无法确定server's fully qualified domain name,即ServerName。

1.进入apache的安装目录

[root@server ~]# cd /usr/local/apache/conf
 

2.编辑httpd.conf文件

搜索"#ServerName",添加ServerName localhost:80
[root@server conf]# ls
extra  httpd.conf  magic  mime.types  original
[root@server conf]# vim httpd.conf

查找到#ServerName所在位置
#ServerName www.example.com:80
ServerName localhost:80

3.再重新启动apache 即可。

[root@server ~]# /usr/local/apache/bin/apachectl restart

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: