[SOLVED] php-fpm dosn't work - apparently no errors

Discussion in 'Installation/Configuration' started by larieu, Jun 15, 2015.

  1. larieu

    larieu New Member

    I have several web domains which work with various PHP with fast cgi
    (5.3.24) (5.4.28) ( I have installed the fpm but never used)
    I have installed the server on CentOS 6 as in the following link
    https://www.howtoforge.com/perfect-...hp-pureftpd-postfix-dovecot-and-ispconfig3-p3
    and I followed this for multiple php verison
    https://www.howtoforge.com/how-to-u...p-fpm-and-fastcgi-with-ispconfig-3-centos-6.3

    Cent OS 6.6

    I have tried to set 5.4.42 as fpm
    install seems to be ok
    no error occurs
    if I enable the PHP-FPM in one site
    I can see the ports listening on appropriate ports
    tcp 0 0 127.0.0.1:9887 0.0.0.0:* LISTEN 40336/php-fpm
    tcp 0 0 127.0.0.1:8998 0.0.0.0:* LISTEN 40315/php-fpm
    tcp 0 0 127.0.0.1:8999 0.0.0.0:* LISTEN 17142/php-fpm
    tcp 0 0 127.0.0.1:9021 0.0.0.0:* LISTEN 40336/php-fpm​

    8999 - 5.3.24
    8998 - 5.4.28
    8997 - 5.4.42
    9021 - the test site
    and if I check the pool.d folder of the selected php version I find the adequate .conf for the website
    but if I put an php. information checker in the root of the site
    and access it I recieve info from default 5.3.3. which ships with the centOS
    1.
    if I set in ISPCONFIG the desired php handler - I receive in information.php
    fcgi default - 5.3.3
    fcgi 5.3.24 - 5.3.24
    fcgi 5.4.28 - 5.4.28
    fcgi 5.4.42 - 5.4.42
    fpm default - 5.3.3
    fpm 5.3.24 - 5.3.3 ?!?!?!?!
    fpm 5.4.28 - 5.3.3 ?!?!?!?!
    fpm 5.4.42 - 5.3.3 ?!?!?!?!

    mod-php - 5.3.3
    CGI - 5.3.3
    suPHP - 5.3.3

    the unexpected results for fpm

    I don't figure out what I'm doing wrong

    how can I track the problem?
    can anyone help
     
    Last edited: Jun 18, 2015
  2. larieu

    larieu New Member

    I have done several test

    I have created one small script ( inspired by http://www.thatsgeeky.com/2012/02/directly-connecting-to-php-fpm/ )
    Code:
    #!/usr/bin/perl -w
    use strict;
    my $fpm = $ARGV[0];
    my $url = $ARGV[1];
    if (!defined $fpm || !defined $url ){
        print "Usage: $0 host:port|path/to/socket /path/to/file \n";
        exit 1;
    }
    if($url =~ /^((?:\/.*)?(\/[^?]*))(?:\?(.*))?$/) {
        $ENV{REQUEST_METHOD}='GET';
        $ENV{SCRIPT_FILENAME}= $1;
        $ENV{SCRIPT_NAME}= $2;
        $ENV{QUERY_STRING}= $3 // '';
    }
    system ('cgi-fcgi', '-bind', '-connect', $fpm);
    you'll need to install fcgi to work

    now knowing that
    php-fpm 4.3.24 is on port 8999
    php-fpm 4.4.28 is on port 8998
    php-fpm 4.4.42 is on port 8997

    and that the website open on port 9021

    I tested each one
    Code:
    ./fcgi.pl localhost:8999 /status
    which returned :
    Primary script unknown
    Status: 404 Not Found
    X-Powered-By: PHP/5.3.24
    Content-type: text/html

    Code:
    ./fcgi.pl localhost:8998 /status
    which returned :
    Primary script unknown
    Status: 404 Not Found
    X-Powered-By: PHP/5.4.28
    Content-type: text/html

    Code:
    ./fcgi.pl localhost:8997 /status
    which returned :
    Primary script unknown
    Status: 404 Not Found
    X-Powered-By: PHP/5.4.42
    Content-type: text/html


    Code:
    ./fcgi.pl localhost:9021 /status
    which returned :
    Primary script unknown
    Status: 404 Not Found
    X-Powered-By: PHP/5.4.28
    Content-type: text/html

    which confirm that the install seems to be Ok
    but why ISPCONFIG3 doesn't make the link between the website and this interpreter?
     
  3. till

    till Super Moderator Staff Member ISPConfig Developer

    Take a look at the genereted vhost file to see if the correct fpm interpreter is set there.
     
  4. larieu

    larieu New Member

    I have chosen in ISPCONFIG
    PHP_FPM
    version 5.4.28
    this is the vhost config
    if I'll set FAST-CGI
    version 5.4.28
    this is the config
     
  5. larieu

    larieu New Member

    as we can see it is quite different
    but I am not able to pinpoint the problem
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    You said that php as fpm is not working but you posted a fastcgi config vs. a fpm config. Comparing a fastcgi config with a fpm config makes not much sense as they are different off course.

    Please post the config file of a website where you enabled a custom php-fpm version that is not working.
     
  7. larieu

    larieu New Member

    As I told
    I have no PHP-FPM working on the server - I have set up for 5.4.28 and 5.4.42

    ok
    I'll take in considerations another ones
    please tell me which one make sense to post here ( or to compare between them)
    this are my options for PHP
    1. Disabled
    2. FAST-CGI
    2.1. Default
    2.2. PHP-5.3.28
    2.3. PHP-5.4.28
    2.4. PHP-5.4.42
    3. CGI
    4. MOD-PHP
    5. SuPHP
    6. PHP-FRM
    6.1. Default
    6.2. PHP-5.3.28
    6.3. PHP-5.4.28
    6.4. PHP-5.4.42
    for the moment I'll compare
    points 6.1~6.4 between them
    please confirm that after you save in ISPCONFIG you'll need a delay abut 5 min until the changes are applied ( this is what I have noticed)
    I'll come back with differences (if any) between 6.x
     
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    Please post the config file of a website where you enabled a custom php-fpm version that is not working. The differences does not matter as I posted above, just pst a vhost config file of a non working php-fpm version.

    The delay is 60 seconds and not 5 minutes as the cronjob is run once a minute.
     
  9. larieu

    larieu New Member

    ok
    it was posted previous
    What I have noticed is that no mater which version I chose the vhost file is the same for that vhost ( I can notice that only the modified time is changing after each save)
    this is for not working PHP-FRM 5.4.28 - but is teh same for any other option in PHP-FRM
     
    Last edited: Jun 19, 2015
  10. larieu

    larieu New Member

    Should I raise a bug against ISPCONFIG for this unintended behaviour?
    I expect that the .vhost file should be different for each kind of PHP-FRM I select in interface
    as long as ISPCONFIG create the same file for all it should be a bug - correct?
     
  11. till

    till Super Moderator Staff Member ISPConfig Developer

    The config file changes correctly here in ISPCOnfig 3.0.5.4p8 on my servers, so what we have here is a config issue on your server and not a bug in ISPConfig.

    Are there any files with .err ending in the sites-enabled folder?
     
  12. larieu

    larieu New Member

    No - no files with .err

    this is the working FAST-CGI
    Code:
    <Directory /var/www/catalog.generic.tld>
            AllowOverride None
                    Order Deny,Allow
            Deny from all
            </Directory>
    
    <VirtualHost *:80>
                        DocumentRoot /var/www/catalog.generic.tld/web
               
            ServerName catalog.generic.tld
            ServerAlias allias.tld
            ServerAdmin webmaster@catalog.generic.tld
    
            ErrorLog /var/log/ispconfig/httpd/catalog.generic.tld/error.log
    
            Alias /error/ "/var/www/catalog.generic.tld/web/error/"
            ErrorDocument 400 /error/400.html
            ErrorDocument 401 /error/401.html
            ErrorDocument 403 /error/403.html
            ErrorDocument 404 /error/404.html
            ErrorDocument 405 /error/405.html
            ErrorDocument 500 /error/500.html
            ErrorDocument 502 /error/502.html
            ErrorDocument 503 /error/503.html
    
            <IfModule mod_ssl.c>
            </IfModule>
    
            <Directory /var/www/catalog.generic.tld/web>
                    # Clear PHP settings of this website
                    <FilesMatch ".+\.ph(p[345]?|t|tml)$">
                            SetHandler None
                    </FilesMatch>
                    Options +FollowSymLinks
                    AllowOverride All
                                    Order allow,deny
                    Allow from all
                            </Directory>
            <Directory /var/www/clients/client1/web1/web>
                    # Clear PHP settings of this website
                    <FilesMatch ".+\.ph(p[345]?|t|tml)$">
                            SetHandler None
                    </FilesMatch>
                    Options +FollowSymLinks
                    AllowOverride All
                                    Order allow,deny
                    Allow from all
                            </Directory>
    
    
    
    
            # cgi enabled
        <Directory /var/www/clients/client1/web1/cgi-bin>
                            Order allow,deny
                Allow from all
                        </Directory>
            ScriptAlias  /cgi-bin/ /var/www/clients/client1/web1/cgi-bin/
            <FilesMatch "\.(cgi|pl)$">
                SetHandler cgi-script
            </FilesMatch>
            # php as fast-cgi enabled
        # For config options see: http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html
            <IfModule mod_fcgid.c>
                    FcgidIdleTimeout 300
                    FcgidProcessLifeTime 3600
                    # FcgidMaxProcesses 1000
                    FcgidMaxRequestsPerProcess 5000
                    FcgidMinProcessesPerClass 0
                    FcgidMaxProcessesPerClass 10
                    FcgidConnectTimeout 3
                    FcgidIOTimeout 600
                    FcgidBusyTimeout 3600
                    FcgidMaxRequestLen 1073741824
            </IfModule>
            <Directory /var/www/catalog.generic.tld/web>
                    <FilesMatch "\.php[345]?$">
                        SetHandler fcgid-script
                    </FilesMatch>
                    FCGIWrapper /var/www/php-fcgi-scripts/web1/.php-fcgi-starter .php
                    FCGIWrapper /var/www/php-fcgi-scripts/web1/.php-fcgi-starter .php3
                    FCGIWrapper /var/www/php-fcgi-scripts/web1/.php-fcgi-starter .php4
                    FCGIWrapper /var/www/php-fcgi-scripts/web1/.php-fcgi-starter .php5
                    Options +ExecCGI
                    AllowOverride All
                                    Order allow,deny
                    Allow from all
                            </Directory>
            <Directory /var/www/clients/client1/web1/web>
                    <FilesMatch "\.php[345]?$">
                        SetHandler fcgid-script
                    </FilesMatch>
                    FCGIWrapper /var/www/php-fcgi-scripts/web1/.php-fcgi-starter .php
                    FCGIWrapper /var/www/php-fcgi-scripts/web1/.php-fcgi-starter .php3
                    FCGIWrapper /var/www/php-fcgi-scripts/web1/.php-fcgi-starter .php4
                    FCGIWrapper /var/www/php-fcgi-scripts/web1/.php-fcgi-starter .php5
                    Options +ExecCGI
                    AllowOverride All
                                    Order allow,deny
                    Allow from all
                            </Directory>
    
            RewriteEngine on
            RewriteCond %{HTTP_HOST} ^www\.allias\.tld$ [NC]
            RewriteRule ^(.*)$ http://allias.tld$1 [R=301,L]
    
            # add support for apache mpm_itk
            <IfModule mpm_itk_module>
                AssignUserId web1 client1
            </IfModule>
    
            <IfModule mod_dav_fs.c>
            # Do not execute PHP files in webdav directory
                <Directory /var/www/clients/client1/web1/webdav>
                    <ifModule mod_security2.c>
                        SecRuleRemoveById 960015
                        SecRuleRemoveById 960032
                    </ifModule>
                    <FilesMatch "\.ph(p3?|tml)$">
                        SetHandler None
                    </FilesMatch>
                </Directory>
                DavLockDB /var/www/clients/client1/web1/tmp/DavLock
                # DO NOT REMOVE THE COMMENTS!
                # IF YOU REMOVE THEM, WEBDAV WILL NOT WORK ANYMORE!
          # WEBDAV BEGIN
                # WEBDAV END
            </IfModule>
    
    php_admin_value open_basedir none
    php_admin_value max_execution_time 86400
    php_admin_value max_input_time 86400
    php_admin_value session.gc_maxlifetime 86400
    php_value session.gc_maxlifetime 86400
    php_value session.cookie_lifetime 86400
    php_admin_value session.cookie_lifetime 86400
    timeout 86400
    </VirtualHost>
    and this is the non working PHP_FPM

    Code:
    <Directory /var/www/catalog.generic.tld>
            AllowOverride None
                    Order Deny,Allow
            Deny from all
            </Directory>
    
    <VirtualHost *:80>
                        DocumentRoot /var/www/clients/client1/web1/web
               
            ServerName catalog.generic.tld
            ServerAlias allias.tld
            ServerAdmin webmaster@catalog.generic.tld
    
            ErrorLog /var/log/ispconfig/httpd/catalog.generic.tld/error.log
    
            Alias /error/ "/var/www/catalog.generic.tld/web/error/"
            ErrorDocument 400 /error/400.html
            ErrorDocument 401 /error/401.html
            ErrorDocument 403 /error/403.html
            ErrorDocument 404 /error/404.html
            ErrorDocument 405 /error/405.html
            ErrorDocument 500 /error/500.html
            ErrorDocument 502 /error/502.html
            ErrorDocument 503 /error/503.html
    
            <IfModule mod_ssl.c>
            </IfModule>
    
            <Directory /var/www/catalog.generic.tld/web>
                    # Clear PHP settings of this website
                    <FilesMatch ".+\.ph(p[345]?|t|tml)$">
                            SetHandler None
                    </FilesMatch>
                    Options +FollowSymLinks
                    AllowOverride All
                                    Order allow,deny
                    Allow from all
                            </Directory>
            <Directory /var/www/clients/client1/web1/web>
                    # Clear PHP settings of this website
                    <FilesMatch ".+\.ph(p[345]?|t|tml)$">
                            SetHandler None
                    </FilesMatch>
                    Options +FollowSymLinks
                    AllowOverride All
                                    Order allow,deny
                    Allow from all
                            </Directory>
    
    
    
    
            # cgi enabled
        <Directory /var/www/clients/client1/web1/cgi-bin>
                            Order allow,deny
                Allow from all
                        </Directory>
            ScriptAlias  /cgi-bin/ /var/www/clients/client1/web1/cgi-bin/
            <FilesMatch "\.(cgi|pl)$">
                SetHandler cgi-script
            </FilesMatch>
            <IfModule mod_fastcgi.c>
                    <Directory /var/www/clients/client1/web1/cgi-bin>
                                            Order allow,deny
                        Allow from all
                                        </Directory>
                    <Directory /var/www/catalog.generic.tld/web>
                        <FilesMatch "\.php[345]?$">
                            SetHandler php5-fcgi
                        </FilesMatch>
                    </Directory>
                    <Directory /var/www/clients/client1/web1/web>
                        <FilesMatch "\.php[345]?$">
                            SetHandler php5-fcgi
                        </FilesMatch>
                    </Directory>
                    Action php5-fcgi /php5-fcgi
                    Alias /php5-fcgi /var/www/clients/client1/web1/cgi-bin/php5-fcgi-*-80-catalog.generic.tld
                    FastCgiExternalServer /var/www/clients/client1/web1/cgi-bin/php5-fcgi-*-80-catalog.generic.tld -idle-timeout 300 -host 127.0.0.1:9010 -pass-header Authorization
            </IfModule>
            <IfModule mod_proxy_fcgi.c>
                ProxyPassMatch ^/(.*\.php[345]?(/.*)?)$ fcgi://127.0.0.1:9010/var/www/clients/client1/web1/web/$1
            </IfModule>
    
            RewriteEngine on
            RewriteCond %{HTTP_HOST} ^www\.allias\.tld$ [NC]
            RewriteRule ^(.*)$ http://allias.tld$1 [R=301,L]
    
            # add support for apache mpm_itk
            <IfModule mpm_itk_module>
                AssignUserId web1 client1
            </IfModule>
    
            <IfModule mod_dav_fs.c>
            # Do not execute PHP files in webdav directory
                <Directory /var/www/clients/client1/web1/webdav>
                    <ifModule mod_security2.c>
                        SecRuleRemoveById 960015
                        SecRuleRemoveById 960032
                    </ifModule>
                    <FilesMatch "\.ph(p3?|tml)$">
                        SetHandler None
                    </FilesMatch>
                </Directory>
                DavLockDB /var/www/clients/client1/web1/tmp/DavLock
                # DO NOT REMOVE THE COMMENTS!
                # IF YOU REMOVE THEM, WEBDAV WILL NOT WORK ANYMORE!
          # WEBDAV BEGIN
                # WEBDAV END
            </IfModule>
    
    php_admin_value open_basedir none
    php_admin_value max_execution_time 86400
    php_admin_value max_input_time 86400
    php_admin_value session.gc_maxlifetime 86400
    php_value session.gc_maxlifetime 86400
    php_value session.cookie_lifetime 86400
    php_admin_value session.cookie_lifetime 86400
    timeout 86400
    </VirtualHost>
    
     
  13. larieu

    larieu New Member

    I've done the following test

    1. new virtual machine
    2. install centos 6.7 minimal
    3. after first boot issued yum groupinstall 'Basic"
    4. then followed this tutorial "by letter"
    https://www.howtoforge.com/perfect-...l-php-pureftpd-postfix-dovecot-and-ispconfig3
    5. after all done added PHP-FPM 5.4.45 like here
    https://www.howtoforge.com/how-to-u...p-fpm-and-fastcgi-with-ispconfig-3-centos-6.3
    6. created one client, and one website
    set the server as PHP-FPM with the only one version available
    (
    not checked any of this CGI, SSI, Perl, Ruby, Python, SuEXEC
    on the options checked only Use Socket For PHP-FPM
    all the rest default
    )
    7. create the standard info.php file in the root of that web ( <?php phpinfo(); ?> )
    the version used by the website is 5.3.3 CGI !?!?!?!?!?!?!?!?

    8. compiled cgi same 5.4.45 and selected fot the same website - the inof show the correct 5.4.45 cgi

    and this is not an issue with ispconfig 3?

    then I tried again the same procedure on one "physical" machine (an old one)
    the result is the same cgi OK fpm NOT OK
    the generated config for the website is
    Code:
    <Directory /var/www/catalog.generic.tld>
            AllowOverride None
                    Order Deny,Allow
            Deny from all
            </Directory>
    
    <VirtualHost *:80>
                        DocumentRoot /var/www/clients/client1/web1/web
               
            ServerName catalog.generic.tld
            ServerAlias balarie.tld
            ServerAdmin webmaster@catalog.generic.tld
    
            ErrorLog /var/log/ispconfig/httpd/catalog.generic.tld/error.log
    
            Alias /error/ "/var/www/catalog.generic.tld/web/error/"
            ErrorDocument 400 /error/400.html
            ErrorDocument 401 /error/401.html
            ErrorDocument 403 /error/403.html
            ErrorDocument 404 /error/404.html
            ErrorDocument 405 /error/405.html
            ErrorDocument 500 /error/500.html
            ErrorDocument 502 /error/502.html
            ErrorDocument 503 /error/503.html
    
            <IfModule mod_ssl.c>
            </IfModule>
    
            <Directory /var/www/catalog.generic.tld/web>
                    # Clear PHP settings of this website
                    <FilesMatch ".+\.ph(p[345]?|t|tml)$">
                            SetHandler None
                    </FilesMatch>
                    Options +FollowSymLinks
                    AllowOverride All
                                    Order allow,deny
                    Allow from all
                            </Directory>
            <Directory /var/www/clients/client1/web1/web>
                    # Clear PHP settings of this website
                    <FilesMatch ".+\.ph(p[345]?|t|tml)$">
                            SetHandler None
                    </FilesMatch>
                    Options +FollowSymLinks
                    AllowOverride All
                                    Order allow,deny
                    Allow from all
                            </Directory>
    
    
    
    
            <IfModule mod_fastcgi.c>
                    <Directory /var/www/clients/client1/web1/cgi-bin>
                                            Order allow,deny
                        Allow from all
                                        </Directory>
                    <Directory /var/www/catalog.generic.tld/web>
                        <FilesMatch "\.php[345]?$">
                            SetHandler php5-fcgi
                        </FilesMatch>
                    </Directory>
                    <Directory /var/www/clients/client1/web1/web>
                        <FilesMatch "\.php[345]?$">
                            SetHandler php5-fcgi
                        </FilesMatch>
                    </Directory>
                    Action php5-fcgi /php5-fcgi
                    Alias /php5-fcgi /var/www/clients/client1/web1/cgi-bin/php5-fcgi-*-80-catalog.generic.tld
                    FastCgiExternalServer /var/www/clients/client1/web1/cgi-bin/php5-fcgi-*-80-catalog.generic.tld -idle-timeout 300 -host 127.0.0.1:9010 -pass-header Authorization
            </IfModule>
            <IfModule mod_proxy_fcgi.c>
                ProxyPassMatch ^/(.*\.php[345]?(/.*)?)$ fcgi://127.0.0.1:9010/var/www/clients/client1/web1/web/$1
            </IfModule>
    
            RewriteEngine on
            RewriteCond %{HTTP_HOST} ^www\.balarie\.tld$ [NC]
            RewriteRule ^(.*)$ http://balarie.tld$1 [R=301,L]
    
            # add support for apache mpm_itk
            <IfModule mpm_itk_module>
                AssignUserId web1 client1
            </IfModule>
    
            <IfModule mod_dav_fs.c>
            # Do not execute PHP files in webdav directory
                <Directory /var/www/clients/client1/web1/webdav>
                    <ifModule mod_security2.c>
                        SecRuleRemoveById 960015
                        SecRuleRemoveById 960032
                    </ifModule>
                    <FilesMatch "\.ph(p3?|tml)$">
                        SetHandler None
                    </FilesMatch>
                </Directory>
                DavLockDB /var/www/clients/client1/web1/tmp/DavLock
                # DO NOT REMOVE THE COMMENTS!
                # IF YOU REMOVE THEM, WEBDAV WILL NOT WORK ANYMORE!
          # WEBDAV BEGIN
                # WEBDAV END
            </IfModule>
    
    
    </VirtualHost>
     
  14. till

    till Super Moderator Staff Member ISPConfig Developer

    Check that
    mod_fastcgi is installed and enabled in apache. Don't mix up with
    mod_fcgi (which has to be installed as well).
     
  15. larieu

    larieu New Member

    of course it wasn't - it is not in any "perfect server" tutorial , nor in multiple PHP ones ( or I wasn't able to spot it)
    now it works

    for people needing the info
    - fast way to install in CentOS 6.7 /64
    bring the latest one (when I write this 2.4.6) and uncompress it
    Code:
    cd /opt/
    wget http://www.fastcgi.com/dist/mod_fastcgi-current.tar.gz
    tar -zxvf mod_fastcgi-current.tar.gz
    cd mod_fastcgi-2.4.6/
    
    select the apache2 make file
    Code:
    cp Makefile.AP2 Makefile
    and install it (for 64 - for 32 just set the appropriate path)
    Code:
    make top_dir=/usr/lib64/httpd
    make install top_dir=/usr/lib64/httpd
    
    then set the apache to load it
    Code:
    vi /etc/httpd/conf.d/mod_fastcgi.conf
    just add this in the file
    and restart apache
    Code:
    etc/init.d/httpd restart
     
  16. till

    till Super Moderator Staff Member ISPConfig Developer

    The current centos versions (7.x) don't need mod_fastcgi to run php-fpm, that's why you don't find it there and the outdated 6.x tutorials were written before ispconfig got php-fpm support at all.
     

Share This Page