(三)apache安装
1.下载下载地址:http://mirror.bjtu.edu.cn/apache//httpd/httpd-2.2.21.tar.gz
卸载
查看是否系统已安装过apache
# rpm -qa|grep httpd
centOS5.4 默认自带apache卸载掉
# rpm -e httpd --nodeps
2.安装
解压
# tar -zxvf httpd-2.2.21.tar.gz
进入解压目录
# cd httpd-2.2.21
配置安装参数
./configure --prefix=/usr/local/apache --enable-so
编译
# make
安装
# make install
修改配置
# cd /usr/local/apache/conf/
# vi httpd.conf
修改并保存退出(:wq)
Listen 80改成Listen 192.168.8.12:80
测试:输入http://192.168.8.12 显示 It works!
解决局域其他机器网无法访问问题
方案1
/etc/init.d/iptables stop
#start 开启
#restart 重启
永久性关闭防火墙chkconfig –level 35 iptables off
方案2
修改vi /etc/sysconfig/iptables命令添加使防火墙开放80端口
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
3.注册为服务
拷贝apache启动脚本
# cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
编辑apache启动脚本
# vi /etc/init.d/httpd
修改并退出(:wq)
在#!/bin/sh下面加上
#chkconfig:345 85 15
#description:start and stops the apache http server.
添加到服务
# chkconfig --add httpd
测试 输入service httpd start/stop/restart
4.开机启动
命令加入到rc.local里面
echo /usr/local/apache/bin/apachectl >> /etc/rc.d/rc.local
页:
[1]