close
這裡的web server是使用Apache來架設 

先確定有實體IP:
例如:192.168.1.50

1.安裝所需套件:(若是裝系統時是全部安裝,那應該已經包含了所需套件)
    yum -y install httpd mysql-server php php-devel php-mysql
2.備份設定檔:
    cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bak
3.修改httpd.conf:
    vi /etc/httpd/conf/httpd.conf
-----------------------------------------
250行 ServerAdmin root@localhost
           系統管理員的 email ,當網站出現問題時,錯誤訊息顯示的聯絡信箱
264行 ServerName www.example.com:80
            設定主機名稱,如果沒有指定的話,預設會以你的 hostname 為依據。填入的這個主機名稱要找的到 IP
354行 UserDir disable 修改成--> #UserDir disable
361行 #UserDir public_html 修改成--> UserDir public_html
390行 DirectoryIndex index.html index.html.var 修改成--> DirectoryIndex index.html index.htm index.php
                                                                                                       index.html.var
730行 LanguagePriority en zh-TW ...... zh-CN
            設定顯示語系的優先順序
746行 AddDefaultCharset UTF-8
            有兩種作法,一種是『直接指定由 WWW 宣告 Big5 編碼,而不用網頁表頭的宣告』:
            AddDefaultCharset Big5   或 AddDefaultCharset  zh-TW
            另一種則是不要宣告預設語系,由網頁表頭宣告的啦!直接註解起來即可
            # AddDefaultCharset UTF-8
----------------------------------------
4.啟動服務:
   service httpd start (或/etc/rc.d/init.d/httpd start)
5.設定開機時就啟動:
   chkconfig httpd on
6.把index.html檔案放入/var/www/html/  (預設的首頁所在目錄) 裡面
7.當輸入『http://localhost』或『http://192.168.1.50』會顯示網頁那就表示成功了

ps:
* 如何架設自己的網頁:
     首先要在電腦裡有建立使用者(廢話)
     例如: astronomy是在192.168.1.50的其中一個使用者 且此電腦有開啟httpd服務(又是廢話) 並有修改如上方  
                  354.361行那樣
     請在自己的資料夾下建立一個public_html的資料夾 權限請改成 755
     另外/home/astronomy/  即個人資料夾權限請改成 711  否則無法讓 Apache 的程序瀏覽
     此處建立的public_html 與上方 httpd.conf檔案的設定有關 (361行)
     若是 UserDir public_html 是改為 UserDir www 那麼建立的資料夾改為www
     使用者個人網頁: http://192.168.1.50/~astronomy
記得把防火牆httpd的服務打開,SELinux請關閉 (httpd的port:80)
*有關更多的設定,請參考鳥哥網頁WWW Server篇 
    (webalizer 與 SSL 的設定似乎頗有趣,改天看了之後再補上)
 
參考資料:
(1)http://apt.nc.hcc.edu.tw/web/student_server_centos/student_server_centos.html
     學生用伺服器建置流程(CentOS 5 版)
(2)http://linux.vbird.org/   鳥哥的網頁   
     其中的WWW Server 部份   
(3)http://www.ichiayi.com/wiki/
(4)Apache HTTP Server 官方網站:http://httpd.apache.org/
arrow
arrow
    全站熱搜

    gtchen 發表在 痞客邦 留言(1) 人氣()