CentOS Apache安装还是比较常用的,于是我研究了一下CentOS Apache安装,在这里拿出来和大家分享一下,希望对大家有用。CentOS是一个开源软件贡献者和用户的社区。下面介绍CentOS Apache安装。
[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
[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来查看。
[root@localhost httpd-2.2.4]# make; make install
#如果没有错误的话,那么Apache就已经安装在/usr/local/apache2目录中了
[root@localhost httpd-2.2.4]# /usr/local/apache2/bin/apachectl start
[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安装成功了,恭喜您!
在编译的过程中遇到了,APR not found这一错误。解决方法如下:
#./configure --prefix……检查编辑环境时出现:
checking for APR... no
configure: error: APR not found . Please read the documentation
解决办法:
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
卸载已经安装的软件包
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 pcre-8.10]#./configure --prefix=/usr/local/pcre [root@xt pcre-8.10]#make && make install
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util/ \
--with-pcre=/usr/local/pcre
成功编译完成~
启动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。
[root@server ~]# cd /usr/local/apache/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
[root@server ~]# /usr/local/apache/bin/apachectl restart