1.使用xshell連接虛擬機,也可直接在虛擬機中敲命令。
以下是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
![](/d/20211016/3bf4d599c2293ea9278e991875bdbe27.gif)
需要關(guān)閉防火墻
[root@one ~]# systemctl stop firewalld
查看firewalld 是否關(guān)閉
[root@one ~]# systemctl status firewalld
![](/d/20211016/9c48ea2ae1c2ce52ce1b16ad03f76d54.gif)
[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ù)制一個文件:
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
![](/d/20211016/93fb3bbc99a289b965a923651ab42155.gif)
刪除藍色的以#開頭的內(nèi)容
使用dd單行刪除,輸入10dd刪除10行
進入插入模式(按i或o)
修改成如下(基于IP地址)在下面增加了幾行內(nèi)容。
![](/d/20211016/50352b73300a73f1a934969599871796.gif)
下面的那個可以先不管
創(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地址打開
![](/d/20211016/c38c642a9d88a9e35a2d46c4fbc8db27.gif)
不過這種方法還是無法通過http訪問上傳到虛擬里的文件
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。