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!

How to set Mod_Sed in cPanel

Discussion in 'Security' started by Secmas, Aug 16, 2011.

  1. Secmas

    Secmas Well-Known Member

    Joined:
    Feb 18, 2005
    Messages:
    330
    Likes Received:
    1
    Trophy Points:
    168
    Hi,
    what is the best way to install Mod_Sed in cPanel?

    Sergio
     
  2. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,609
    Likes Received:
    32
    Trophy Points:
    238
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Hello Sergio,

    In WHM > Software > EasyApache (Apache Update) > 5. Short Options List and selecting Mod Security, then choosing "Save and Build" in that area.

    Otherwise, in root SSH running /scripts/easyapache and selecting Mod Security in the Short Options list, then again choosing "Save and Build" in command line.

    Thanks!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. Secmas

    Secmas Well-Known Member

    Joined:
    Feb 18, 2005
    Messages:
    330
    Likes Received:
    1
    Trophy Points:
    168
    Hello cPanelTristan,
    do you mean that Mod_Sed is part of Mod Security and it is already installed if mod security is?
     
  4. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,609
    Likes Received:
    32
    Trophy Points:
    238
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Sorry, it's early yet. I was reading it as Mod_Sec not Mod_Sed. I apologize for the erroneous information there. I'm trying to determine how precisely mod_sed would be installed. Please provide your OS version and architecture type:

    Code:
    uname -a
    cat /etc/redhat-release
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. Secmas

    Secmas Well-Known Member

    Joined:
    Feb 18, 2005
    Messages:
    330
    Likes Received:
    1
    Trophy Points:
    168
    # uname -a
    Linux myserver.com 2.6.18-274.el5PAE #1 SMP Fri Jul 8 17:59:09 EDT 2011 i686 i686 i386 GNU/Linux
    # cat /etc/redhat-release
    Red Hat Enterprise Linux Server release 5.7 (Tikanga)
    #
     
  6. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,609
    Likes Received:
    32
    Trophy Points:
    238
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    All right, I got it to baseline install, although I don't know if it actually works:

    Code:
    cd /root
    wget wget http://src.opensolaris.org/source/raw/webstack/apache-modules/sed/mod_sed.tar.gz
    tar xzf mod_sed.tar.gz
    cd mod_sed
    apxs -c mod_sed.c sed0.c sed1.c regexp.c
    apxs -i -a mod_sed.la
    If you have any issues with the first apxs command, shorten it to "apxs -c mod_sed.c" initially, run the second apxs, then re-run the commands above after that. This will put the following LoadModule into /usr/local/apache/conf/httpd.conf file:

    Code:
    LoadModule sed_module         modules/mod_sed.so
    At that point, I suggest removing the module from httpd.conf and putting it as an include with these steps:

    Code:
    echo "LoadModule sed_module modules/mod_sed.so" >> /usr/local/apache/conf/includes/pre_main_global.conf
    cp /usr/local/apache/conf/httpd/conf /usr/local/apache/conf/httpd.conf.bak110818
    /usr/local/cpanel/bin/apache_conf_distiller --update
    /scripts/rebuildhttpdconf
    /etc/init.d/httpd restart
    Copy the mod_sed.so file to /root to save a copy of it, since future /scripts/easyapache recompiles will move the file out of /usr/local/apache/modules folder:

    Code:
    cp /usr/local/apache/modules/mod_sed.so /root
    Now, before you run /scripts/easyapache in the future, create these files:

    Code:
    vi /scripts/preeasyapache
    Place the following content into the file:

    Code:
    #!/bin/bash
    
    sed -i 's/LoadModule sed_module/#LoadModule sed_module/g' /usr/local/apache/conf/includes/pre_main_global.conf
    Next, create this file:

    Code:
    vi /scripts/posteasyapache
    Place the following content into the file:

    Code:
    #!/bin/bash
    
    cp /root/mod_sed.so /usr/local/apache/modules/
    sed -i 's/#LoadModule sed_module/LoadModule sed_module/g' /usr/local/apache/conf/includes/pre_main_global.conf
    /etc/init.d/httpd restart
    The first script comments out the LoadModule in /usr/local/apache/conf/includes/pre_main_global.conf at the beginning of the Apache build. The second script copies mod_sed.so back into /usr/local/apache/modules folder, uncomments the LoadModule, and restarts Apache at the end of the build.

    After saving these files, ensure they can execute:

    Code:
    chmod +x /scripts/preeasyapache
    chmod +x /scripts/posteasyapache
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. Secmas

    Secmas Well-Known Member

    Joined:
    Feb 18, 2005
    Messages:
    330
    Likes Received:
    1
    Trophy Points:
    168
    Thank you cPanelTristan,
    wonderful job on the instructions. I still in doubt if that is not too risky to set in a production server and not know if it will work.

    Any way I will try on the weekend just in case I do something wrong I will not affect anyone on the server.

    Best Regards,

    Sergio
     
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