"php --help" results in "PHP memory error" error on Ubuntu

PHP Fatal error: the allowed memory size of 262144 bytes has been exhausted (tried to allocate 523800 bytes) in Unknown on line 0

The same thing happens with "php5 --help"

I already studied this and read that I should: 1) increase the memory limit in php.ini - it is 128 MB in all instances of php.ini - should be enough to run php cli help 2) make the script more efficient memory - obviously not applies to --help

Please help if you can?

+4
source share
6 answers

Check out the php.ini file for the PHP CLI (/etc/php5/cli/php.ini).

Make sure your memory_limit declaration has its own blocks set:

memory_limit = 32M 

not

 memory_limit = 32 

This is fixed for me . I hope this works for you too.

+12
source

I assume that you are using the latest version of Linux. I use Ubuntu, but any Debian distribution such as Linux will be similar, and the other distribution will also not have many differences.

In / etc / php5 / I have the following configuration directories:

 root@delphic :/etc/php5# ls -la total 20 drwxr-xr-x 5 root root 4096 2011-01-15 00:52 . drwxr-xr-x 92 root root 4096 2011-01-15 00:51 .. drwxr-xr-x 2 root root 4096 2011-01-05 10:55 apache2 drwxr-xr-x 2 root root 4096 2011-01-15 00:52 cli drwxr-xr-x 2 root root 4096 2011-01-15 00:51 conf.d root@delphic :/etc/php5# cd cli root@delphic :/etc/php5/cli# ls -al total 76 drwxr-xr-x 2 root root 4096 2011-01-15 00:52 . drwxr-xr-x 5 root root 4096 2011-01-15 00:52 .. lrwxrwxrwx 1 root root 9 2011-01-15 00:52 conf.d -> ../conf.d -rw-r--r-- 1 root root 67457 2011-01-12 19:51 php.ini root@delphic :/etc/php5/cli# grep memory php.ini ; Maximum amount of memory a script may consume (128MB) ; http://php.net/memory-limit memory_limit = -1 

Have you also changed the CLI memory limit?

If you use the shared hosting service, you will have to ask for help in changing the restrictions or find out why php consumes so much memory even on the command line.

+2
source

Text

Allowable memory size 262144

Assumes PHP does not consider the memory limit to be 128 MB. Did you miss the php.ini file? Could you post your php.ini online?

+1
source

How strange that ini instructions are talking about using MB, but this did not work for me, the standard apt-get install, only the other bit that I added was APC. I could not understand what could be wrong, fortunately, some of the comments made above just use M

Looks like an IMO error, especially given the ini instructions.

ini says it // The maximum amount of memory a script can consume (128 MB)

But only this worked for me: / 228th

+1
source

Can you run php -i to get PHP info? You may not be loading the php.ini file you expect and the memory limit is much lower. Although, it’s really strange that the PHP CLI will use PHP to display CLI help.

Refresh . You may not be able to run php -i , but php --ini can do the trick, at least by showing you that (if any) the INI file is being used.

0
source

The value in my php.ini file was 1024 MB, and I was still getting the error. What I did to fix it, change it to 1024 M, it’s strange, as in the example the text said 128 MB

0
source

Source: https://habr.com/ru/post/1335625/


All Articles