CentOS   发布时间:2022-05-09  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了CentOS6.5下安装apache2.2大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

1.准备程序 :

httpd-2.2.27.tar.gz下载地址:http://httpd.apache.org/download.cgi#apache22

apr-1.5.1.tar.gz下载地址:http://apache.spd.co.il/apr/

apr-util-1.5.3.tar.gz下载地址:http://apache.spd.co.il/apr/

安装apr-1.5.1.tar.gz

1、Copy root文件夹

2、Cd /root

3、Tar –zxvf apr-1.5.1.tar.gz

4、Cd apr-1.5.1

5、./configure --with-apr=/usr/local/apr

提示:configure: error: no acceptable C compiler found in $PATH

解决:yum -y install gcc

6../configure --with-apr=/usr/local/apr

7.make

Make install

安装apr-util-1.5.3.tar.gz

1.copy上传apr-util-1.5.3.tar.gz文件

2.cd /root

3.cdapr-util-1.5.3

4.#./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

5.Make

6.Make install

安装httpd-2.2.27.tar.gz

1.copy apache

2.tar-zxvfhttpd-2.2.27.tar.gz

3.cdhttpd-2.2.27

4.#./configure --prefix=/usr/local/apache2--enable-module=so --enable-ssl=sharedSSL --enable-rewrite=shared --enable-proxy=shared --enable-deflate=shared --with-mpm=worker --enable-expires=shared --enable-speling=shared --enable-mods-shared=all --enable-module=most --enable-mods-shared=all --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util

5.提示错误:

6.checking whether to enable mod_deflate... configure: error: mod_deflate has been requested but can not be built due to prerequisite @R_46_4895@

7.原因:没装zlib-devel
安装方法:yum install gcc zlib-devel openssl-devel

8.Make

9.Make install

本例中apache安装在/usr/local/apache2,服务控制脚本为:

/usr/local/apache2/bin/apachectl

执行下面的命令启动Apache服务:

/usr/local/apache2/bin/apachectl start

执行下面的命令停止Apache服务:

/usr/local/apache2/bin/apachectl stop

可以简单地把Apache启动命令加到/etc/rc.local文件,让Apache随系统启动而自动启动:

echo"/usr/local/apache2/bin/apachectl start" >> /etc/rc.local

下面介绍如何把Apache加入到系统服务,用service命令来控制Apache的启动和停止。

首先以apachectl脚本为模板生成Apache服务控制脚本:

grep -v "#"/usr/local/apache2/bin/apachectl > /etc/init.d/apache

用vi编辑Apache服务控制脚本/etc/init.d/apache:

vi /etc/init.d/apache

在文件最前面插入下面的行,使其支持chkconfig命令:

#!/bin/sh

# chkconfig: 2345 85 15

# description: Apache is a World Wide Webserver.

保存后退出vi编辑器,执行下面的命令增加Apache服务控制脚本执行权限:

chmod +x /etc/init.d/apache

执行下面的命令将Apache服务加入到系统服务:

chkconfig --add apache

执行下面的命令检查Apache服务是否已经生效:

chkconfig --list apache

命令输出类似下面的结果:

apache0:off 1:off 2:on 3:on 4:on 5:on 6:off

表明apache服务已经生效,在2、3、4、5运行级别随系统启动而自动启动,以后可以使用service命令控制Apache的启动和停止。

启动Apache服务:

service apache start

  停止Apache服务:

service apache stop

  执行下面的命令关闭开机自启动:

chkconfig apache off

  执行下面的命令改变开机自启动的运行级别为3、5:

chkconfig --level 35 apache on

打开防火墙

vim /etc/sysconfig/iptables

添加端口

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

重启生效

service iptables restart重启

启动apache

./apachectl start

此时用户为daemon

若启动apachectl start

此时用户为apache

则修改监听端口无效

@H_489_160@

大佬总结

以上是大佬教程为你收集整理的CentOS6.5下安装apache2.2全部内容,希望文章能够帮你解决CentOS6.5下安装apache2.2所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: