The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

php-fpm enable ssh command

Discussion in 'EasyApache' started by vacancy, Jan 24, 2017.

Tags:
  1. vacancy

    vacancy Well-Known Member

    Joined:
    Sep 20, 2012
    Messages:
    122
    Likes Received:
    11
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Hello there

    As we know, we need to select and enable sites that use php-fpm, which is quite difficult.

    What commands can we use to set the php version for all domains via ssh and enable php-fpm?

    We can php-fpm to newly opened sites by the commands to be used in this way to cron.
     
  2. sparek-3

    sparek-3 Well-Known Member

    Joined:
    Aug 10, 2002
    Messages:
    1,432
    Likes Received:
    30
    Trophy Points:
    178
    cPanel Access Level:
    Root Administrator
    It's not really that easy to do this. I agree with you that something needs to be done regarding this. But the way cPanel has this set up, it's just not that easy.

    You would have to do something like:

    Code:
    /usr/local/cpanel/bin/whmapi1 php_set_vhost_versions version=ea-php56 php_fpm=1 vhost-0=%domain%
    /usr/local/cpanel/bin/uapi --user=%user% LangPHP php_set_vhost_versions vhost=%domain% version=ea-php56
    Adjusting %domain% to the be the domain name (or the subdomain, or the addon domain ... you have to do it for each one, which makes this method a bit cumbersome).
    %user% to be the username of the account.
    ea-php56 is the PHP version (PHP 5.6 here, ea-php70 and ea-php71 are also options)

    You do have to have MultiPHP enabled in the feature list that %user% is using. Which probably isn't a big ordeal, but say you don't want your user to be able to change their PHP version or you have a reseller that doesn't enable MultiPHP for one of their feature lists... then you are out of luck.

    You can set up a series of hooks to do this, but you have to do this for every account that is create, every subdomain that is created, and every addon domain that is created. You also have to remove all of this for every addon domain that is removed and every subdomain that is removed, otherwise you'll gum up the PHP-FPM configs and PHP-FPM won't restart.


    There may be another way of doing this that doesn't involved uapi. I'm not aware of it. You can set up your own PHP-FPM pools outside of MultiPHP (a roll your own setup) and accomplish this. But you're deviating outside of cPanel's realm if you do this.
     
    vacancy likes this.
  3. vacancy

    vacancy Well-Known Member

    Joined:
    Sep 20, 2012
    Messages:
    122
    Likes Received:
    11
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Thank you for the information.

    I understand that this is not going to be easy.

    We will expect Cpanel to produce a solution for this issue.
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,037
    Likes Received:
    1,280
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
  5. bejbi

    bejbi Well-Known Member

    Joined:
    Jan 20, 2006
    Messages:
    94
    Likes Received:
    1
    Trophy Points:
    158
    Location:
    Poland
    cPanel Access Level:
    DataCenter Provider
    Thank You. Do You know how to detect hanging PHP version by user ? It could be helpfull to make some king of trigger to set FPM automatically again using API as You wrote.

    Wojtek
     
  6. sparek-3

    sparek-3 Well-Known Member

    Joined:
    Aug 10, 2002
    Messages:
    1,432
    Likes Received:
    30
    Trophy Points:
    178
    cPanel Access Level:
    Root Administrator
    Not that I know.

    The way I usually combat this is to enable all of the hook debugging:

    /usr/local/cpanel/bin/whmapi1 set_tweaksetting key=debughooks value=logall

    Then leave a running tail of the /usr/local/cpanel/logs/error_log

    tail -f /usr/local/cpanel/logs/error_log

    Then log into a cPanel and perform the action you are wanting to hook. Watch the tailing error_log to see if a hookable event comes up.

    Then write the hook for it.

    It helps if you can do this on a test server or at least a nonbusy server. The error_log is going to fill up pretty fast with all of this debugging information. You might be able to use just logdata instead of logall. logall is going to give a lot of information, but more information is generally what I am after.

    Turn off hook debugging with:

    /usr/local/cpanel/bin/whmapi1 set_tweaksetting key=debughooks value=0
     
    bejbi likes this.
Loading...

Share This Page