# Can't use WP-CLI due to php memory limit

**URL:** https://discourse.roots.io/t/cant-use-wp-cli-due-to-php-memory-limit/20257
**Category:** trellis
**Created:** 2021-03-02T15:48:19Z
**Posts:** 7

## Post 1 by @LucasDemea — 2021-03-02T15:48:19Z

In my dev environment, I try to use the trellis built-in variable `wp_cli_packages` to provision my site with and additional wp-cli package, but I get this error :

```
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 2621440 bytes) in 
phar:///usr/bin/wp/vendor/composer/composer/src/Composer/Json/JsonFile.php on line 275
```

I tried increasing the php\_memory\_limit to 512M, but I still get the same error.  
In wordpress backend I can see the php limit has been increased, but if I `vagrant ssh` in my dev environment and type :

```
php --info | grep memory_limit
```

I get :

```
memory_limit => 128M => 128M
```

which seems to be the cause of the issue.

If I try to install the package with :  
`php -d memory_limit=512M "$(which wp)" package install git@github.com:10up/wp-vulnerability-scanner.git`

It works. But this is not an acceptable solution for me as I want to automate this wp-cli package install.

This is what the top of my groups\_var/all/main.yml file looks like :

```
php_memory_limit: 512M

composer_keep_updated: true

apt_cache_valid_time: 3600

apt_package_state: present

apt_security_package_state: latest

apt_dev_package_state: latest

ntp_timezone: Europe/Paris

ntp_manage_config: true

www_root: /srv/www

theme: example-theme

wp_cli_packages: ["git@github.com:10up/wp-vulnerability-scanner.git"]
```

What am I missing here ?

**EDIT:** I did reprovision the VM with `vagrant provisison` and `vagrant reload --provision`

---

## Post 2 by @strarsis — 2021-03-02T16:09:02Z

Have you reprovisioned the Vagrant VM after changing the memory config?

---

## Post 3 by @LucasDemea — 2021-03-03T05:44:37Z

Yes, I did run `vagrant provision`.

---

## Post 4 by @strarsis — 2021-03-03T12:01:55Z

SSH into the vagrant box (`vagrant ssh`) and inspect the PHP configuration files. Has the memory limit changed, notably in the PHP CLI configuration file?

---

## Post 5 by @LucasDemea — 2021-03-03T13:00:16Z

/etc/php/7.4/fpm/php.ini :

```
...
memory_limit = 512M
...
```

/etc/php/7.4/cli/php.ini :

```
;Ansible managed

[PHP]
error_reporting = E_ALL
sendmail_path = /opt/mailhog/mhsendmail
expose_php = Off
date.timezone = Europe/Paris

[mysqlnd]
mysqlnd.collect_memory_statistics = On

[opcache]
opcache.enable = 0
opcache.enable_cli = 1
opcache.memory_consumption = 128
opcache.interned_strings_buffer = 8
opcache.max_accelerated_files = 4000
opcache.revalidate_freq = 60
opcache.fast_shutdown = 1
```

---

## Post 6 by @strarsis — 2021-03-03T15:41:53Z

Apparently the PHP CLI memory limit has to be set differently/explicitly, see this discussion

> <https://serverfault.com/questions/295584/php-cli-memory-limit>

---

## Post 7 by @system — 2021-04-13T15:48:21Z

This topic was automatically closed after 42 days. New replies are no longer allowed.
