【发布时间】:2021-10-13 19:20:50
【问题描述】:
安装最新版本的xampp 8.0.9 后,当我从xampp 面板打开终端时,我有另一个操作系统Debian,
uname -a -r
Linux debian 4.19.0-17-amd64 #1 SMP Debian 4.19.194-3 (2021-07-18) x86_64 GNU/Linux
现在导航到htdocs 文件夹内的php 项目后,我尝试使用composer upadte 安装和更新composer.json 包,但我收到此错误:
composer update
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Loading composer repositories with package information
Warning from https://repo.packagist.org: Support for Composer 1 is deprecated and some packages will not be available. You should upgrade to Composer 2. See https://blog.packagist.com/deprecating-composer-1-support/
Updating dependencies (including require-dev)
mmap() failed: [12] Cannot allocate memory
mmap() failed: [12] Cannot allocate memory
PHP Fatal error: Out of memory (allocated 798220288) (tried to allocate 32134463 bytes) in /usr/share/php/Composer/Util/RemoteFilesystem.php on line 459
Fatal error: Out of memory (allocated 798220288) (tried to allocate 32134463 bytes) in /usr/share/php/Composer/Util/RemoteFilesystem.php on line 459
当我收到此错误时,我尝试将 memory_limit 更改为 php.ini 文件,然后运行此命令:
php --ini
输出:
Configuration File (php.ini) Path: /opt/lampp/etc
Loaded Configuration File: /opt/lampp/etc/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
这里memory_limit 是-1,当我安装php 8.0.9 时,/etc/ 内没有php 文件夹,而我只有php 7.3
php -v
输出:
PHP 8.0.9 (cli) (built: Jul 30 2021 09:12:42) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.9, Copyright (c) Zend Technologies
在php 7.3文件夹内打开php.ini更改memory_limit,这个选项值也有-1
现在如何增加memory_limit 并解决这个问题?
最后运行这个命令不要给我任何输出或结果:
php -d memory_limit=1024M /usr/bin/composer update
【问题讨论】: