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.

.php includes in .html files?

Discussion in 'General Discussion' started by katz_global, May 14, 2004.

  1. katz_global

    katz_global Well-Known Member
    PartnerNOC

    Joined:
    Oct 18, 2003
    Messages:
    69
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Hosting from: Panama, Hong Kong, Singapore, Malays
    I am moving a site from a plesk system to a cpanel system. In plesk, the site was built using filename.html container pages and the "included" content of those pages is filename.php etc...

    php includes are being parsed from .html pages somehow by the server on the plesk system.

    include("hosting-x.php")

    ex.
    filename.html
    include("filename.php")
    filename.php

    Now, being that I do not want to try and attempt to rename all the html pages to .php and rename thousands of includes on hundreds of pages does anyone here have a work around for this situation?

    If plesk can parse php via html there must be a config setting for this right?

    thank you
     
  2. chmod

    chmod Well-Known Member

    Joined:
    Apr 20, 2004
    Messages:
    45
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    London - UK
    I think you can just assign a handler for html files to be parsed by php in cpanel "Apache Handlers" section..

    Otherwise:

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

    in httpd.conf
     
  3. katz_global

    katz_global Well-Known Member
    PartnerNOC

    Joined:
    Oct 18, 2003
    Messages:
    69
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Hosting from: Panama, Hong Kong, Singapore, Malays
    I added a line into the httpd.conf file and restarted apache and now am getting a 500 error on all html files. I played with the permissions of the files and no luck yet:

    AddHandler application/x-httpd-php .php .php4 .php3
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php .php4
    AddType application/x-httpd-php .php3

    <<< NEW LINE >>>

    AddType application/x-httpd-php .html

    <<< END NEW LINE >>>

    AddType application/x-httpd-php-source .phps
    AddType application/x-httpd-php .phtml
    AddHandler cgi-script .cgi .pl
    AddType text/html .shtml
    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


    is the added line above correct, and/or in the correct place?

    I chmoded the html file to:

    644 and get this

    [2004-05-14 06:20:18]: error: file has no execute
    [2004-05-14 06:18:49]: error: file has no execute
    [2004-05-14 06:18:46]: error: file has no execute

    777 = gets this
    [2004-05-14 06:22:39]: error: file is writable by others:
    [2004-05-14 06:22:38]: error: file is writable by others:

    chmod 755 gives the 500 error.

    On plesk I always had to chmod 755 to make it work.

    any ideas?
     
  4. katz_global

    katz_global Well-Known Member
    PartnerNOC

    Joined:
    Oct 18, 2003
    Messages:
    69
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Hosting from: Panama, Hong Kong, Singapore, Malays
    nevermind...

    I added the handler also and it came right up.

    Now the question remains: are both the httpd.conf and apache handler required or only the handler?

    Since the handler is site specific, how can it be configured globally?

    Scott
     
  5. bamasbest

    bamasbest Well-Known Member

    Joined:
    Jan 10, 2004
    Messages:
    531
    Likes Received:
    0
    Trophy Points:
    16
    to make it global, don't specify the handler within a virtual account.

    modify/add your runtime directive where the global directives exist.

    Then, it would apply server wide.
     
  6. katz_global

    katz_global Well-Known Member
    PartnerNOC

    Joined:
    Oct 18, 2003
    Messages:
    69
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Hosting from: Panama, Hong Kong, Singapore, Malays
    isnt that already being discussed? The question is what file and what code specifically, not how or why.

    It was said that adding a line to https.conf would do it, but that proved wrong on its own.

    I have heard that a .htaccess file can do it, but that is site specific.

    I head that ssi can do it, but that is again site specific.
     
  7. SarcNBit

    SarcNBit Well-Known Member

    Joined:
    Oct 14, 2003
    Messages:
    1,010
    Likes Received:
    3
    Trophy Points:
    38
    I assume you meant httpd?

    That should work as long as there is no conflict within your virtual account settings.

    Parsing the .html file for SSI would require almost essential the same changes as parsing for PHP.


    Parsing all .html files for PHP will severly increase your server load on an active server. Is that really what you want to do? You may be better off simply parsing .html files for those clients that need it and for whatever reason can or will not stand to rename their files.
     
  8. oinkmedia

    oinkmedia Well-Known Member

    Joined:
    Jul 5, 2003
    Messages:
    49
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    SW London (UK)
    A similar problem is being discussed at http://forums.cpanel.net/showthread.php?t=22936

    This problem appear to be more common than I had first thought. I would also recommend against parsing all html files with php as it will definately increase server load. There has to be a neater answer.
     
  9. djmerlyn

    djmerlyn Well-Known Member

    Joined:
    Aug 31, 2004
    Messages:
    203
    Likes Received:
    1
    Trophy Points:
    16
    Here's the full scoop...

    Add the following line to your .htaccess file (NOT IN THE CONF FILE) in the directory you want to parse html as php.

    THIS IS A HACK because your server will parse EVERY html page whether there is php in it or not. Thus, eventually degrading server performance...

    You would be better off doing apache includes if possable. On pretty much every Cpanel server I've ever seen...you can do an SSI include using the following code in your SHTML (note I said SHTML not HTML) file~

    Note that the .html is changed to .shtml so that the server does not parse every HTML page as an SSI page. SHTML is used by the server to parse apache includes. Following this file naming structure for the type of file you are using is a good idea, so that a server move in the future will be easy -since almost every server follows the same scheme...

    The only difference between SHTML and HTML is that SHTML is parsed by the server.

    Hope that helps~
     
  10. tomakaze

    tomakaze Member

    Joined:
    Oct 12, 2004
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Toronto, CA / Helsinki, FI
    php parsing from .html (separate cpanel apache config?)

    I already have my Apache set to parse PHP from html files, I'm not concerned about possible performance issues.

    The problem is, that cPanel is not playing by the right Apache configuration, and after many experiments, I'm convinced that cpanel has it's own configuration and it's own unique instance of apache.

    There is a file that I'm a bit suspicous of: /usr/local/cpanel/APACHE_CONFIG :rolleyes:

    But that doesn't seem to do the job when I add the handlers or type.

    My installation of cPanel won't even deliver a PHP file properly to my browser, so I know there is something going on designed only for the standard cpanel skins.

    And then beyond this, there seems to be still general problems with limitations of php within the cpanel framwork. Juan Poze has created this php wrapper to get around some of these: http://html.conclase.net/cp/scripts/#cpanelphp

    I want to know how we can all untie our hands from these issues and have a more open environment. I guess cpanel doesn't care about that, but I do, and I bet many of you do too! :eek:
     
Loading...

Share This Page