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

CentOs5.4 64/32系统 ---源码安装apache2.2.23

2012-10-27 14:59 465 查看
注:命令前的#表示root用户,$表示普通用户

注:当前安装为64位系统,32位系统类似

注:因为不同的系统,设置或工具软件安装略有差别,安装过程可能会出现偶然错误,此时只要把错误百度一下,基本能解决。大致安装流程如下,本机测试ok!

 

Apache安装:

1、  下载、解压安装包:

httpd-2.2.23.tar.gz

下载地址:http://httpd.apache.org/download.cgi#apache24

# tar -zxvfhttpd-2.2.23.tar.gz

 

4000
apr-1.4.6.tar.gz

下载地址:http://apr.apache.org/download.cgi

# tar -zxvf apr-1.4.6.tar.gz

  

apr-util-1.5.1.tar.gz

下载地址:http://apr.apache.org/download.cgi

# tar -zxvf apr-util-1.5.1.tar.gz

 

pcre-8.31.tar.gz

下载地址:ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/

# tar -zxvf pcre-8.31.tar.gz

 

2、  安装apr:

进入解压目录:

# cd apr-1.4.6

执行:

# ./configure--prefix=/usr/local/apr

# make

# make install

 

3、  安装apr-util

进入解压目录:

# cd apr-util-1.5.1 

执行:

#./configure--prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config

# make

# make install

 

4、  安装pcre

进入解压目录:

# cd pcre-8.31

执行:

#./configure--prefix=/usr/local/pcre

# make

# make install

 

5、  安装apache

进入解压目录:

# cd httpd-2.2.23

执行:

#./configure --enable-so --enable-threads  --enable-cache --enable-rewrite=shared-enable-deflate=shared --enable-expires=shared --prefix=/usr/local/apache2--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/                

# make

# make install

 

6、  开机启动:

1.      # cp  /usr/local/apache2/bin/apachectl/etc/init.d/httpd

2.      # vi /etc/init.d/httpd

在在#!/bin/sh后面加入下面两行
# chkconfig:345 8515
# description:Start and stops the Apache HTTP Server

其中所增加的第二行中三个数字第一个表示在运行级别3和5下启动apache

 

然后
# chmod+x /etc/rc.d/init.d/httpd
# chkconfig--add httpd

# chkconfig--level 345 httpd on

# chkconfig--list httpd

常见FAQ:

1、访问错误

[Mon Oct 22 22:19:54 2012] [error] [client182.128.68.42] client denied by server configuration: /usr/local/www/index.html

[Mon Oct 22 22:19:54 2012] [error] [client 182.128.68.42]client denied by server configuration: /usr/local/www/favicon.ico

 

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    allow from all #去掉
</Directory>

 

<Files ~>

AllowOverride AuthConfigFileInfo Indexs Limit Options

Order allow ,deny

Deny from all #--------注意:就是这儿!!--->把这行去掉或注释掉就行!!!

</Files>


 

2、启动错误

Redhat  Linux 服务器,在重启后发现Apache启动失败,在Apache的日志文件中有如下的错误信息:

 

[Thu Aug 2704:20:44 2008] [alert] (22002)Name or service not known: mod_unique_id: unableto find IPv4 address of "localhost.zxlm.cn"

ConfigurationFailed!

 

查了一些资料后,发现在/etc/hosts中添加一行

 

127.0.0.1    localhost.zxlm.cn localhost

 

就可以正常启动Apache了。

 

随后发现Webalizer Logfile Analysis
生成的统计日志将默认的站点的URL写成了localhost.zxlm.cn

而localhost.zxlm.cn正是此Linux服务器的主机名,通过Webmin将Linux服务器的主要名改为www.zxlm.cn,而在本机的DNS中已经存在www.zxlm.cn的DNS记录所以Hosts文件都不需要修改了。只要把服务器的主机各设置对就行了。

 

 

修改Linux的主机名,其实是修改文件etc/sysconfig/network里的主机名.

NETWORKING=yes

HOSTNAME=主机名

 

1、 如果在安装apache的时候入到 error: mod_deflate has been requested but can not be built due toprerequisite failures的错误,那是没有安装zlib包。centos下可以采用yum install zlib-devel, ubuntu下可以采用apt-get install zlib1g-dev.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: