If you use mamp in cgi mode, to support opcache for instance if your page will take more than 30 seconds to load you get some error similar to
FastCGI: comm with server "/Applications/MAMP/fcgi-bin/php7.4.12.fcgi" aborted: idle timeout (30 sec)
How to increase that?
Solution No 1
Enable xdebug, xdebug is for debugging purposes and you might be in the process of debugging a couple of breakpoints and moving around for a couple of minutes does it make sense that your debugger after 30 seconds stops and tells you OH, well I have to go we can't do this anymore!
So that's why turning the xdebug works, but should you do it?
If you get stuck once in the development and want a fast workaround use xdebug, otherwise don't! Xdebug makes your request a lot slower and gives you a development environment equal to hell, don't ever use xdebug constantly!!! only when you need to debug.
Solution No 2
Add
-idle-timeout.First let's talk about this little nifty menu.
This will let you modify a
httpd.conffile, but where is it? Is it thehttpd.conffile that will actually be used? NO.This is just a file full of placeholders, mamp will replace the placeholders in this file and generate a new file and that file will be used at last.
Knowing that was very important since we are going to see the actual output and see how we can edit that to add
idle-timeoutsupport.Step 1. Find the generated file
The generated
httpd.conffile is somewhere in your computer, you have to find it first if you are on Linux or MacOS you can useI have a MacOS and I found that it was at
At the top of this file you will read that it is auto-generated by Mamp Pro.
Step 2. Find the section about fastcgi in the generated output
Now in this file look for
mod_fastcgi.cyou will find something like:Step 3. add idle-timeout to FastCgiServer lines from generated file
That is great now all we need to do is to add the
-idle-timeout numbereg:-idle-timeout 3600at the end of lines that start with FastCgiServer, so in this example we need to change it to the following (But DON'T! because this is the generated file just keep reading)Remember that this is the generated file! in order to achieve this, we must modify the source file not this one, so let's just write it down somewhere so we can add it to the source file in the next step.
Step 4. Put the lines we wrote inside the source file of httpd.conf
Using the Mamp Pro menu we open the source
httpd.conffile, again we search formod_fastcgi.cthis time we'll find
Matching this to the output, you'll see that
MAMP_FastCgiServer_MAMPis the placeholder that gets replaced by FastCgiServer lines! So let's get rid of this placeholder and we'll add those lines ourselves here, in order to do this change the placeholder name slightly eg to:# M#A#M#P_FastCgiServer_MAMPand add the FastCgiServer lines withidle-timeoutunder or above it eg:So the full section became
Step 5. Test our changes by checking the new generated file
Save that restart the servers and look at the generated file
The operation was successful, if you changed your php versions just put the placeholder back-on, and repeat these steps.