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.

Cannot Parse php within .html files!

Discussion in 'General Discussion' started by smartads, Jan 23, 2009.

  1. smartads

    smartads Member

    Joined:
    Dec 19, 2008
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    Hi there,

    I've spent days trying to get php to parse within .html files with no luck. Here are some methods i've already tried:

    ==============

    .htaccess

    Addhandler application/x-httpd-php5 .html .php
    AddType application/x-httpd-php5 .html .php

    Addhandler application/x-httpd-php .html .php
    AddType application/x-httpd-php .html .php

    RemoveHandler .html .htm
    .html server parsed

    AddHandler x-httpd-php .html
    AddType application/x-httpd-php .html .htm

    ==============

    Server Tweaks:

    Cpanel > Mime Types
    application/x-httpd-php .html .htm
    application/x-httpd-php html htm
    text/html php .php

    Cpanel > Apache Handlers
    x-httpd-php .html
    server-parsed html

    SSH:

    Changed the actual application handler file to include .html with x-httpd-php

    ==============

    Server Specs:

    Apache/2.2.11
    PHP 5
    suphp

    ==============

    Test page:
    http://members.article99.com/test.html

    As you can see, php is printed within the source code and not parsed to the browser.

    Please note: I have complete control over this server, and is not shared by anyone else.

    Any help would be greatly appreciated.

    Sincerely,

    Martin Lemieux
    Smartads President
     
  2. budway

    budway Well-Known Member

    Joined:
    Apr 16, 2003
    Messages:
    186
    Likes Received:
    0
    Trophy Points:
    16
    Post some error logs to help out our open a ticket with cpanel.
     
  3. smartads

    smartads Member

    Joined:
    Dec 19, 2008
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    That's the point, no errors are being generated at all for this issue.
     
  4. handsonhosting

    handsonhosting Well-Known Member

    Joined:
    Feb 17, 2002
    Messages:
    151
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Omaha, NE
    cPanel Access Level:
    Root Administrator
    from what I remember there was some sort of restriction on the "htdocs" folder where you couldn't EXECUTE files (like how PHP would want). I think I ended up doing the same tasks using Javascript - but if I recall right, you can't execute within the htdocs without making changes to your httpd.conf file
     
  5. smartads

    smartads Member

    Joined:
    Dec 19, 2008
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    Hey Conor,

    That would make sense, things are being stopped on the server side of things, i'll try some tweaks and keep everyone posted. I just hope WHM doesn't re-write any new changes made to the httpd.conf file automatically when regenerated later on.

    I've also added a ticket to my server's hosting company to see what they would recommend.

    Cheers & thank you!
     
  6. smartads

    smartads Member

    Joined:
    Dec 19, 2008
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    Update:

    One of the suggestions from my hosting company which hasn't solved the problem, but may help others in the future was this:

    They are now investigating this issue futher for me.
     
  7. smartads

    smartads Member

    Joined:
    Dec 19, 2008
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    To all of you who are interested, the suggestion from "Conor" was correct, but editing your servers main httpd.conf file will do nothing when cpanel rebuilds apache.

    Here's a fix around this problem:

    1) From your /etc/httpd/conf/httpd.conf it states - "This configuration file was built from the following templates... /var/cpanel/templates/apache2/main.default" so what you need to do is edit the file which is generated to create the httpd.conf file.

    2) Within your favorite ssh editor, type:

    cd /var/cpanel/templates/apache2/
    pico main.local

    HIT CTRL+V to scroll down the file until you see these initiatives:

    [% IF supported.mod_mime -%]
    AddHandler cgi-script .cgi .pl .plx .ppl .perl
    AddHandler server-parsed .shtml
    AddType text/html .shtml
    AddType application/x-httpd-php .htm .html
    AddType application/x-tar .tgz
    AddType text/vnd.wap.wml .wml
    AddType image/vnd.wap.wbmp .wbmp
    AddType text/vnd.wap.wmlscript .wmls
    AddType application/vnd.wap.wmlc .wmlc
    AddType application/vnd.wap.wmlscriptc .wmlsc
    [% END -%]

    *** You'll want to add this line:
    AddType application/x-httpd-php .htm .html

    Exit pico, save the file and then restart httpd, type:
    service httpd restart

    TIP: To check if your configurations are saved, type in:
    /usr/local/cpanel/bin/rebuild_phpconf

    Afterwards, pico main.default once again to see if your new line of code is still there, and then check your test.html for parsing php within .html or .htm files.

    Worked for me, hopefully this helps those of you who cannot get php to parse within html files.

    Cheers!
     
  8. smartads

    smartads Member

    Joined:
    Dec 19, 2008
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
  9. Solokron

    Solokron Well-Known Member

    Joined:
    Aug 8, 2003
    Messages:
    849
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Seattle
    cPanel Access Level:
    DataCenter Provider
    Anyone find a fix for this that does not require enabling PHP to process all htm files on the server?
     
  10. Solokron

    Solokron Well-Known Member

    Joined:
    Aug 8, 2003
    Messages:
    849
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Seattle
    cPanel Access Level:
    DataCenter Provider
    Scratch that, I have located my issue.

    Thanks.
     
Loading...

Share This Page