Just let me state that I am new to FastCGI. I have MAMP's Apache on my OS X machine. Default PHP handler was Apache Handler 2.0
(libphp5.so). I wanted to change to FastCGI
and followed the answer here: How to configure Apache to run PHP as FastCGI on Ubuntu 12.04 via terminal?
I added the following at the end of my httpd.conf:
<IfModule mod_fastcgi.c>
AddHandler php5.fcgi .php
Action php5.fcgi /php5.fcgi
Alias /php5.fcgi /Applications/MAMP/fcgi-bin/php5.fcgi
FastCgiServer /Applications/MAMP/fcgi-bin/php5.fcgi -socket /Applications/MAMP/tmp/php-fcgi/php5-fpm.sock -pass-header Authorization -idle-timeout 3600
#FastCgiExternalServer /Applications/MAMP/fcgi-bin/php5.fcgi -socket /Applications/MAMP/tmp/php-fcgi/php5-fpm.sock -pass-header Authorization -idle-timeout 3600
<Directory /Applications/MAMP/fcgi-bin>
Order allow,deny
Allow from all
</Directory>
</IfModule>
However, as you can see, FastCgiExternalServer
is commented out. Instead, I had to use FastCgiServer
cause otherwise Apache was giving me the following errors when trying to request a page:
[Fri May 06 23:25:22 2016] [error] [client ::1] (2)No such file or directory: FastCGI: failed to connect to server "/Applications/MAMP/fcgi-bin/php5.fcgi": connect() failed
[Fri May 06 23:25:22 2016] [error] [client ::1] FastCGI: incomplete headers (0 bytes) received from server "/Applications/MAMP/fcgi-bin/php5.fcgi"
But /Applications/MAMP/fcgi-bin/php5.fcgi
exists and its content is:
#!/bin/bash
PHP_CGI=/Applications/MAMP/bin/php/php5.6.2/bin/php-cgi
exec $PHP_CGI
What's the difference between FastCgiServer
and FastCgiExternalServer
and why FastCgiExternalServer
didn't work in my case but FastCgiServer
worked?