当前位置首页 > Apache知识

apacheSetEnv设置

阅读次数:277 次  来源:admin  发布时间:

hp的服务器预定义变量 $_SERVER

可以通过apache的mod_env模块来添加我们所需要的内容

来段官网介绍

Description: Modifies the environment which is passed to CGI scripts and SSI pages Status: Base Module Identifier: env_module Source 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 variables Syntax: SetEnv env-variable [value] Context: server config, virtual host, directory, .htaccess Override: FileInfo Status: Base Module: 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/bi

If you omit the value argument, the variable is set to an empty string.

来段配置实例

lt;VirtualHost *:80>

ServerName aa.com

DocumentRoot /var/www

AddDefaultCharset UTF-8

lt;IfModule mod_rewrite.c>

RewriteEngine o

#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.ph

lt;/IfModule>

SetEnv RUN_MODE productio

lt;/VirtualHost>

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

上一篇:mac系统中搭建apache+mysql+php的开发环境,安装mysql后,登录报错:macERROR1045(28000):
下一篇:apache访问日志