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

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

如下是xshell上的命令:linux

首先安装HTTPD包shell

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

[root@one ~]# systemctl restart httpdthis

[root@one ~]# systemctl status httpd
spa

须要关闭防火墙rest

[root@one ~]# systemctl stop firewalldhtm

查看firewalld 是否关闭blog

[root@one ~]# systemctl status firewalldget

 

[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服务,还有基于域名的基于端口的。都是在配置文件里面作的一些修改。

相关文章
相关标签/搜索