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.

EA3 to EA4 - Permanent httpd.conf Changes

Discussion in 'EasyApache' started by Jim_WHM, Jan 29, 2017.

  1. Jim_WHM

    Jim_WHM Member

    Joined:
    Jun 12, 2014
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    These are old threads of mine where I described how i wanted to permanently change the httpd.conf file to add system-wide mime types to make an .aspx file be ran as a php file and also get rid of the mysite.tld/whm and mysite.tld/cpanel shortcuts.

    System-Wide Apache Handler and MIME Types

    Disable mysite.tld/whm And mysite.tld/cpanel Shortcuts?

    I am now migrating to a EA4 server from and EA3 server and I want to know if the process is still the same. What i did before on my EA3 server was this:


    - Logged into SSH with root changed dir to /var/cpanel/templates/apache2_4
    - cp main.default main.local
    - vim main.local and did vim search for 'main.mainifmodulemimemodule.item.ifmodule'
    - found it. and edited the block to look like this:
    <IfModule [% main.mainifmodulemimemodule.item.ifmodule %]>
    TypesConfig [% main.ifmodulemimemodule.typesconfig.item.typesconfig %]
    [% FOREACH dir IN main.ifmodulemimemodule.addtype.items -%]
    AddType [% dir.mime %] [% dir.extension %]
    [% END -%]
    AddType application/x-httpd-php5 .aspx

    </IfModule>

    - vim searched for "main.scriptaliasmatch.items" AND REMOVED THESE 3 LINES from the main.local file:
    [% FOREACH dir IN main.scriptaliasmatch.items -%]
    ScriptAliasMatch [% dir.regex %] [% dir.path %]
    [% END -%]

    - saved and quit vim
    - ran '/scripts/rebuildhttpdconf' by just typing '/scripts/rebuildhttpdconf' in the commandline. It said '/usr/local/apache/conf/httpd.conf OK'.
    - restarted apache using 'service httpd restart'
    - ran EasyApache to rebuild Apache/php and the changes to httpd.conf survived! So Success in EA3.
     
    #1 Jim_WHM, Jan 29, 2017
    Last edited: Jan 29, 2017
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,022
    Likes Received:
    1,276
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
  3. Jim_WHM

    Jim_WHM Member

    Joined:
    Jun 12, 2014
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Thanks for the links and hints Michael.

    I ended up adding these lines to the WHM httpd.conf include editor (WHM »Home »Service Configuration »Apache Configuration »Include Editor) in "Pre VirtualHost Include" for "All Versions" and it seemed to do the trick.

    AddHandler application/x-httpd-ea-php70 .aspx
    AddType application/x-httpd-ea-php70 .aspx


    If you can think of a reason this is a bad idea let me know. I also added a .htaccess file with the same commands for backup in case EasyApache messes something up down the line. It's real important my aspx files are processed as php and the code not just served up as text.

    One concern is if php is upgraded either automatically or i do it myself forgetting that it will break the AddType command then all my code will be served up as text until i fix the AddType command to use the new php handler.
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,022
    Likes Received:
    1,276
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    This is the primary concern you will face when adding that custom AddHandler entry. You may want to consider using the following UAPI function via the command line to quickly enable that custom Mime type for all accounts:

    UAPI Functions - Mime::add_mime - Software Development Kit - cPanel Documentation

    You could also setup a script that utilizes that UAPI function and then runs it automatically as a hook during account creation.

    Thank you.
     
Loading...

Share This Page