1

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)

<IfModule mod_fastcgi.c>
        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.
        <Directory "/var/www/fastcgi">
                Order allow,deny
                <Files "php5.fastcgi">
                        Order deny,allow
                </Files>
        </Directory>
</IfModule>

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.

2
  • you find a solution to this?
    – Ricalsin
    Apr 15, 2014 at 20:56
  • @Ricalsin Unfortunately not, it would be incredibly useful if I could as well... at the moment I have to do all sorts of crazy permissions to have things running properly while still being able to edit files from my own user account
    – waffl
    Apr 16, 2014 at 12:12

3 Answers 3

1

Try using the parameters -idle-timeout and -appConnTimeout in the FastCgiExternalServer in the httpd.conf. Check this out for the syntax

0

In case it helps... I had systematic 500 Internal Errors and had to struggle a lot to make php-fpm work with Apache and IPSCONFIG on a Ubuntu 14.04 LTS Trusty, build with Falko tutorial

This is my working PHP-FPM configuration:

  • /etc/php5/fpm/pool.d/www.conf

    user = www-data
    group = www-data
    listen.owner = www-data
    listen.group = www-data
    listen.mode = 0660
    listen = /var/run/php5-fpm.sock
    pm = dynamic
    pm.max_children = 10
    pm.start_servers = 4
    pm.min_spare_servers = 2
    pm.max_spare_servers = 6
    pm.max_requests = 2000
    pm.status_path = /fpm_status?full
    chdir = /
    
  • /etc/php5/fpm/php-fpm.conf

    pid = /var/run/php5-fpm.pid
    error_log = /var/log/php5-fpm.log
    include=/etc/php5/fpm/pool.d/*.conf
    
  • /etc/apache2/conf-enabled/php-fpm.conf

    <IfModule mod_fastcgi.c>
      Alias /php-fcgi /usr/lib/cgi-bin/php5
      AddHandler php .php
      Action php /php-fcgi
      FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -socket /var/run/php5-fpm.sock -pass-header Authorization -idle-timeout 3600
      <Directory /usr/lib/cgi-bin>
        AllowOverride All
        Options +ExecCGI +FollowSymLinks
        Require all granted
      </Directory>
    </IfModule>
    
  • I had to chmod 666 /var/run/php5-fpm.sock

  • Last, but this is specific to Ispconfig, when I set a website with PHP-FPM into IspConfig, it writes the following lines in its sites-enabled vhost :

    Alias /php5-fcgi ALIAS_PATH&NAME
    FastCgiExternalServer ALIAS_PATH&NAME -idle-timeout 300 -host 127.0.0.1:9016 -pass-header Authorization</code>
    

    I have to change -host 127.0.0.1:9016 to -socket /var/run/php5-fpm.sock, then it works.

Just don't know where IspConfig takes the wrong information from.

0

I've resolved this issue, on Ispconfig with ubuntu 14.XX, Apache and PHP-FPM usign just this:

chmod 666 /var/lib/php5-fpm/web104.sock

Where web104 is the instance for the hosting 'web104'.

Hope this helps!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .