yzc164 发表于 2015-8-6 10:08:36

apache SetEnv 设置

  php的服务器预定义变量 $_SERVER
  可以通过apache的mod_env模块来添加我们所需要的内容
  来段官网介绍
  
Description:Modifies the environment which is passed to CGI scripts and SSI pagesStatus:BaseModule Identifier:env_moduleSource File:mod_env.c


Summary
  This module allows for control of internal environment variables that are used by various Apache HTTP Server modules. These variables are also provided to CGI scripts as native system environment variables, and available for use in SSI pages. Environment variables may be passed from the shell which invoked the httpd process. Alternatively, environment variables may be set or unset within the configuration process.
  
  可以通过 SetEnv来向apache虚拟主机配置文件里写一些我们需要的东西
  对setenv来段官网介绍
Description:Sets environment variablesSyntax:SetEnv env-variable Context:server config, virtual host, directory, .htaccessOverride:FileInfoStatus:BaseModule:mod_env  
  
  
  
  
  Sets an internal environment variable, which is then available to Apache HTTP Server modules, and passed on to CGI scripts and SSI pages.
Example
  SetEnv SPECIAL_PATH /foo/bin
  If you omit the value argument, the variable is set to an empty string.
  
  来段配置实例
  
    ServerName aa.com
    DocumentRoot /var/www
    AddDefaultCharset UTF-8
   
      RewriteEngine on
      #RewriteCond %{HTTP_HOST}   !^$
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule !\.(js|ico|gif|jpg|png|css|xml|swf|cur|html|apk|manifest)$ /index.php
   
    SetEnv RUN_MODE production

  就是红色部分了,可以在php里使用$_SERVER['RUN_MODE']来进行调用和判断,这样在本地开发环境中不配置这个变量,在服务器上配置这个变量,可以写两份配置文件,判断这个变量的不同,从而调用不同的配置文件来进行开发.
页: [1]
查看完整版本: apache SetEnv 设置