1.使用xshell連接虛擬機(jī),也可直接在虛擬機(jī)中敲命令。
以下是xshell上的命令:
首先安裝HTTPD包
[root@one ~]# mount /dev/sr0 /mnt
[root@one ~]# yum install httpd
重啟服務(wù)查看狀態(tài):
[root@one ~]# systemctl restart httpd
[root@one ~]# systemctl status httpd

需要關(guān)閉防火墻
[root@one ~]# systemctl stop firewalld
查看firewalld 是否關(guān)閉
[root@one ~]# systemctl status firewalld

[root@one ~]# setenforce 0
(setenforce是Linux的selinux防火墻配置命令 執(zhí)行setenforce 0 表示關(guān)閉selinux防火墻)
[root@one ~]# getenforce
(查看selinux狀態(tài)的指令,有enforce、permissive分別是1和0設(shè)置)
Permissive
執(zhí)行命令復(fù)制一個(gè)文件:
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

刪除藍(lán)色的以#開頭的內(nèi)容
使用dd單行刪除,輸入10dd刪除10行
進(jìn)入插入模式(按i或o)
修改成如下(基于IP地址)在下面增加了幾行內(nèi)容。

下面的那個(gè)可以先不管
創(chuàng)建目錄: /www/161
[root@one conf.d]# mkdir -p /www/161
重啟服務(wù)(我等了好久)
[root@one conf.d]# systemctl restart httpd
如果有問題查看靜態(tài)(status) -l 顯示全部,然后一般都是配置文件haha.conf寫的有問題。
給網(wǎng)頁里寫入一些內(nèi)容:
[root@one ~]# echo this is sebastiane blog > /www/161/index.html
然后可以在網(wǎng)頁上輸入IP地址打開

不過這種方法還是無法通過http訪問上傳到虛擬里的文件
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。