HTTP (Hyper Text Transfer Protocol,超文件傳輸協定)是屬於OSI第七層的協定;簡言之,當使用者輸入HTTP://(IP Address)或HTTP://(Hostname)時,就能夠看到一個簡易的網頁 (首頁 / WebPage / HomePage)。
首先,我們先讓HTTP Server啟動 (在這裡我們假設使用者已經安裝了相關套件):
service httpd start

我們可以查詢一下本機的IP Address和Hostname:
ifconfig
hostname -f; hostname -i

接著開啟瀏灠器 (Browser),我們輸入以上得到的三個位址:
HTTP://192.168.1.4/
或
HTTP://rhel6.server.net/
或
HTTP://127.0.0.1/
都可以看到以下的畫面,表示httpd有被正常執行。

當然在實際的應用上,我們當然不會用這預設首頁,我們會放上自己編輯的網頁;那麼,我們的網頁相關檔案應該放在那裡??
在/var/www/html/下,我們新增一個首頁:
touch index.html
然後用文字編輯器 (vi, vim, gedit)去編輯它:

編輯完之後,記得存檔;然後重新啟動HTTP Server
service httpd restart

最後,我們重新Refresh剛剛輸入的三個網址:

剛剛我們編輯的網頁效果也確實呈現了!!
假如使用者不想每次開機都還要手動啟動伺服器,希望系統開機時就能夠自動執行,請輸入以下指令:
chkconfig httpd on
沒有留言:
張貼留言