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

注:命令前的#表示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

 

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

其中所增加的第二行中三个数字第一个表示在运行级别35下启动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服务器的主机名,通过WebminLinux服务器的主要名改为www.zxlm.cn,而在本机的DNS中已经存在www.zxlm.cnDNS记录所以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.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值