Macbook pro: 10.9.3
Php: 5.4.25
Apache 2.2
I have downloaded php using homebrew along with mongodb. Everything is working fine but I can not seem to find the php.ini file that apache is using. I used the phpinfo() method and it is telling me that the loaded file is in etc/php.ini. Strange thing about that is my php.ini file is empty. The only line in this file is the extension directive for the mongodb driver. I have been searching for a while now using the usual methods such as php -i and phpinfo(). I have no idea how to configure my php. It must be loading default configurations from somewhere but I can not find where. Anyone have any clue to where it might be?
Installed MAMP on a new Macbook with PHP 5.5.3.
Reload and refresh do nothing. Still nothing. Google around for a few minutes trying to find out what is wrong, come back and refresh. It works. What the heck?
I went into php.ini and disabled all the new OPcache and set the default cache time to 0. Added headers to the document to force no caching. Still same problem. What the heck is going on here?
The network tab is showing a HTTP 200 request, so any new HTML in the index.php file renders fine, but new PHP that needs to be rendered by the server is delayed and not rendered until some predetermined set of time passes that I don't know how to change. What's going on?
I checked this in Safari too so it is definitely a server thing that is keeping the file from rendering.
Interesting fact though, if I go into MAMP and change the PHP version to the old one (PHP 5.2 or something) it will render normally, with no "caching issues". Switch to PHP 5.5 and it hangs up. In the MAMP preferences caching options for 5.5 don't even exist and are automatically disabled.
Disable OPCache
MAMP now turns on OPCache by default, you can disable it by editing your php.ini file. Make sure you edit the correct php.ini.
I was running into the same problem myself. MAMP with PHP version 5.5.3 runs OPcache by default, but you can't turn it off in the GUI like you can with the older PHP version 5.2.17. You have to manually comment out all the OPcache lines at the end of the php.ini file (MAMP/bin/php/[version]/conf/php.ini) and make sure to stop and start the servers for the changes to take effect.
I updated the URI, the changes can be reflective by also changing /conf/ under the php folder, but it seems MAMP will ignore these after restart.
I added opcache_reset(); in my main PHP to stop this caching.
Removing it from php5.5.3/conf/php.ini did nothing for me.
Edit
Turns out there also is a /Applications/MAMP/bin/php/php5.5.3/conf/php.ini. It
works if I comment it out there.
1) in /Applications/MAMP/bin/php/php5.5.3/conf/php.ini
2) set opcache.revalidate_freq=0
3) restart MAMP
Took me so long to figure out it was a MAMP problem! Why would OPcache be enabled by default-- and require php.ini tinkering to disable-- in an app that's supposed to be used for testing websites? Anyway, I read through this whole thread and tried the various solutions.
Here are my notes on how each solution works and considerations for selecting a solution.
Each solution works on its own; no need for redundancy.
Webpage code solution
opcache_reset();
<?php opcache_reset(); ?>
Must be added in the webpage code.
Forces all scripts to be reloaded.
Works without restarting MAMP server.
Server configuration solutions
Important: Use the php.ini file in /Applications/MAMP/bin/php/php5.5.3/conf/php.ini and not in
/Applications/MAMP/conf/php5.5.3/php.ini. Adjust accordingly if you're using a different version of PHP.
enable=0
[OPcache]
zend_extension="/Applications/MAMP/bin/php/php5.5.3/lib/php/extensions/no-debug-non-zts-20121212/opcache.so"
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=1
enable=0
Must be added under [OPcache] in php.ini.
Disables OPcache.
Requires MAMP server restart.
opcache.revalidate_freq=0
[OPcache]
zend_extension="/Applications/MAMP/bin/php/php5.5.3/lib/php/extensions/no-debug-non-zts-20121212/opcache.so"
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=0
opcache.fast_shutdown=1
opcache.enable_cli=1
Modify opcache.revalidate_freq under [OPcache] in php.ini.
Makes OPcache check for updates every 0 seconds instead of every 60 seconds.
Requires MAMP server restart.
Commenting out [OPcache]
;[OPcache]
;zend_extension="/Applications/MAMP/bin/php/php5.5.3/lib/php/extensions/no-debug-non-zts-20121212/opcache.so"
;opcache.memory_consumption=128
;opcache.interned_strings_buffer=8
;opcache.max_accelerated_files=4000
;opcache.revalidate_freq=60
;opcache.fast_shutdown=1
;opcache.enable_cli=1
Comment out the entire [OPcache] section in php.ini.
Removes OPcache from the PHP server.
Requires MAMP server restart.
Considerations
Choose the webpage code solution if:
You just need to force script refreshing for a particular project
You don't want to restart the MAMP server
You don't want to edit php.ini
Choose a server configuration solution if:
You want to disable caching by default instead of having to do it in every project
You're comfortable with editing php.ini
I personally prefer enable=0 since it's the simplest solution for me, and I need caching disabled by default.
References
http://php.net/manual/en/function.opcache-reset.php
http://php.net/manual/en/opcache.configuration.php
It looks like this is finally a GUI option. MAMP 3.0.7.2 for Mac OS X.
It was painful spending around 1 hour trying to figure out what could it be.
I just added this at the end of the code and restart MAMP.
opcache.revalidate_freq=0
opcache_reset();
Edit "/Applications/MAMP/conf/php5.5.3/php.ini", and search for [OPcache] and add this code under it directly:
opcache.enable=0
This will disable opcache in when use PHP in MAMP server.
Oh man am I glad I found this thread! I was pulling my hair out! I just upgraded MAMP yesterday and didn't notice this caching issue until today while working on a project. Thought I was losing my mind.
I just changed "/Applications/MAMP/conf/php5.5.3/php.ini" very bottom of file opcache.enable=0
This is also current in the Windows version of MAMP as well.
C:\MAMP\conf\php5.6.3\php.ini
It's listed at the very bottom of the file.
The other problem I found, was on a QNAP NAS TS-431. This caching is also enabled, and if you are working with dynamically changing files, or try to develop on it, you'll be ripping out your hair. As per the other comments, just comment it out. The setting is located in:
Control Panel/Applications/Web Server/PHP.ini Maintenance.
Once again, you'll find the settings at the bottom of the file.
For those using MAMP 6.x you have to disable the setting in the UI otherwise MAMP will overwrite your PHP files the next time you restart apache.
The setting is in the PHP setting as shown here:
Change the default OPcache setting to off and click Save. After saving restart the Apache service.
Open your Mamp panel
on the right top corner click "Preferences"
a pop will open ,there is a option to "off" the php cache.
It works like charm,No need to modify any other files.
I have a dedicated server and I'm facing a strange issue. I found there 2 php installations and only one must be used and is correct, which is version 5.2.6, but currently, I see on phpinfo that the php.ini is being loaded isn't the right configuration. The php.ini which I need the server use is located in /opt/php-5.2.6/config/php.ini and the current in use is located in /etc/php.ini. How to turn on the php located in /opt/php-5.2.6/ ? I don't know what happened, maybe after I tried to install the xCache extension, but didn't work and in some way that installation of xCache changed where the php is loaded from.
How to make loading the php which I have in directory /opt/php-5.2.6/ ?
Thanks.
You can make your apache to point to another php.ini using .htaccess file.
I am setting up PHP on Windows Server 2008 SP1 (64 bit). I have configured PHP 5.3.13 which I managed to find over here. I have configured it in IIS to use fastCGI. As an aside, the reason that I used PHP 5.3.13 and not 5.4.3 is because I have not been able to find the 5.4 binary for the extension php_win32service which we need.
The issue that I am encountering though is that the include_path configured in the php.ini is being totally ignored by PHP. I have confirmed that I am changing the correct php.ini by making changes to other settings in the ini and I see these changes when I echo phpinfo. My php.ini is defined in the C:\Windows folder. But no matter what I put as the include_path in the ini file I always see ".;C:\php\pear" shown for the include path by phpinfo.
The include path that I have in my ini is copied/pasted from the ini on another server that is configured and working correctly. The only differences between the new server and the previous one is that the new one is 64 bit and the new one is running PHP 5.3.13 with fastCGI (as opposed to 5.2.1 with ISAPI for the one that is working).
So does anyone know whether the fact that include_path is being ignored is a bug in version 5.3.13 or if this behaviour is by design for fastCGI? Is there some setting that I could change in the php.ini that would resolve this?
Ignore the false conclusion I came to in the comments, because I must admit that this issue was in fact caused by an error in my php.ini file, so it was all my fault. ;) At some point during the editing of the ini file I accidentally put a carriage return character in the middle of one of the comment lines. This caused the processing of the ini to be cut off half way at the point that the error was encountered. I discovered this after installing 5.4.3, because this version actually reported an exception and showed a 500 Server Error message in the browser.
So what did I learn from this? Always test your ini file by doing php -v from the command line. If I had of done that I would have seen the message about the error encountered during the parsing of the ini file. Lesson learnt. :)
Error - No PHP Executables defined
I am running Eclipse on OS X 10.6 with MAMP 1.9
Everything was working fine before. I created a new PHP file and now none of my files will run.
I reset my Eclipse Preferences - PHP Executables, to point to MAMP/bin/PHP5.3/bin
Then I got a lauch error - "The Session Could Not Be Started, in order to generate debug information, please makw sure that the debugger is properly configured as a php.ini directive."
A PHP Web Page launch opens a URL at a running server (usually your local server).
A PHP Script launch uses the CLI/CGI executable that you defined in your preferences.
It also uses the php.ini defined there, and from what I remember, it will try to locate the one next to the executable by default.
Sounds like the php.ini was not defined/located. Check that you have the ini in the directory you selected.
This ini should also have the right debugger directives and paths needed for the CLI/CGI debug session.
hope that helps
The problem was in my MAMP php.ini ( /Applications/MAMP/conf/php5.3 ). It turns out I needed to remove the ";" semi-colon from the beginning of the line with the path to xdebug.so.
Incorrect:
[xdebug]
;zend_extension="/Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"
Correct:
[xdebug]
zend_extension="/Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"
My MAMP php.ini file does not include a directive for the Zend Debugger. The above setting is for XDebug in the MAMP PHP 5.3 php.ini file. I did not have any directives for the Zend Debugger in my php.ini file. I may have removed them when I initially set this up over a year ago, then again maybe the Zend Debugger is not inlcuded with the MAMP installation. I would welcome confirmation on this and of course any additional insights are appreciated.
I have included some resources below for those experiencing problems with XDebug, Zend Debugger, MAMP, and Eclipse PDT setup and configuration:
This is the thread that helped me identify the problem, as well as instructions on how to confirm that Xdebug is running:
http://forum.mamp.info/viewtopic.php?f=6&t=9119&p=23143&hilit=eclipse+debug#p23143
This is from NetBeans Support, it is relevant and I think a good reference to bookmark:
http://netbeans.org/kb/docs/php/configure-php-environment-mac-os.html
I also found this documentation from DeveloperWorks to be helpful, particularly p.17 - 21 and p.30
PDF:
www.ibm.com/developerworks/opensource/tutorials/os-php-eclipse-pdt-debug/os-php-eclipse-pdt-debug-pdf.pdf
URL:
www.ibm.com/developerworks/opensource/tutorials/os-php-eclipse-pdt-debug/section4.html