Tuesday, May 19, 2015

PHP-FPM with Apache 2.2.22 and Ubuntu 12.10 - 500 Error, or returns text (not executing)

I am following this tutorial to try to install PHP-FPM on my LAMP stack.




My config in /etc/apache2/sites-available/default contains (as per the guide)




Alias /php5.fastcgi /var/www/fastcgi/php5.fastcgi
AddHandler php-script .php
FastCGIExternalServer /var/www/fastcgi/php5.fastcgi -socket /var/run/php-fpm.sock
Action php-script /php5.fastcgi virtual

# This part is not necessary to get it to work, but it stops anything else from being
# accessed from it by mistake or maliciously.


Order allow,deny

Order deny,allow





Which resulted in 500 errors. I checked the Apache log and am seeing:





(111)Connection refused: FastCGI: failed to connect to server
"/usr/lib/cgi-bin/php5-fcgi": connect() failed FastCGIExternalServer
/var/www/fastcgi/php5.fastcgi -socket /var/run/php-fpm.sock
FastCGI: incomplete headers (0 bytes) received from server "/usr/lib/cgi-bin/php5-fcgi"




I checked and realised my /etc/php5/fpm/pool.d/www.conf was listening on a different socket location (from the tutorial), so I updated the apache config to:



FastCGIExternalServer /var/www/fastcgi/php5.fastcgi -socket /var/run/php5-fpm.sock




But now visiting a php5 script just shows plain text.



I'm not sure where I'm going wrong here, can anyone point me in the right direction to troubleshooting this? Unfortunately everything I've found is very NGINX oriented (or the user just switched to NGINX entirely!) I am somewhat tied to Apache at the moment as I am relying on .htaccess for wordpress and permalink rewrites etc.



Endless thanks in advance.

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...