一、CentOS6中简单的web站点的配置实例:

1.安装httpd:

~]# yum install -y httpd httpd-manual httpd-tools //安装httpd应用程序所需要的必要文档文件

centos下验证网页 centos配置网站_linux配置


2.确保SElinux和iptables防火墙不会干扰httpd服务的提供:

SElinux配置:

~]# getenforce //查看SELinux状态
Enforcing
~]# setenforce 0 //设置SELinux为

centos下验证网页 centos配置网站_运维_02


防火墙:

~]# iptables -vnL //查看主机是否防火墙状态

其执行结果中如果有防火墙规则如图:

centos下验证网页 centos配置网站_运维_03


,就需要进行如下处理:

~]# service iptables stop //停止防火墙服务,仅限于实验环境关闭

~]# chkconfig iptables off //设置防火墙服务开机自启关闭

~]# iptables -F //清除所有规则来暂时停止防火墙 (只适合在没有配置防火墙的环境中,如果已经配置过默认规则为deny的环境,此步骤将使系统的所有网络访问中断)

centos下验证网页 centos配置网站_IP_04


3.添加一个html文档:/var/www/html/index.html

centos下验证网页 centos配置网站_linux配置_05


4.启动httpd服务

~]# service httpd start

centos下验证网页 centos配置网站_html_06


5.监测服务启动是否正常:

~]# ss -tnl | grep httpd //监听端口号,查看httpd服务是否开启,一般默认是80

~]# ps aux | grep httpd //查看进程是否有httpd进程启用

~]# service httpd status //查看httpd服务的状态

centos下验证网页 centos配置网站_IP_07


6.设置httpd服务开机自动启动:

~]# chkconfig httpd on

7.在本地客户端主机访问创建好的IP地址就可以了:

centos下验证网页 centos配置网站_IP_08

二、CentOS7中简单的web站点的配置实例:

1.安装httpd:

~]# yum install -y httpd httpd-manual httpd-tools

centos下验证网页 centos配置网站_IP_09


2.确保SElinux和iptables防火墙不会干扰httpd服务的提供:

SElinux配置:

~]# getenforce

Enforcing

~]# setenforce 0

centos下验证网页 centos配置网站_运维_10


防火墙:

~]# iptables -vnL

其执行结果中如果有防火墙规则如下图:

centos下验证网页 centos配置网站_运维_11


,需要进行如下处理:

~]# systemctl disable firewalld.service //停止防火墙

~]# systemctl stop firewalld.service //禁用防火墙

~]# iptables -F 清除所有规则来暂时停止防火墙 (只适合在没有配置防火墙的环境中,如果已经配置过默认规则为deny的环境,此步骤将使系统的所有网络访问中断)

centos下验证网页 centos配置网站_html_12


3.添加一个html文档:/var/www/html/index.html

centos下验证网页 centos配置网站_linux配置_13


4.启动httpd服务:

~]# systemctl start httpd

5.监测服务启动是否正常:

~]# ss -tnl | grep httpd

~]# ps aux | grep httpd

~]# systemctl status httpd.service

centos下验证网页 centos配置网站_运维_14


6.设置httpd服务开机自动启动:

~]# systemctl enable httpd.service

centos下验证网页 centos配置网站_html_15


7.在本地客户端主机访问创建好的IP地址就可以了:

centos下验证网页 centos配置网站_html_16


https://blog.51cto.com/chenliangdeeper/2108738