一、描述
CentOS安装Apache服务可以有两种方式,一种是用yum安装,一种是从官网下载源代码进行安装。
二、使用yum安装Apache服务
步骤1:在命令行输入如下语句可以使用yum在线更新方式进行安装:
[tong@tong /]$ sudo yum install httpd -y
注意:采用该方式进行安装配置文件的默认路径为:/etc/httpd/conf/httpd.conf
步骤二:配置防火墙,添加下面红色字体的一行,表示开启80端口供客户浏览。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
[tong
@tong
/]$ sudo vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport
22
-j ACCEPT
# Firewall configuration written by system-config-firewall
# Manual customization of
this
file is not recommended.
*filter
:INPUT ACCEPT [
0
:
]
:FORWARD ACCEPT [
]
:OUTPUT ACCEPT [
]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-j ACCEPT
80
-j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
|
步骤三:配置完防火墙之后需要重新启动防火墙