VMware虚拟机上建立HTTP服务步骤

1.使用xshell连接虚拟机,也可直接在虚拟机中敲命令。

以下是xshell上的命令:

首先安装HTTPD包

[root@one ~]# mount /dev/sr0 /mnt
[root@one ~]# yum install httpd
重启服务查看状态:

[root@one ~]# systemctl restart httpd

[root@one ~]# systemctl status httpd

需要关闭防火墙

[root@one ~]# systemctl stop firewalld

查看firewalld 是否关闭

[root@one ~]# systemctl status firewalld

 

[root@one ~]# setenforce 0

(setenforce是Linux的selinux防火墙配置命令 执行setenforce 0 表示关闭selinux防火墙)


[root@one ~]# getenforce

(查看selinux状态的指令,有enforce、permissive分别是1和0设置)
Permissive

 

执行命令复制一个文件:

cp  /usr/share/doc/httpd-2.4.6/httpd-vhosts.conf  /etc/httpd/conf.d/

 

改名为haha.conf

mv  httpd-vhosts.conf  haha.conf

编辑此文件

vim haha.conf

删除蓝色的以#开头的内容

使用dd单行删除,输入10dd删除10行

进入插入模式(按i或o)

修改成如下(基于IP地址)在下面增加了几行内容。

 

下面的那个可以先不管

创建目录: /www/161

[root@one conf.d]# mkdir -p /www/161

重启服务(我等了好久)

[root@one conf.d]# systemctl restart httpd

如果有问题查看静态(status) -l 显示全部,然后一般都是配置文件haha.conf写的有问题。

 

给网页里写入一些内容:

[root@one ~]# echo this is sebastiane blog > /www/161/index.html

 

然后可以在网页上输入IP地址打开

就能看到写入的内容,说明已经成功。

本次仅是基于IP地址的http服务,还有基于域名的基于端口的。都是在配置文件里面做的一些修改。

 

posted @ 2017-11-05 13:29  Sebastiane  阅读(4236)  评论(0编辑  收藏  举报