I’ve tried
the steps below, but doesn’t seem to take effect.
I created
a file index.php
at /Users/bheng/Sites/info
<?php
phpinfo();
?>
I added
a virtual host
<Virtualhost *:80>
VirtualDocumentRoot "/Users/bheng/Sites/info"
ServerName phpinfo.test
UseCanonicalName Off
</Virtualhost>
I saw
to http://phpinfo.test/
I see phpinfo page load up
Location of the php.ini
showed that it’s at /etc/
I went
to /etc
in my Terminal
⚡️ etc ls | grep php
php-fpm.conf.default
php-fpm.d/
php.ini.default
php.ini.default-5.2-previous
php.ini.default-5.2-previous~orig
php.ini.default-previous
php.ini.default-previous~orig
⚡️ etc ls | grep ini
mach_init.d/
mach_init_per_login_session.d/
mach_init_per_user.d/
php.ini.default
php.ini.default-5.2-previous
php.ini.default-5.2-previous~orig
php.ini.default-previous
php.ini.default-previous~orig
As you can see, I don’t see php.ini
there at all.
The only thing that closes to that is php.ini.default
I opened
that file, and update memory_limit to 4G.
Nothing seem to take effect, it kept show 128 MB on the site. 😓
I just want to update the memory_limit from 128 MB to 4 GB
Any hints for me ?
2
Answers
First, look at phpinfo’s output for the value of Loaded Configuration File. Also take a look at the section titled Additional .ini files parsed. You’ll need to check any and all INI files listed there to see if they might have a memory_limit value that is over-writing your setting.
I believe php.ini.default is just a fallback file that you can use to create a new PHP.ini file if you need to. Check the output of phpinfo as instructed above to determine which ini files are actually processed.
EDIT: Just seeing now that your phpinfo output says None next to Loaded Configuration File. I’d suggest copying that php.ini.default file to the location specified in Configuration File (php.ini) path which in your case is
/etc
. Note that this is a pretty awkward place for this file. PHP.ini is usually located somewhere like/etc/php7.0/
or/etc/php7.0/apache/
or something like that. However, your PHP executable is looking for it in/etc
so copy the file there:sudo cp /etc/php.ini.default /etc/php.ini
Finally, if you are running PHP-FPM (which it looks like you are from your ls command above) then you need to restart the PHP-FPM process pool. I’m not sure the exact command on your machine but this works on mine:
sudo service php7.0-fpm restart
What works on your machine will probably depend on how you installed PHP-FPM. You might also try:
service php-fpm restart
EDIT: You might also consider restarting apache. This will also depend on the installation method you have used. On my Ubuntu machine, this command works
sudo service apache2 restart
What you actually have to do is copy the php.ini.default file from /etc and create a new file php.ini on the same path. There you can make changes.