2011年2月23日 星期三

【Centos架站應用】

在Centos底下架設Web Server:
Linux系統:Centos v5.x
網站伺服器程式:Apache
網頁語法支援:PHP
網頁資料庫支援:Mysql
網頁資料庫管理:phpMyadmin


【apache、php-step】
詳細說明:http://www.centospub.com/make/apache.html
  1. 安裝apache
    yum -y install httpd

  2. 安裝php
    yum -y install php

  3. 設定apache-httpd.conf
    vi /etc/httpd/conf/httpd.conf

    #ServerTokens OS  //出現錯誤頁面時,不顯示伺服器操作系統的名稱
    ServerTokens Prod

    #ServerSignature On  //在錯誤頁面中,不顯示 Apache 的版本
    ServerSignature Off

    #ServerAdmin root@localhost //設定管理員信箱
    ServerAdmin andraw@abc.com.tw

    #ServerName www.example.com:80  //修改網域名稱
    ServerName 192.168.0.101:80

    #AllowOverride None  //設定是否允許 .htaccess
    AllowOverride All

    <Directory "/var/www/icons">
    #   Options Indexes MultiViews  //不在瀏覽器上顯示樹狀目錄結構
    Options MultiViews

    #Options Indexes FollowSymLinks  //原始設定
    #Options Includes FollowSymLinks  //允許伺服器執行SSI
    Options Includes FollowSymLinks

    #NameVirtualHost *:80
    NameVirtualHost *:80 //設定多重網域

    #<VirtualHost *:80> //設定多重網域
    #    ServerAdmin webmaster@dummy-host.example.com
    #    DocumentRoot /www/docs/dummy-host.example.com
    #    ServerName dummy-host.example.com
    #    ErrorLog logs/dummy-host.example.com-error_log
    #    CustomLog logs/dummy-host.example.com-access_log common
    #</VirtualHost>

    <VirtualHost  *:80>
    Documentroot /var/www/a1.com.tw
    ServerName a1.com.tw
    ErrorLog logs/a1.com.tw-error_log
    CustomLog logs/a1.com.tw-access_log common
    </VirtualHost>


    <VirtualHost  *:80>
    Documentroot /var/www/a2.com.tw
    ServerName a2.com.tw
    ErrorLog logs/a2.com.tw-error_log
    CustomLog logs/a2.com.tw-access_log common
    </VirtualHost>


  4. 設定開機自動啟動 httpd
    chkconfig httpd on
    **檢查開機自動啟動的項目  chkconfig --list httpd


  5. 手動開啟 httpd
    /etc/init.d/httpd start

  6. 開啟防火牆
    vi /etc/sysconfig/iptables
    # apache-httpd-port-80
    -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
    /etc/init.d/iptables restart

注意事項:
  • 歡迎畫面:/etc/httpd/conf.d/welcome.conf
  • 錯誤畫面:/網頁路徑/error/noindex.html

沒有留言: