Search code examples
apachecpanelcentos7cloudflareeasyapache-4

How to install mod_cloudflare for easyapache 4


I am trying to install mod_cloudflare for Apache using easyapache 4 on cPanel Server. I am running CentOS 7.2.

I have installed mod_cloudflare for EasyApache4 following the instructions under Option 2 here. After running the installer it said "Done. Please restart EasyApache 4". I then went into WHM -> EasyApache 4 and tried to find the server module, but it is not to be found. I clicked the "run system update" button and tried again, to no avail. Is there an easyapache service that needs to be restarted via the command line?

I am not a hosting provider so I have not tried the Cloudflare plugin for CPanel.

* Edit 4/9/2019 * Changing accepted answer to EasyCo's, as the original solution no longer works.


Solution

  • Figured I'd throw my solution into the mix using Centos 6.9 with WHM/cPanel.

    bash <(curl -s https://raw.githubusercontent.com/cloudflare/mod_cloudflare/master/EasyApache/installer.sh)
    wget https://raw.githubusercontent.com/cloudflare/mod_cloudflare/master/mod_cloudflare.c
    yum install ea-apache24-devel
    apxs -a -i -c mod_cloudflare.c
    rm /etc/apache2/conf.modules.d/mod_cloudflare.conf
    service httpd restart
    

    What's happening?

    1. We're using the cPanel installer.sh as suggested by Cloudflare but the compiled mod_cloudflare.so throws an error if you then run service httpd restart. Lets fix this.
    2. Download the source mod_cloudflare file.
    3. Ensure we have the correct EasyApache4 developer tools to build the mod_cloudflare module.
    4. Build and install extension module.
    5. Remove the new mod_cloudfare.conf file since we prefer the one that was generated and installed in step 1.
    6. Restart apache.

    Note: The mod_cloudflare module will not show in EasyApache4. You can see it's enabled by running httpd -M | grep cloudflare and you should see something like cloudflare_module (shared).

    References: