kasparsd / php-7-debian

Install PHP 7 on Debian/Ubuntu
349 stars 103 forks source link

PHP-FPM Failed to connect to FastCGI server #49

Closed Tahiche closed 7 years ago

Tahiche commented 7 years ago

I was getting an error "Permission denied: FastCGI: failed to connect to server "/usr/lib/cgi-bin/php.fcgi": connect() failed" when setting up php7-fpm with Apache2

Solved using directions here: "https://stackoverflow.com/a/25418157/5815000"

listen.owner = www-data
listen.group = www-data
listen.mode = 066

Also had to change "listen" to set a sock instead of port. Here´s what worked out for me:

/etc/apache2/conf-available/php-fpm.conf (had to create dir /run/php/ )

<IfModule mod_fastcgi.c>
   AddHandler php.fcgi .php
   Action php.fcgi /php.fcgi
   Alias /php.fcgi /usr/lib/cgi-bin/php.fcgi
   FastCgiExternalServer /usr/lib/cgi-bin/php.fcgi -socket /run/php/php-fpm.sock -pass-header Authorization -idle-timeout 3600
   <Directory /usr/lib/cgi-bin>
       Require all granted
   </Directory>
</IfModule>

/usr/local/php7/etc/php-fpm.d/www.conf

[www]

user = www-data
group = www-data

listen.owner = www-data
listen.group = www-data
listen.mode = 0660

;listen = 127.0.0.1:9007
listen = /run/php/php-fpm.sock
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3

Hope it helps someone.

kasparsd commented 7 years ago

Thanks for sharing this @Tahiche!

olbe157d commented 1 year ago

This solved the issue for me.