简体   繁体   English

无法增加 MAMP php 内存限制

[英]Can't increase MAMP php memory limit

I've been trying to increase the php memory_limit in MAMP (Mac OSX).我一直在尝试增加 MAMP (Mac OSX) 中的 php memory_limit。 The version of PHP I'm using is 5.4.1.0.我使用的 PHP 版本是 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 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.感谢您的时间。


I've added the following to my site's htaccess file, which is read by the site and works (ExpressionEngine). 我已将以下内容添加到我网站的 htaccess 文件中,该文件由网站读取并有效(ExpressionEngine)。 But the master PHP limit is still not updating. 但是主 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.10 /Applications/MAMP/conf/php5.4.10
memory_limit = 128M ; memory_limit = 128M ;

I then quit MAMP entirely and restarted it, but in MAMP phpInfo it still reads:然后我完全退出 MAMP 并重新启动它,但在 MAMP phpInfo 中它仍然显示:
memory_limit 32M内存限制 32M


Virtual Hosts虚拟主机

I am using Virtual Hosts to set my own URLs.我正在使用虚拟主机来设置我自己的 URL。 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':所以我将它添加到“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

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!谢谢!

Make an phpinfo.php and put there the phpinfo();制作一个phpinfo.php并将phpinfo(); in the output you can see the loaded configuration files and the values.在输出中,您可以看到加载的配置文件和值。

Edit the loaded php.ini file and set the memory limit.编辑加载的 php.ini 文件并设置内存限制。 I think you have edited the wrong php.ini file or your application set the value over memory_limit .我认为您编辑了错误的 php.ini 文件或您的应用程序将值设置为memory_limit

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.我已经追了几个小时,试图清理我所有的php.ini文件,尝试使用文本编辑器更新设置并保存它。 And every time I'd restart MAMP the settings would get changed back and the file would be overwritten.每次我重新启动 MAMP 时,设置都会被改回来,文件会被覆盖。 So here's how I did it where I finally didn't get overwritten by MAMP.所以这就是我如何做到的,我最终没有被 MAMP 覆盖。

In MAMP, use the menu to get to version of PHP you are using.在 MAMP 中,使用菜单获取您正在使用的 PHP 版本。 Mine is 7.3.1 at this time.我的此时是 7.3.1。

  1. MAMP > File > Edit Template > PHP(php.ini) > 7.3.1
  2. An editor window will open, then use the search bar to find your setting... memory_limit将打开一个编辑器窗口,然后使用搜索栏查找您的设置... memory_limit
  3. Update your setting更新您的设置
  4. Cmd + S then close the editor window OR just close the editor window and click "Save" when you are prompted Cmd + S 然后关闭编辑器窗口或关闭编辑器窗口并在出现提示时单击“保存”
  5. MAMP will then automatically re-start the servers with the new settings然后 MAMP 将使用新设置自动重新启动服务器

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();但根据phpinfo(); My loaded configuration file is in different path!我加载的配置文件在不同的路径中! It is here:是这里:

/Library/Application Support/appsolute/MAMP PRO/conf/php7.2.8.ini

Also don't forget restart Mamp Pro.也不要忘记重新启动 Mamp Pro。

Coming here after facing the same problem with PHP v.7.2 .遇到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.ini and change the following:要解决此问题,我需要转到路径/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 字节的允许内存大小...)

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 模式)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM