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服務,還有基於域名的基於端口的。都是在配置文件裏面作的一些修改。

相關文章
相關標籤/搜索