MAMP 将其 php.ini 保存在哪里?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11691767/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 01:53:11  来源:igfitidea点击:

Where does MAMP keep its php.ini?

macosmampphp

提问by James Vince

I have recently got a mac an am not used to developing on a mac at all.

我最近有了一台 mac,我根本不习惯在 mac 上进行开发。

I have MAMP Pro 1.9.6.1. I did a locate on php.iniand got this:

我有 MAMP Pro 1.9.6.1。我做了一个定位php.ini并得到了这个:

$ locate php.ini
/Applications/MAMP/conf/php5.2/php.ini
/Applications/MAMP/conf/php5.3/php.ini
/Library/Application Support/appsolute/MAMP PRO/conf/php.ini
/private/etc/php.ini.default

I changed the name of all of them. Restarted MAMP. It loaded without a hitch (I know odd right?). I am using PHP version 5.2.

我改变了他们所有人的名字。重新启动 MAMP。它顺利加载(我知道奇怪吗?)。我使用的是 PHP 5.2 版。

All of these files are now different names (done one by one for process of elimination). So I figure restart the mac. Same, MAMP loaded no problems, even though all of the php.inifiles had been move. On Lamp this that wouldn't even load. But either there is another php.inifile I'm missing (quite possible I don't know how to updatedb), MAMP is really intelligent and just pulls in all of them (less likely) or it doesn't use one.

所有这些文件现在都是不同的名称(为消除过程一一完成)。所以我想重启mac。同样,MAMP 加载没有问题,即使所有php.ini文件都已移动。在灯上,这甚至不会加载。但是,要么php.ini我缺少另一个文件(很可能我不知道该怎么做updatedb),MAMP 真的很聪明,只是拉入所有文件(不太可能),或者它不使用一个。

回答by drew010

Note:If this doesn't help, check below for Ricardo Martins' answer.

注意:如果这没有帮助,请查看下面的 Ricardo Martins 的答案。



Create a PHP script with <?php phpinfo() ?>in it, run that from your browser, and look for the value Loaded Configuration File. This tells you which php.inifile PHP is using in the context of the web server.

在其中创建一个 PHP 脚本<?php phpinfo() ?>,从浏览器运行该脚本,然后查找值Loaded Configuration File. 这会告诉您php.iniPHP 在 Web 服务器的上下文中正在使用哪个文件。

回答by Ricardo Martins

I'm not sure if in MAMP (non-PRO) is the same, but MAMP overrides the modified php.inieverytime it starts.

我不确定在 MAMP(非 PRO)中是否相同,但 MAMPphp.ini每次启动时都会覆盖修改后的内容。

In my case, I needed to use the MAMP menu to change my php.ini file(File -> Edit Template -> PHP -> PHP 5.xx -> php.ini).

就我而言,我需要使用 MAMP 菜单来更改我的php.ini file( File -> Edit Template -> PHP -> PHP 5.xx -> php.ini)。

回答by Aerendir

To be clearer (as i read this thread but didn't SEE the solution, also if it was here!), I have the same problem and found the cause: I were modifying the wrong php.ini!

为了更清楚(因为我阅读了这个线程但没有看到解决方案,如果它在这里!),我遇到了同样的问题并找到了原因:我修改了错误的php.ini!

Yes, there are 2 php.ini files in MAMP:

是的,MAMP 中有 2 个 php.ini 文件:

  1. Applications/MAMP/conf/php5.5.10/php.ini
  2. Applications/MAMP/bin/php/php5.5.10/conf/php.ini
  1. 应用程序/MAMP/conf/php5.5.10/php.ini
  2. 应用程序/MAMP/bin/php/php5.5.10/conf/php.ini

The right php.ini file is the second: Applications/MAMP/bin/php/php5.5.10/conf/php.ini

正确的 php.ini 文件是第二个:Applications/MAMP/bin/php/php5.5.10/conf/php.ini

To prove this, create a .php file (call it as you like, for example "info.php") and put into it a simple phpinfo()

为了证明这一点,创建一个 .php 文件(随意命名,例如“info.php”)并在其中放入一个简单的 phpinfo()

<?php
echo phpinfo();

Open it in your browser and search for "Loaded Configuration File": mine is "/Applications/MAMP/bin/php/php5.5.10/conf/php.ini"

在浏览器中打开它并搜索“加载的配置文件”:我的是“/Applications/MAMP/bin/php/php5.5.10/conf/php.ini”

The error was here; i edited Applications/MAMP/conf/php5.5.10/php.ini but this is the wrong file to modify! Infact, the right php.ini file is the one in the bin directory.

错误就在这里;我编辑了 Applications/MAMP/conf/php5.5.10/php.ini 但这是要修改的错误文件!事实上,正确的 php.ini 文件是 bin 目录中的文件。

Take care of this so small difference that caused me literally 1 and a half hours of headaches!

照顾好这个让我头痛了 1 个半小时的如此微小的差异!

回答by tim

The file you have to edit is in MAMP Pro and uses the php.inifile everytime it starts up.

您必须编辑的文件位于 MAMP Pro 中,并且php.ini每次启动时都会使用该文件。

  • Start MAMP PRO
  • Edit File > Edit Templates > PHP 5.3.2 php.ini
  • Restart MAMP Pro
  • 启动 MAMP PRO
  • 编辑 File > Edit Templates > PHP 5.3.2 php.ini
  • 重启 MAMP Pro

Your changes should stick.

你的改变应该坚持下去。

回答by zarpio

Just run the following command from your terminal, it will show you your Loaded Configuration Fileeasiest way I have ever found.

只需从您的终端运行以下命令,它就会向您显示我找到的最简单的加载配置文件方式。

php --ini

回答by Jonathan Disla

I don't know if you ever found an answer to this but I DIDN'T need MAMP PRO to do this. Simply goto the correct path by following what others have said. It's something like...

我不知道你是否找到了答案,但我不需要 MAMP PRO 来做到这一点。跟着别人说的走正确的路就行了。有点像...

MAMP-> bin-> php-> php(your php version)-> conf-> php.ini

MAMP-> bin-> php-> php(你的php版本)-> conf-> php.ini

The key here is where you're editing the file. I was making the mistake of editing the commented part of the ini file. You actually have to scroll down to LINE #472 where it says "display_errors = Off and change it to On. Hope this helps any

这里的关键是您编辑文件的位置。我在编辑 ini 文件的注释部分时犯了一个错误。您实际上必须向下滚动到第 472 行,其中显示“display_errors = Off 并将其更改为 On。希望这对您有所帮助

回答by Manikandan

After running the MAMP server, you have php info link in toolbar Once click, You will get all information about php enter image description here

运行 MAMP 服务器后,您将在工具栏中获得 php 信息链接 一旦单击,您将获得有关 php 的所有信息 在此处输入图片说明

回答by nicowernli

Change /Applications/MAMP/conf/php5.2/php.ini if you are using 5.2 version of php. If you are using the 5.3 php version, edit the /Applications/MAMP/conf/php5.3/php.ini.

如果您使用的是 5.2 版本的 php,请更改 /Applications/MAMP/conf/php5.2/php.ini。如果您使用的是 5.3 php 版本,请编辑 /Applications/MAMP/conf/php5.3/php.ini。

If you are using OSX Lion or OSX Mountain Lion, I recommend you using the default installation of apache and php.

如果您使用的是 OSX Lion 或 OSX Mountain Lion,我建议您使用默认安装的 apache 和 php。

Greets!

问候!

回答by leopinzon

It depends on which version of PHP your MAMP is using. You can find it out on: /Applications/MAMP/conf/apache/httpd.conflooking for the configured php5_module.

这取决于您的 MAMP 使用的 PHP 版本。您可以在以下位置找到它:/Applications/MAMP/conf/apache/httpd.conf寻找已配置的php5_module.

After that, as someone said before, you have to go to the binfolder. There you'll find a conffolder with a php.iniinside.

之后,正如之前有人所说,您必须转到bin文件夹。在那里你会找到conf一个php.ini里面有一个文件夹。

example: /Applications/MAMP/bin/php/php5.4.10/conf

例子: /Applications/MAMP/bin/php/php5.4.10/conf

Leo

狮子座

回答by Panos Spiliotis

Probably the fastest way to access the PHP.ini for the currently loaded version of PHP in MAMP PRO (v.4.2.1):

可能是在 MAMP PRO (v.4.2.1) 中为当前加载的 PHP 版本访问 PHP.ini 的最快方法:

  1. Open MAMP Pro
  2. Click on "PHP" under the "Languages" section on the sidebar
  3. Tap on the arrow button right next to the drop-down that lets you select the "Default Version" of PHP.
  1. 打开 MAMP 专业版
  2. 点击侧边栏“语言”部分下的“PHP”
  3. 点击下拉菜单旁边的箭头按钮,您可以选择 PHP 的“默认版本”。