php 7 support vsite

Discussion in 'Installation/Configuration' started by Steffan, Oct 4, 2016.

  1. Steffan

    Steffan Member

    Hello,

    i have enabling php7 for a vsite with php-fpm (php7 is a addition php version on the server
    when doing a phpinfo on that site i see the stocl php version (5.6)

    When looking in the config of the website i dont see php 7:


    <FilesMatch "\.php[345]?$">
    SetHandler php5-fcgi
    <FilesMatch "\.php[345]?$">
    SetHandler php5-fcgi
    Action php5-fcgi /php5-fcgi virtual
    Alias /php5-fcgi /var/www/clients/client126/web402/cgi-bin/php5-fcgi-*-80-xxx.nl
    FastCgiExternalServer /var/www/clients/client126/web402/cgi-bin/php5-fcgi-*-80-xxx.nl -idle-timeout 300 -host 127.0.0.1:9411 -pass-header Authorization
    #ProxyPassMatch ^/(.*\.php[345]?(/.*)?)$ fcgi://127.0.0.1:9411/var/www/clients/client126/web402/web/$1
    <FilesMatch "\.php[345]?$">
    <FilesMatch "\.php[345]?$">
    SetHandler php5-fcgi
    <FilesMatch "\.php[345]?$">
    SetHandler php5-fcgi
    Action php5-fcgi /php5-fcgi virtual
    Alias /php5-fcgi /var/www/clients/client126/web402/cgi-bin/php5-fcgi-*-443-xxx.nl
    FastCgiExternalServer /var/www/clients/client126/web402/cgi-bin/php5-fcgi-*-443-xxx.nl -idle-timeout 300 -host 127.0.0.1:9411 -pass-header Authorization
    #ProxyPassMatch ^/(.*\.php[345]?(/.*)?)$ fcgi://127.0.0.1:9411/var/www/clients/client126/web402/web/$1
    <FilesMatch "\.php[345]?$">
     
  2. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

    That config is fine, the 'php5' parts may be confusing, but they are just a name used in the apache config (and file pathnames) - maybe file an rfe to use generic names for the future? If you run `lsof -i :9411` you should see a php7 fpm daemon listening on that port; if you run phpinfo() through a script on the website it should say it's php7.
     
  3. Steffan

    Steffan Member

    hm
    lsof -i :9411
    is empty
    netstat -tulpn also no port 9411

    Path to the PHP-FPM init script: php70-php-fpm
    Path to the php.ini directory: /etc/opt/remi/php70
    Path to the PHP-FPM pool director: /etc/opt/remi/php70/php-fpm.d

    Path to the PHP FastCGI binary: /opt/remi/php70/root/usr/bin/php-cgi
    Path to the php.ini directory: etc/opt/remi/php70
     
  4. Steffan

    Steffan Member

    Oke php-fpm was not running :-(
    now the port is open.

    But when doing a phpinfo call in a file i still not see php7
    Configuration File (php.ini) Path /etc
    Loaded Configuration File /etc/php.ini
    Scan this dir for additional .ini files /etc/php.d
     
  5. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

    ie. you ran phpinfo() from through the website, not from cli? Go back and check the website settings and make absolutely sure it's set to php7. Check what php-fpm daemon is running on port 9411, maybe it actually is php5.6? (is php_fpm_BIN set correctly in your init file?)
     
  6. Steffan

    Steffan Member

    lsof -i :9411
    COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
    php-fpm 737 root 9u IPv4 1170004646 0t0 TCP localhost.localdomain:9411 (LISTEN)
    php-fpm 740 web402 0u IPv4 1170004646 0t0 TCP localhost.localdomain:9411 (LISTEN)

    ls -al /proc/740
    exe -> /opt/remi/php70/root/usr/sbin/php-fpm
    ==============
    When setting the site on php 7 i see:
    /etc/opt/remi/php70/php-fpm.d/web395.conf
    [web395]
    listen = 127.0.0.1:9404
    listen.allowed_clients = 127.0.0.1

    When setting the site on php 5.6 i see
    /etc/php-fpm.d/web395.conf
    [web395]
    listen = 127.0.0.1:9404
    listen.allowed_clients = 127.0.0.1

    ===================
    /etc/opt/remi/php70/php-fpm.d/www.conf: listen = 127.0.0.1:9007

    So looks like ispconfig is not changing the portnumber
    Any idees where to set this?

    ====
    just changed the settings to fast-cgi and then i see php7
    So something is wrong.
     
    Last edited: Oct 6, 2016
  7. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

    Each website uses a different port (or unix socket), but it's ok that the same port would be assigned to the site for a different php version as long as when you change it, the old php-fpm daemon stops listening on that port and the new php-fpm daemon starts listening there.

    And no, I don't remember where to set that :) I think, but may be wrong, that there was an option to use tcp ports or unix sockets; if you used ports you had the starting port number and ispconfig would automatically add one to that for each site it configured. I might try to find that again but really need to get a new test server setup, as our one ispconfig installation is starting to resemble a production system. :)
     
  8. Steffan

    Steffan Member

    Thanks for the time you putting in to this, php-fpm is new for me.
    I changed both php-fpm version from listen to socket
    listen = /var/run/php-fpm/php5.sock
    and
    listen = /var/run/php7-fpm/php7.sock
    restarted apache and both php-fpm's
    change the site back to php-fpm php 7 version
    still i see php5 in the phpinfo on the website (trough the browser)
    If i look at the vsite... then again i see:

    Action php5-fcgi /php5-fcgi virtual
    Alias /php5-fcgi /var/www/clients/client120/web395/cgi-bin/php5-fcgi-*-80-xxxxx.nl
    FastCgiExternalServer /var/www/clients/client120/web395/cgi-bin/php5-fcgi-*-80-xxxx.nl -idle-timeout 300 -host 127.0.0.1:9404 -pass-header Authorization
    <Directory /var/www/clients/client120/web395/web>
    <FilesMatch "\.php[345]?$">
    SetHandler "proxy:fcgi://127.0.0.1:9404"
    </FilesMatch>
    </Directory>

    if i change it to php5 a see the same settings in the vsite.
    Can there anything stupid that i forget to set on someplace?
    ====================================================
    lsof -i :9404
    COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
    php-fpm 30880 root 9u IPv4 1221395537 0t0 TCP localhost.localdomain:9404 (LISTEN)
    php-fpm 30881 web395 0u IPv4 1221395537 0t0 TCP localhost.localdomain:9404 (LISTEN)
    php-fpm 30882 web395 0u IPv4 1221395537 0t0 TCP localhost.localdomain:9404 (LISTEN)

    localhost.localdomain:9404 is that correct? or should that be the website name?

    ps aux | grep 30881
    web395 25440 0.0 0.0 403092 4764 ? S 19:17 0:00 php-fpm: pool web395

    ps aux | grep 30881
    root 3279 0.0 0.0 6444 708 pts/0 S+ 19:27 0:00 grep 30881
    web395 30881 0.0 0.0 403092 4756 ? S 19:22 0:00 php-fpm: pool web395

    ps aux | grep php-fpm
    root 30739 0.0 0.0 463504 9284 ? Ss 19:22 0:00 php-fpm: master process (/etc/php-fpm.conf)
    apache 30740 0.0 0.0 463504 0 ? S 19:22 0:00 php-fpm: pool www
    apache 30741 0.0 0.0 463504 0 ? S 19:22 0:00 php-fpm: pool www
    apache 30742 0.0 0.0 463504 0 ? S 19:22 0:00 php-fpm: pool www
    apache 30743 0.0 0.0 463504 0 ? S 19:22 0:00 php-fpm: pool www
    apache 30744 0.0 0.0 463504 0 ? S 19:22 0:00 php-fpm: pool www
    root 30880 0.0 0.0 403780 5816 ? Ss 19:22 0:00 php-fpm: master process (/etc/opt/remi/php70/php-fpm.conf)
    web395 30881 0.0 0.0 403092 4756 ? S 19:22 0:00 php-fpm: pool web395
    web395 30882 0.0 0.0 403092 4756 ? S 19:22 0:00 php-fpm: pool web395
    web402 30883 0.0 0.0 403092 4756 ? S 19:22 0:00 php-fpm: pool web402
    web402 30884 0.0 0.0 403092 4756 ? S 19:22 0:00 php-fpm: pool web402
    web410 30885 0.0 0.0 403092 4808 ? S 19:22 0:00 php-fpm: pool web410
    web410 30886 0.0 0.0 403092 4808 ? S 19:22 0:00 php-fpm: pool web410
    web457 30888 0.0 0.0 403092 4760 ? S 19:22 0:00 php-fpm: pool web457
    web457 30889 0.0 0.0 403092 4760 ? S 19:22 0:00 php-fpm: pool web457
    web613 30890 0.0 0.0 403092 4760 ? S 19:22 0:00 php-fpm: pool web613
    web613 30891 0.0 0.0 403092 4760 ? S 19:22 0:00 php-fpm: pool web613
    web614 30892 0.0 0.0 403092 4760 ? S 19:22 0:00 php-fpm: pool web614
    web614 30893 0.0 0.0 403092 4760 ? S 19:22 0:00 php-fpm: pool web614
    web621 30894 0.0 0.0 403092 4760 ? S 19:22 0:00 php-fpm: pool web621
    web621 30895 0.0 0.0 403092 4760 ? S 19:22 0:00 php-fpm: pool web621
    web626 30896 0.0 0.0 403092 4760 ? S 19:22 0:00 php-fpm: pool web626
    web626 30897 0.0 0.0 403092 4760 ? S 19:22 0:00 php-fpm: pool web626
    web627 30898 0.0 0.0 403092 4760 ? S 19:22 0:00 php-fpm: pool web627
    web627 30899 0.0 0.0 403092 4760 ? S 19:22 0:00 php-fpm: pool web627
    apache 30900 0.0 0.0 403252 0 ? S 19:22 0:00 php-fpm: pool www
    apache 30901 0.0 0.0 403252 0 ? S 19:22 0:00 php-fpm: pool www
    apache 30902 0.0 0.0 403252 0 ? S 19:22 0:00 php-fpm: pool www
    apache 30903 0.0 0.0 403252 0 ? S 19:22 0:00 php-fpm: pool www
    apache 30904 0.0 0.0 403252 0 ? S 19:22 0:00 php-fpm: pool www

    =======================================================

    fast cgi is working fine for php7
    on a dedicated server what is better fotr my customers and server :) ?
    i have a lot of costumers running wordpress and joomla
     
  9. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

    I think that just affects a default config/instance; each website then gets its own config section pointing to a per-site socket (yours is using a tcp socket, ours is using a unix socket, and I don't see how to configure it to use one vs. the other).

    That's ok for what socket the website uses, what matters is which php-fpm daemon is listening on that socket. If switching php versions doesn't change what phpinfo reports, either there's a problem with your init scripts so that the daemons don't get reloaded with a new config, or maybe something is holding up all changes from taking place, eg. maybe an error in a website so that apache's config check fails.

    That's fine, the php-fpm daemon is listening on the loopback interface, which is what you want.

    That shows that pids 30881/30882 are php7 - are you sure you got accurate phpinfo output when you said it was php5? Eg. you had waited long enough for the change to take effect (a minute, but wait 2 or 3 to be safe) and that the reply wasn't cached (I don't think I've ever seen that with phpinfo() output, but...)?

    Probably depends on what "better" means; I'm using a variety of php versions/settings to test things and learn, but most of them I put on php-fpm in ondemand mode, which uses less resources (less processes sitting idle), and I would guess is probably what you mean by "better".
     
  10. Steffan

    Steffan Member

    i have found the one-line problem :)
    I needed to diable one line in /etc/httpd/conf.d/php-fpm.conf.

    thanxs for the support and the answers.
     

Share This Page