是否可以在php.ini中使用环境变量? [英] Is it possible to use environment variables in php.ini?

查看:108
本文介绍了是否可以在php.ini中使用环境变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不想硬链接我的php.ini配置中的一些路径,我想使用系统变量配置它们在一些其他地方,如我的Apache配置共享。我已经做了一些搜索,找不到合适的关键字组合,以发现是否有办法做到这一点。

Rather than hard-wiring some paths in my php.ini configuration, I'd like to configure them using system variables that are shared in some other places such as my Apache configuration. I've done some searching and couldn't find the right mix of keywords to discover if there's a way to do this.

有谁知道这是否可以做到?

Does anyone know if this can be done?

upload_tmp_dir = $SCRATCH_HOME/uploads

现在SCRATCH_HOME可以在环境中导出为/ tmp或/ var / scratch或任何我想要的。

Now SCRATCH_HOME can be exported in the environment as /tmp or /var/scratch or whatever I want it to be.

推荐答案

此功能没有详细记录。
在开始之前,我只想指定我的配置:
我使用Windows 7-64bit,PHP 5.4.3,Apache HTTP Server 2.2.x,我设置了环境变量 PHP_HOME = C:\tools\php-5.4.3 (PHP安装目录)。
我使用 httpd.conf php.ini 文件中的变量

This feature is not well documented. Before I begin, I just want to specify my configurations: I'm using Windows 7-64bit, PHP 5.4.3, Apache HTTP Server 2.2.x, I've set my environmental variable PHP_HOME=C:\tools\php-5.4.3 (PHP installation directory). I use the variable in my httpd.conf and php.ini file

注意:为了简洁,我将略去一些文本。

Note: I will be omitting some text for brevity.

httpd.conf file

# For PHP 5 do something like this:
LoadModule php5_module "${PHP_HOME}/php5apache2_2.dll"
AddType application/x-httpd-php .php

# configure the path to php.ini
PHPIniDir "${PHP_HOME}"

php.ini 档案

; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
extension_dir = "${PHP_HOME}/ext"

这篇关于是否可以在php.ini中使用环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆