php+apache的配置

1. 配置擴展模塊的目錄:
extension_dir = "./ext/"
注意:在最後以定要以"/"結束。
2. 配置Mysql模模
extension=php_mysql.dll

說明:
php運行時配置:
在php運行的一些初始化參數,可以有在php.ini文件中設置。編譯時設置php.ini文件的路徑。也可以使用環境變量PHPRC來設置初始化參數。

php在參數在apache中是否有效?
1.如果php以cgi方式與apache整合,php將使用php.ini中的參數。
2. 如果php以apahce模塊方式加載,php的參數可以在httpd.conf中重新設置。如:
如果要配置生效需要設置:httpd.conf和.htaccess的參數:AllowOverride ALL 使得有權限完成配置

<IfModule mod_php5.c>
  php_value include_path ".:/usr/local/lib/php"
  php_admin_flag safe_mode on
</IfModule>
配置選項說明:
   php_value name value
          Sets the value of the specified directive. Can be used only
          with PHP_INI_ALL and PHP_INI_PERDIR type directives. To clear a
          previously set value use none as the value.

     Note: Don't use php_value to set boolean values. php_flag (see
     below) should be used instead.

   php_flag name on|off
          Used to set a boolean configuration directive. Can be used only
          with PHP_INI_ALL and PHP_INI_PERDIR type directives.

   php_admin_value name value
          Sets the value of the specified directive. This can not be used
          in .htaccess files. Any directive type set with php_admin_value
          can not be overridden by .htaccess or virtualhost directives.
          To clear a previously set value use none as the value.

   php_admin_flag name on|off
          Used to set a boolean configuration directive. This can not be
          used in .htaccess files. Any directive type set with
          php_admin_flag can not be overridden by .htaccess or
          virtualhost directives.

php + apache 的配置
方式1. 配置CGI,在httpd.conf中加入:

ScriptAlias /php/ "c:/php/"
AddType application/x-httpd-php .php
# For PHP 4
Action application/x-httpd-php "/php/php.exe"
# For PHP 5
Action application/x-httpd-php "/php/php-cgi.exe"

方式2.配置php作爲apache的一個模塊,在httpd.conf中加入:
# For PHP 4 do something like this:
LoadModule php4_module "c:/php/sapi/php4apache2.dll"
AddType application/x-httpd-php .php
# For PHP 5 do something like this:
LoadModule php5_module "c:/php/php5apache2.dll"
AddType application/x-httpd-php .php


httpd.conf的配置需要重新啓動服務器後才生效。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章