php - 如何在 MAMP 中设置环境变量?

标签 php apache environment-variables mamp

如何在我可以在我的 PHP 应用程序中使用的 MAMP(3.3 版)中设置环境变量?

我更新了 /Applications/MAMP/Library/bin/envvars_ 和 envvars-std_ 文件 并添加了以下行:

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# envvars-std - default environment variables for apachectl
#
# This file is generated from envvars-std.in
#
if test "x$DYLD_LIBRARY_PATH" != "x" ; then
  DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
else
  DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib"
fi
export DYLD_LIBRARY_PATH

MY_TEST_DETAIL="foo"
export MY_TEST_DETAIL

#

我查看了 phpinfo(),但找不到 MY_TEST_DETAIL。

谁能告诉我我做错了什么? 提前致谢。

最佳答案

找到了解决方案。在 /Applications/MAMP/conf/apache/httpd.conf 添加以下内容:

SetEnv MY_TEST_DETAIL foo

关于php - 如何在 MAMP 中设置环境变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32110634/

相关文章:

php - 在 Magento 集合中的连接表中选择多行查询

javascript - $_POST 未定义,同时定义?

php - pear channel 更新 pear.php.net 后的 SSL 问题

php - 相同的网页在虚拟服务器实例和生产实例上看起来不同

react-native - 使用 .env 变量在 react-native 应用程序上设置 appcenter

python-2.7 - 如何在arch linux中用python 2完全替换python 3

linux - 如何在curl PUT 请求正文中使用环境变量?

php - 当用户更改类别时自动填充表单时的 JSON 使用

Apache Tomcat 和 Mod_jk

apache - 如何在 Apache Ruta 中将参数 dictRemoveWS 设置为 true