CentOS 6.5下Apache 安装

centos 6.5下apache 安装过程。

1.下载apache  www.apache.org 找到相应的地址复制后 weget即可,也可以用下面这个

wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.23.tar.gz

tar -xf httpd-2.4.23.tar.gz

./configure

–prefix=/application/apache2.4.23

–enable-deflate

–enable-expires

–enable-header

–enable-modules=most

–enable-rewrite

–enable-so

–with-mpm=worker

解释一下上面的参数:

–prefix 安装路径

–enable-modules=most 使用大部分常用模块

–enable-rewrite 重写模块

–with-mpm=work 运行方式为一个主进程若干个子线程,还可以配置为进程,配置为进程的优点是更稳定,但是同时也更慢,更耗费cpu资源,当前主流都是把apache作为静态服务器使用所以使用work就可以了。如果你要和php等程序做配合可以设置为进程方式工作。

2.进行到这一步的时候出现了错误提示找不到apr,逐回到apache.org下载 apr和apr-util

wget http://mirrors.cnnic.cn/apache/apr/apr-1.5.2.tar.gz

./configure –prefix=/application/apr

make

make install

wget http://mirrors.cnnic.cn/apache/apr/apr-util-1.5.4.tar.gz

./configure –prefix=/application/apr-util –with-apr=/application/apr

make

make install

3.重新安装apache,进入apache解压缩目录

./configure

–prefix=/application/apache2.4.23

–enable-deflate

–enable-expires

–enable-header

–enable-modules=most

–enable-rewrite

–enable-so

–with-mpm=worker

–with-apr=/application/apr –with-apr-util=/application/apr-util

4.继续报错

checking whether to enable mod_deflate… configure: error: mod_deflate has been requested but can not be built due to prerequisite failures

这是因为没有安装zlib包,逐 yum 安装之

yum install zlib-devel

5.ok 装好后继续 make apache 这次没有问题了 继续 make install 至此安装完毕

6.修改/application/apache2.4.23/conf/httpd.conf

找到#ServerName

去掉# 更改为:

ServerName localhost:80

7.启动apache

/application/apache2.4.23/bin/httpd -k start

8.测试一下

curl 本机ip 如果 返回 it works 证明apache已经可以正常运行了

原创文章,作者:晴川运维,如若转载,请注明出处:https://baike.qcidc.com/11641.html

(0)
晴川运维晴川运维
上一篇 2025年7月5日
下一篇 2025年7月5日

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注