http基本配置
阿新 • • 發佈:2021-08-17
1.要求搭建web伺服器,能夠訪問到網頁內容為“小胖,你咋這麼胖呢!”
在圖形化介面,更改手動模式,新增IP地址
下一步
[root@localhost ~]# rpm -qa | grep httpd #檢視是否有http的包
[root@localhost ~]# yum install httpd #如果沒有http的包,則需先下載http [root@localhost ~]# systemctl stop firewalld #關閉防火牆 [root@localhost ~]# setenforce 0 #臨時關閉seLinux [root@localhost~]# systemctl start httpd #啟動http伺服器 [root@localhost ~]# vim /etc/httpd/conf.d/vhost.conf #更改配置資訊
[root@localhost ~]# systemctl restart httpd [root@localhost ~]# mkdir /130 /131 [root@localhost ~]# echo "小胖。你咋這麼胖呢!" > /130/index.html [root@localhost ~]# cat /130/index.html 小胖。你咋這麼胖呢!
2.要求搭建web伺服器,建立基於域名的虛擬主機,能夠使用www.xiaopang.com和www.daqiang.com訪問各自的網站網站存放路徑分別為/xiaopang和/daqiang,內容自定。
[root@localhost ~]# rpm -qa | grep httpd #檢視是否有http的包 [root@localhost ~]# yum install httpd #如果沒有http的包,則需先下載http [root@localhost ~]# systemctl stop firewalld #關閉防火牆 [root@localhost ~]# setenforce 0 #臨時關閉seLinux [root@localhost ~]# systemctl start httpd #啟動http伺服器 [root@localhost~]# vim /etc/httpd/conf.d/vhost.conf #更改配置資訊
yum包安裝如下: [root@localhost ~]# vim /etc/yum.repos.d/suibian.repo [root@localhost ~]# mount /dev/sr0 /mnt [root@localhost ~]# yum install httpd -y [root@localhost ~]# yum install httpd
更改配置資訊
<virtualhost 192.168.126.130:80> DocumentRoot /xiaopang ServerName www.xiaopang.com </virtualhost> <Directory /xiaopang> AllowOverride none Require all granted </Directory> <virtualhost 192.168.126.131:80> DocumentRoot /daqang ServerName www.daqang.com </virtualhost> <Directory /daqang> AllowOverride none Require all granted </Directory> ~ ~ :wq 儲存退出
下一步
[root@localhost ~]# systemctl restart httpd [root@localhost ~]# vim /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.126.130 www.xiaopang.com 192.168.126.131 www.daqang.com ~ :wq 儲存退出
下一步
在windows下,手動修改host檔案
下一步
[root@localhost conf.d]# echo "小明同學,你好" > /xiaopang/index.hml [root@localhost conf.d]# echo "小紅同好,你好" > /daqang/index.html [root@localhost conf.d]# cat /xiaopang/index.html 小明同好,你好 [root@localhost conf.d]# cat /daqang/index.html 小紅同好,你好 [root@localhost conf.d]# curl http://www.xiaopang.com 小明同好,你好 [root@localhost conf.d]# curl http://www.daqang.com 小紅同好,你好
最後在瀏覽器中輸入網址