關於 PHP, Linux, Open Source 及個人生活記載的網誌。
RSS icon
  • PHP 檢查 apache module 是否啟動

    Posted on July 22nd, 2009 Sam Tang No comments

    如果要用 PHP 檢查 apache 的 module 是否已啟動,可以用以下方法實現:

    PHP:
    1. <?php
    2. function module_enabled($module){
    3.     $modules = apache_get_modules();
    4.     return in_array($module, $modules);
    5. }
    6.  
    7. if(module_enabled("mod_rewrite")){
    8.     echo "mod_rewrite enabled.";
    9. }
    10. ?>

    以上程式碼會檢查 mod_rewrite 是否開啟。這個方法只支援 apache module 安裝的 php,而不支援以 cgi 執行的 PHP。


    Leave a reply

    *
    To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
    Click to hear an audio file of the anti-spam word