php+apache的配置

2019-04-14 21:23发布

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 使得有权限完成配置
  php_value include_path ".:/usr/local/lib/php"
  php_admin_flag safe_mode on

配置选项说明:
   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的配置需要重新启动服务器后才生效。