部署服务的步骤(以appach为例)
1.准备环境
(1)关闭防火墙
centos7
查看防火墙状态:firewall-cmd --state
停止firewall: systemctl stop firewalld.service
禁止firewall开机启动: systemctl disable firewalld.service
下面是centos7以下的:
临时关闭,重启会再次启动:service iptables stop
设置开机就关闭防火墙chkconfig iptables off
(2)关闭SELINUX(注意需要重启)
临时关闭,重启会再次启动:setenforce 0
设置开机就关闭防火墙:vim /etc/sysconfig/selinux将其中的SELINUX=enforcing改成SELINUX=disabled
(3)配置ip地址
2.安装软件包
yum install httpd -y
rpm -qa | grep httpd
3.修改配置文件
vim /etc/httpd/conf/httpd.conf
注意配置文件的两个配置项:
默认监听端口号【 Listen:80 】
默认文档根目录:【 DocumentRoot /var/www/html/ 】
4.重启服务
service httpd restart
5.测试
echo “你好” >> /var/www/html/index.html
echo “你好” >> /var/www/html/hello.html
在客户端的/etc/hosts文件中,加上:服务端ip www.ybp.com
然后在客户端浏览器输入:http://www.ybp.com/hello.html可以访问hello.html文件,如果直接写http://www.ybp.com/hello.html是访问默认的/var/www/html/index.html