I've made the possible changes to the php.in at /etc/php.ini. I didn't had php.ini so took a copy of php.ini.default. The changes I've made are
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=64
When I print phpinfo() and see the result, I tried to find opcache and it is not showing up. I'm using Mac Sierra.
Make sure you have edited the correct php.ini (it can be seen in the phpinfo() result).
Check, if the files listed in "Additional ini files parsed" does not override your settings. (e.g.: opcache.enable=0 somewhere override your php.ini setting)
If you are using PHP-FPM, that need a restart / reload to pick up the changes.
Related
I'm using the standard Apache and PHP 7.1 (not Homebrew) that comes with Mac High Sierra. However, it appears that this version doesn't have Opcache enabled even though it should come as standard with PHP 7. It's even listed in phpinfo() under "Module Authors", but no section showing it's actually installed. Calling opcache_get_status gives a fatal error.
I've installed the extension via Homebrew, and linked the opcache.so file. It appears to be working on the CLI but not in Apache. For some reason the CLI and web are using different ini files:
/usr/local/etc/php/7.1/php.ini for CLI
/etc/php.ini for web
The CLI is parsing the addition files including /usr/local/etc/php/7.1/conf.d/ext-opcache.ini, and php -i shows Opcache. But phpinfo() in the browser does not - no additional ini files are parsed.
I currently have this in /etc/php.ini:
[opcache]
zend_extension="/usr/local/opt/php71-opcache/opcache.so"
opcache.enable=1
But still nothing. I followed the exact same process for xdebug and it worked fine. What am I missing?
I wonder if it would be easier to use the Homebrew version of PHP. But I don't appear to have the required .so file. Various tutorials say to put this in Apache's httpd.conf:
LoadModule php7_module /usr/local/opt/php71/libexec/apache2/libphp7.so
But the libexec directory does not exist. There is lib but neither this nor any other directory has any .so file.
For me it worked by these steps:
Search extension_dir in "phpinfo()" page, I got a path
/usr/lib/php/extensions/no-debug-non-zts-20160303
By execute ls -lh /usr/lib/php/extensions/no-debug-non-zts-20160303, I found "opcache.so" , I guess it's installed when upgraded to "High Sierra"
Create "/etc/php.ini" (by copy "/etc/php.ini.default"), and modify:
[opcache]
zend_extension = opcache.so
opcache.enable = 1
Restart apache, module "opcache" is enabled
EDIT / CONCLUSION
Since "opcache extension" is installed on Mac OS High Sierra by default, the solution of enabling opcahe on Mac OS High Sierra is:
Create "/etc/php.ini" if you don't have one, by simply copy the default configuration: sudo cp /etc/php.ini.default /etc/php.ini
Add zend_extension = opcache.so to /etc/php.ini and set "opcache" enable:
php.ini opcache section looks like:
[opcache]
zend_extension = opcache.so
opcache.enable = 1
I've using PHP 5.5.27 installed on Apache 2.4 on CentOS 7. Opcache is showing on a phpinfo() page as:
Opcode Caching: Disabled
Yet below opcache.enable shows 'On'. I verified the proper php.ini is being used (/etc/php.d/opcache.ini) and it shows that it is loading up above in the list of loaded config files. I tried replacing zend_extension=opcache.so with the full path to the file, but that didn't work either. I even restarted apache after each of the changes.
I feel like I must be missing something simple, but I have no idea what it is.
Turns out I had zend_extension=opcache.so in my /etc/php.ini file as well as in the /etc/php.d/opcache.ini. Removing it from /etc/php.ini fixed the issue. Guessing that either it couldn't find the path, or didn't like that it was listed twice.
I remember in PHP 5.3 I could easily change xdebug settings inside php.ini file. (i.e. xdebug.max_nesting_level = 200)
I have upgraded to PHP 5.4 and since then no longer I can modify xdebug settings.
I make changes in php.ini and restart the webserver but nothing happens.
Looking inside php.ini there is no definition for xdebug settings.
but when I run:
php -m
I see xdebug already loaded.
Surprisingly when I run:
php -i | grep xdebug
I see loads of xdebug settings.
So my question is where are those settings come from if they are not in php.ini
(I need to add I have checked /etc/php5/cli/conf.d/20-xdebug.ini already and there is onlu one line in it: zend_extension=/usr/lib/php5/20100525/xdebug.so)
And how can I modify these settings.
Its the same like before. Open a phpinfo and look which ini files are loaded. In one of that files should be a xdebug part and you can modify them. If there is not block for xdebug you can add them. You can put that settings to the 20-xdebug.ini if you but if there are some other settings and the order is not correct your changes aren't working.
I've installed Apache 2.4.x webserver on Ubuntu and also PHP5.5.x from sources. I go to php installation folder and do find . -name "opcache.so". Then, to php.ini (same as in phpinfo()), I add zend_extension=/php5/lib/php/extensions/no-debug-zts-x/opcache.so, and opcache.enable=On (or 1) and restart Apache with apachectl restart. Then I check phpinfo() but opcache does not get enabled! Please help.
I think a wrong php.ini file might be used, but in phpinfo() it shows the path to file which I do edit. When I change maximum upload filesize from 2M to 4M in the php.ini, and restart Apache, it does not get changed in phpinfo()
Turns out, after compilation PHP would look for the ini file in /usr/local/lib rather than where I installed it despite
--with-config-file-path=PATH
Set the path in which to look for php.ini [PREFIX/lib]
To check it, you can run php --ini to see if the file has been read fine.
But now I'm seeing white screen when trying to load php files :)
Hope it helps.
I'm running a local server on my macbook (os x 10.9.2)
I'm trying to install mcrypt and I've run into a problem that I can't add the extension to my php.ini file, because apparently my php installation doesn't use a php.ini file.
Looking at phpinfo(), I see this:
Configuration File (php.ini) Path: /etc
Loaded Configuration File: (none)
In my /etc folder, a php.ini file doesn't exist. I do have a php.ini.default, but when I make a copy of that and name it php.ini, and restart apache, PHP just stops working entirely (my php code isn't interpreted and shows up when viewing the web site's source).
Is there something in the php.ini.default file I have to change before copying it to php.ini?
Edit: Upon further trial and error, I have found that if I create a blank php.ini file and restart the server, PHP runs just fine. There must be an error in php.ini.default that is killing PHP on my local server. I've tried using php.ini.default~orig too and the same problem happens. Any way to find out what is wrong with the php.ini.default file?
Edit2: Upon further random trial and error, if my php.ini only contains:
[PHP]
short_open_tag = On
PHP works. If it only contains:
[PHP]
short_open_tag = Off
PHP doesn't work. I'm so confused.
Edit3: Oh! The php.ini.default file had short_open_tag = Off, and of course I'm using short open tags everywhere. Edit2 clued me in. Wasted half a day on this. This is so embarrassing. Everything is working now.
In case someone else runs into the missing php.ini problem on OS X 10.9 or 10.10:
I ran into the same problem after trying install the latest php through homebrew. Turns out mac comes with php already installed, but no config file. Homebrew won't overwrite the system php binary, which remains the default.
Try sudo rm /usr/bin/php then brew install homebrew/php/php55.