无法增加 MAMP php 内存限制
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25996782/
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
Can't increase MAMP php memory limit
提问by jx3
I've been trying to increase the php memory_limit in MAMP (Mac OSX). The version of PHP I'm using is 5.4.1.0. I've read about creating a new template for MAMP Pro, but I'm using the standard version of MAMP.
我一直在尝试增加 MAMP (Mac OSX) 中的 php memory_limit。我使用的 PHP 版本是 5.4.1.0。我已阅读有关为 MAMP Pro 创建新模板的信息,但我使用的是 MAMP 的标准版本。
I've tried all of the below, but nothing seems to have worked. Any help would be much appreciated.
我已经尝试了以下所有方法,但似乎没有任何效果。任何帮助将非常感激。
Thank you for your time.
感谢您的时间。
我已将以下内容添加到我网站的 htaccess 文件中,该文件由网站读取并有效(ExpressionEngine)。但是主 PHP 限制仍然没有更新。
php_value memory_limit 128M
I've changed the following from 32M to 128M in the following file:
我已将以下文件中的以下内容从 32M 更改为 128M:
/Applications/MAMP/conf/php5.4.10memory_limit = 128M
;
/Applications/MAMP/conf/php5.4.10memory_limit = 128M
;
I then quit MAMP entirely and restarted it, but in MAMP phpInfo it still reads:
memory_limit 32M
然后我完全退出 MAMP 并重新启动它,但在 MAMP phpInfo 中它仍然显示:
memory_limit 32M
Virtual Hosts
虚拟主机
I am using Virtual Hosts to set my own URLs. I read somewhere that it may be necessary to increase the memory limit here. So I added this to the 'php_value memory_limit 128M':
我正在使用虚拟主机来设置我自己的 URL。我在某处读到可能有必要在这里增加内存限制。所以我将它添加到“php_value memory_limit 128M”中:
/Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
/Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot /Applications/MAMP/htdocs
ServerName localhost
php_value memory_limit 128M
</VirtualHost>
and lower down in the same file in the relevant site's configuration:
并在相关站点配置中的同一文件中降低:
<VirtualHost *:80>
DocumentRoot "/Users/Username/Dropbox/Dev/sitename.dev"
ServerName sitename.dev
php_value memory_limit 128M
</VirtualHost>
(By the way, I keep my MAMP folder (Dev) in Dropbox and it works fine)
(顺便说一句,我将我的 MAMP 文件夹(Dev)保存在 Dropbox 中,它工作正常)
php.ini
配置文件
I also added a php.ini file with the following contents in both the root of my site directory and the root of my MAMP directory:
我还在站点目录的根目录和 MAMP 目录的根目录中添加了一个包含以下内容的 php.ini 文件:
memory_limit = 128M
回答by jx3
Managed to solve it ;-)
设法解决它;-)
The correct one is:
正确的一种是:
/Applications/MAMP/bin/php/php[your_php_version]/conf/php.ini
find 'memory_limit' and increase the number:
找到“memory_limit”并增加数字:
memory_limit = [number]M
Thanks!
谢谢!
回答by René H?hle
Make an phpinfo.php
and put there the phpinfo();
in the output you can see the loaded configuration files and the values.
制作一个phpinfo.php
并将其放在phpinfo();
输出中,您可以看到加载的配置文件和值。
Edit the loaded php.ini file and set the memory limit. I think you have edited the wrong php.ini file or your application set the value over memory_limit
.
编辑加载的 php.ini 文件并设置内存限制。我认为您编辑了错误的 php.ini 文件或您的应用程序将值设置为memory_limit
.
回答by ali jarkani
In Mamp Pro and PHP version 7.2.8 ,you can find configuration file in this path:
在 Mamp Pro 和 PHP 7.2.8 版本中,您可以在此路径中找到配置文件:
/Applications/MAMP/bin/php/php7.2.8/conf/php.ini
But according to phpinfo();
My loaded configuration file is in different path! It is here:
但是根据phpinfo();
我加载的配置文件在不同的路径中!是这里:
/Library/Application Support/appsolute/MAMP PRO/conf/php7.2.8.ini
Also don't forget restart Mamp Pro.
也不要忘记重新启动 Mamp Pro。
回答by Sébastien Gicquel
I was able to set memory_limit with MAMP PRO 5.5 on MacOS here :
我可以在 MacOS 上使用 MAMP PRO 5.5 设置 memory_limit :
/Applications/MAMP/bin/php/php7.3.8/conf/php.ini
PHP mode is Individual PHP version for every host (CGI mode)
PHP 模式是每个主机的单独 PHP 版本(CGI 模式)
回答by Shane McCurdy
I have been chasing this for a couple hours, trying to scrub through all my php.ini
files trying to update the settings with a text editor and saving it. And every time I'd restart MAMP the settings would get changed back and the file would be overwritten. So here's how I did it where I finally didn't get overwritten by MAMP.
我已经追了几个小时,试图清理我的所有php.ini
文件,试图用文本编辑器更新设置并保存它。每次我重新启动 MAMP 时,设置都会被改回来,文件会被覆盖。所以这就是我最终没有被 MAMP 覆盖的地方。
In MAMP, use the menu to get to version of PHP you are using. Mine is 7.3.1 at this time.
在 MAMP 中,使用菜单获取您正在使用的 PHP 版本。我的此时是 7.3.1。
MAMP > File > Edit Template > PHP(php.ini) > 7.3.1
- An editor window will open, then use the search bar to find your setting...
memory_limit
- Update your setting
- Cmd + S then close the editor window OR just close the editor window and click "Save" when you are prompted
- MAMP will then automatically re-start the servers with the new settings
MAMP > File > Edit Template > PHP(php.ini) > 7.3.1
- 将打开一个编辑器窗口,然后使用搜索栏查找您的设置...
memory_limit
- 更新您的设置
- Cmd + S 然后关闭编辑器窗口或关闭编辑器窗口并在出现提示时单击“保存”
- 然后 MAMP 将使用新设置自动重新启动服务器
回答by christostsang
Coming here after facing the same problem with PHP v.7.2. To fix this I needed to go to the path /usr/local/etc/php/7.2/conf.d/php-memory-limits.iniand change the following:
在遇到与PHP v.7.2相同的问题后来到这里。要解决此问题,我需要转到路径/usr/local/etc/php/7.2/conf.d/php-memory-limits.ini并更改以下内容:
; Max memory per instance
memory_limit = 2048M
Anything else I tried would not change it.
我尝试过的其他任何事情都不会改变它。
Now I don't get this errors when trying to pull packages with composer in my projects (Fatal error: Allowed memory size of 536870912 bytes exhausted...)
现在,当我尝试在我的项目中使用 Composer 提取包时,我没有收到此错误(致命错误:已耗尽 536870912 字节的允许内存大小...)