Change PHP Version

Discussion in 'General' started by vmbelizario, Oct 14, 2015.

  1. vmbelizario

    vmbelizario New Member

    Hi guys!
    i'm having a little issue with PHP Version. I followed this guide https://www.howtoforge.com/how-to-u...p-fpm-and-fastcgi-with-ispconfig-3-centos-6.3 and sucefully installed PHP 5.3 and PHP 5.5 in my server (Centos 7 + Nginx). I have configured the others 2 versions in ISPConfig panel, and the only problem is : When i change the version for website example.com , click in save button, the website example.com give me 502 Bad Gateway error. The logs inside /var/www/example.com/log/error.log say :
    connect() to unix:/var/lib/php5-fpm/web1.sock failed (2: No such file or directory) while connecting to upstream.
    BUT, if i restart the server or just restart the php services :
    systemctl restart php-fpm
    /etc/init.d/php-5.5.13-fpm restart
    /etc/init.d/php-5.3.22-fpm restart
    and test, the website works again great with the version i choose. (I use a info.php to check).
    Someone know what is this issue ? How can we fix it or just configure ISPConfig to restart the services when i change a website PHP Version ?

    Thank very much !
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

  3. vmbelizario

    vmbelizario New Member

    Till,
    Thanks so much.
    Can we do some of the options to solve this ?
    "Option4: ignore CentOS7-"patch". Since CentOS7+ can still handle initd scripts if properly configured, there is actually no need to handle CentOS seperately. Just use the initd scripts."
    Look like easy, right ?
    Maybe if we found what sh script / php script ISPconfig calls when we change a PHP Version, we can just edit and put the commands to restart the 3 services. I'm wrong ?

    Thanks again !
     
  4. Seiya Kou

    Seiya Kou New Member

    New Installation on Debian 9 with PHP 7.0 (Defaul) and PHP 5.6.37 , still the sane problems "Bad Gateway" when switch from PHP 7 to 5 and back. Manually restart of PHP 5 and 7 is working.
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    Maybe you started the php-fpm daemon in a wrong way? Ensure that you use systemctl command to start / stop / restart a php-fpm daemon , don't use a init script, if you have one. When a daemon is started with an init script while the system is using systemd in general, then systemd is not able to restart the daemon and as ISPConfig uses systemd if installed, ispconfig must fail to restart the daemon then as well. Plus, ensure that all additional PHP versions have a www.conf pool file
     
  6. Seiya Kou

    Seiya Kou New Member

    Thanks, I really appreciate it.
     
  7. Seiya Kou

    Seiya Kou New Member

    I've got straight away with this tutorial for Debian 9, Nginx and PHP 5.6 , there is no www.conf in this documentation. Is this outdated? Howtoforge tutorial - "How to install PHP 7.1, 7.2 and 5.6 as PHP-FPM & FastCGI for ISPConfig 3 on Debian 9"

    It seems after switch the website from default (7.0) to php 5.6 the web1.conf are be moved correctly from /etc/php/7.0/fpm/pool . d/ to /opt/php-5.6/etc/php-fpm . d
    - but the web1.conf is listen on web1 . sock instead of the localhost 8997


    #head /opt/php-5.6/etc/php-fpm.d/web1 . conf
    listen = /var/lib/php7.0-fpm/web1 . sock

    Other changes are made like in the tutorial for 5.6 only in the php-fpm . conf , there are no www . conf for PHP 5.6 in the php-fpm . d

    Netstat shows up php 5.6 on the port defined in php-fpm . conf
    #netstat -tulpn |grep php
    tcp 0 0 127.0.0.1 : 8997 0.0.0.0:* LISTEN 297/php-fpm: master

    Systemd init Script are set like in the conf, are some changes in debian 9?
    # cat php-5.6-fpm . service
    [Unit]
    Description=The PHP 5.6 FastCGI Process Manager
    After=network . target

    [Service]
    Type=simple
    PIDFile=/opt/php-5.6/var/run/php-fpm . pid
    ExecStart=/opt/php-5.6/sbin/php-fpm --nodaemonize --fpm-config /opt/php-5.6/etc/php-fpm . conf
    ExecReload=/bin/kill -USR2 $MAINPID

    [Install]
    WantedBy=multi-user . target

    (the empty spaces are because i'm not allowed to post a "link" in this board)
    Thank you, Seiya
     
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    Both guides you referred to are up to date, so if you followed them to the letter the system setup is ok. What remains then is that yoi might have used an init script to start PHP instead of systemd.

    That's as it should be. Port 8997 is a pool run under the www-data user, this is not used for any site that you add in ISPConfig.
     
  9. Seiya Kou

    Seiya Kou New Member

    Thank you! I've found something that helped me. Now i can switched between PHP Versions.
    Had to set the listen.owner, group and mode.

    File: /opt/php-5.6/etc/php-fpm.conf
    listen = 127.0.0.1:8997
    listen.owner = www-data
    listen.group = www-data
    listen.mode = 0660

    Best regards , Seiya
     

Share This Page