Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Best Apache + PHP configuration for a fresh server?

Discussion in 'EasyApache' started by Razva, Apr 30, 2018.

  1. Razva

    Razva Member

    Joined:
    Aug 30, 2012
    Messages:
    15
    Likes Received:
    1
    Trophy Points:
    3
    cPanel Access Level:
    Root Administrator
    Hey,

    I'm currently deploying a fresh cPanel server (bare-metal). I don't need to migrate any old accounts so I can just have a fresh start.

    I would like to:
    • offer "modern stuff" like http/2, compression, amp etc
    • use php-fpm as much as possible
    • offer caching (memcache, opcache etc)
    • isolate users/threads while dropping suPHP
    • allow users to benefit from WordPress's auto-upgrade feature (so Apache should run each user's processes via user, similar with the old suPHP configs)
    • support PHP7x exclusively (so no 5x required)
    • not use CloudLinux (CentOS 7)
    • have a snappy/light&functional config, without installing a ton of legacy stuff
    The questions are:
    • What Apache MPM should I choose? Prefork doesn't allows http/2, right?
    • What Apache Modules should I choose?
    • What's the best/recommended caching method (memcache, opcache etc)?
    Thank you,
    Razva
     
  2. cPanelLauren

    cPanelLauren Forums Analyst
    Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    2,721
    Likes Received:
    186
    Trophy Points:
    143
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    Hello @Razva

    To answer your questions please see the following:

    Prefork does allow http/2 but it does come with restrictions. Please see apache's documentation on this here: HTTP/2 guide - Apache HTTP Server Version 2.5 but you'd probably be just as well off if you're using worker unless you need prefork for compatibility reasons

    We can't tell you all the apache modules you'll need but you might want to look up some for your specific needs though you will get a lot of these on a default cPanel installation but here are some other threads that go over this info:

    apache modules required

    And documentation on modules as well as default apache profiles that come with cPanel's EA4:
    Apache Modules - Easy Apache - cPanel Documentation


    I'm not sure if I can tell you which would be better for you since they serve somewhat different purposes but here is some further information on both opcache and memcache:

    Apache Module: MemCache - Easy Apache - cPanel Documentation
    PHP Extension: OPCache - Easy Apache - cPanel Documentation

    To Memcache or Not?
    Installing memcached on WHM server
    Installing memcache and memcached with EasyApache4


    Is "All PHP Options + OpCache" option safe to use?
    PHP-FPM and Opcache
    Configuring Opcache across multiple accounts
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. Razva

    Razva Member

    Joined:
    Aug 30, 2012
    Messages:
    15
    Likes Received:
    1
    Trophy Points:
    3
    cPanel Access Level:
    Root Administrator
    What "compatibility reasons" should I consider? Is there some user script/cms that might not work in a certain configuration, or we're talking about this?

    The question is basically about suPHP vs ruid vs "other cgi modes". I'm interested in something that offers caching + user isolation + scripts should be run under/for each user (needed for cms's auto-upgrade functions) + fpm.

    I've read a ton of stuff/docs and things got really "blurry" at this point. There's fpm and lsphp, there's ruid and workers and prefork and and and. Obviously a lot of stuff doesn't work with "the other stuff" so everything needs to be combined in an acceptable manner. Hence the subject of this thread.

    So again, my target is to:
    • run "modern" protocols (http/2 etc)
    • run "as much fpm as possible" as it has obvious speed/memory advantages
    • allow caching as this is vital for "everything 2018"
    • allow CMS auto-upgrades (so files written via apache/fpm should be owned by the user not by the daemon)
    • have a setup as secure as possible for a non-CloudLinux environment
    Thank you
     
  4. cPanelLauren

    cPanelLauren Forums Analyst
    Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    2,721
    Likes Received:
    186
    Trophy Points:
    143
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    Hi @Razva

    prefork is basically compatible with basically everything but in your case since you want to use http/2 due to the restrictions imposed I think you'd be better off with worker .
    From Apache:
    You can read about here: prefork - Apache HTTP Server Version 2.4

    You can also read the other MPM descriptions such as worker here worker - Apache HTTP Server Version 2.4

    I would suggest reading about them both, stackoverflow has some great discussions on the benefits and demerits of them both which I would suggest looking into.

    If you're going to be using CloudLinux the following goes over the most Optimal base EasyApache profiles for CloudLinux EasyApache Profile Stage - Easy Apache - cPanel Documentation - LSPHP wouldn't be a bad choice if you're going with CloudLinux as well. There's some wonderful information on LSPHP at Cloudlinux's docs here: CloudLinux Documentation

    I understand it's a lot of information and it can be daunting but we can't point to one configuration and say "that's the one" as a lot of it is going to depend on preference. You might also want to work with a system administrator to determine the best configuration for your content. If you don't have one you may find one here: Resources | cPanel Forums.

    Thank you,
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. Razva

    Razva Member

    Joined:
    Aug 30, 2012
    Messages:
    15
    Likes Received:
    1
    Trophy Points:
    3
    cPanel Access Level:
    Root Administrator
    As specified before I don't want to use CloudLinux, hence the questions about fpm/lsphp.

    The default cPanel install (after fresh install) has "nghttp2" (+libnghttp2). I couldn't find them on EA4. Any hints on this?

    Thanks
     
    #5 Razva, May 2, 2018
    Last edited: May 2, 2018
  6. cPanelLauren

    cPanelLauren Forums Analyst
    Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    2,721
    Likes Received:
    186
    Trophy Points:
    143
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    Hello

    Those are http/2 C library and tools they're necessary for the function of http/2:

    ea-nghttp2.x86_64 : Meta-package that only requires libnghttp2
    ea-libnghttp2.x86_64 : A library implementing the HTTP/2 protocol

    you can read about them here:
    Nghttp2: HTTP/2 C Library - nghttp2.org

    The actual http2 module is:

    ea-apache24-mod_http2.x86_64 : HTTP2 module for Apache HTTP Server

    You can use LSPHP without CloudLinux as well. They have instructions on how to install it on their site here: litespeed_wiki:cpanel:easyapache4-config [LiteSpeed Wiki]

    But keep in mind if you don't want CloudLinux you'll need to use Litespeed (LSWS) as the webserver in order to utilize lsphp (it can be installed but the only way it would be useful without CloudLinux is to use Litespeed)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. vlee

    vlee Well-Known Member

    Joined:
    Oct 13, 2005
    Messages:
    348
    Likes Received:
    23
    Trophy Points:
    168
    Location:
    Spokane, Washington
    cPanel Access Level:
    Root Administrator
    You also can use mod_mpm_event with http/2

    I run my server with mod_mpm_event with http/2

    event - Apache HTTP Server Version 2.4

    I have customized my servers in such as mod's and extensions in EasyApache and seem to work good.

    It is all up to you on what and how you want your servers to do.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    cPanelLauren likes this.
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice