Page 2 of 2 FirstFirst 12
Results 11 to 19 of 19

Thread: PHP not working in *.html in LAMP

  1. #11
    Join Date
    Feb 2009
    Location
    /earth/india/mumbai
    Beans
    599
    Distro
    Ubuntu 12.04 Precise Pangolin

    Unhappy Re: PHP not working in *.html in LAMP

    Quote Originally Posted by SeijiSensei View Post
    Go reread the OP's post. The "problem," if you can call it that, is resolved by adding the SetHandler directive to tell Apache to use the PHP module when sending .html files.
    Quote Originally Posted by ridgeland View Post
    satish_j,
    That's what the initial post did. It explains how I got php to process in html. Semms like Bluehost did something with .htmaccess or such. Search their knowledgebase for php, you don't need an account.
    Quote Originally Posted by satish_j View Post
    I have already tried creating htaccess file in /var/www and entering the 'AddType' declaration inside it,but that didn't helped..
    As mentioned in Post6,i have already tried that method w/o success..

    Vote for my Idea
    ~~~Open-source Software and Patience go hand in hand~~~

  2. #12
    Join Date
    Nov 2008
    Location
    Boston MetroWest
    Beans
    16,326

    Re: PHP not working in *.html in LAMP

    Quote Originally Posted by satish_j View Post
    As mentioned in Post6,i have already tried that method w/o success..
    You need either "SetHandler" or "AddHandler" depending on where you deploy it in the Apache configuration. AddType won't solve the problem.

  3. #13
    Join Date
    Feb 2009
    Location
    /earth/india/mumbai
    Beans
    599
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: PHP not working in *.html in LAMP

    Quote Originally Posted by SeijiSensei View Post
    You need either "SetHandler" or "AddHandler" depending on where you deploy it in the Apache configuration. AddType won't solve the problem.
    This is also not working..Got any other ideas??

    Vote for my Idea
    ~~~Open-source Software and Patience go hand in hand~~~

  4. #14
    Join Date
    Feb 2009
    Location
    /earth/india/mumbai
    Beans
    599
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: PHP not working in *.html in LAMP

    Solved it..
    Added the 'AddType' handler in /etc/apache2.conf and bingo,prob is resolved..

    Vote for my Idea
    ~~~Open-source Software and Patience go hand in hand~~~

  5. #15
    Join Date
    Oct 2007
    Location
    India
    Beans
    103
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: PHP not working in *.html in LAMP

    Hi,
    PHP file is not being executed,it is offered as a download.I installed LAMP as

    apt-get install apache2
    apt-get install php5
    apt-get install mysql-server

    I have tried everything like
    sudo a2enmod php5
    Module php5 already enabled

    even re-installing libapache2-mod-php5

    sudo apt-get purge libapache2-mod-php5

    sudo apt-get install libapache2-mod-php5

    I am using public_html directory and it is working fine.MySQL is working perfect and i can access it from the Terminal.

    Note:
    My computer Hard disk is faulty and i had sent it for a repair.I am using Ubuntu 10.10 as Live CD and installing lamp on it and intent to save the source php files on an external hard-disk.

    I have tried the ApachePHPMySQL ubuntu documentation and whole lot of online resource.Nothing works.Any Idea will be appreciated.

    Thanks in Advance

  6. #16
    Join Date
    Aug 2009
    Location
    Bangalore
    Beans
    9
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: PHP not working in *.html in LAMP

    Quote Originally Posted by ivikas View Post
    Hi,
    PHP file is not being executed,it is offered as a download.I installed LAMP as

    apt-get install apache2
    apt-get install php5
    apt-get install mysql-server

    I have tried everything like
    sudo a2enmod php5
    Module php5 already enabled

    even re-installing libapache2-mod-php5

    sudo apt-get purge libapache2-mod-php5

    sudo apt-get install libapache2-mod-php5

    I am using public_html directory and it is working fine.MySQL is working perfect and i can access it from the Terminal.
    Suffering with the same problem. I tried to add "AddType application/x-httpd-php .php .htm .html" or "AddHandler" in .htaccess. None worked.
    Does anybody solved the problem if so please help us. Thanks.


    My test html file with simple PHP snippet
    --------------------------------------------------
    <html>
    <head></head>
    <body>
    <h1>
    <?php echo "I LOVE PHP!"; ?>
    </h1>
    </body>
    </html>

  7. #17
    Join Date
    Jan 2007
    Location
    Ridgeland WI US
    Beans
    464
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: PHP not working in *.html in LAMP

    Hi trinetra
    I don't use LAMP a lot but I tested this for you.
    I copied your script and saved it as /Data/Temp/trinetra.html
    Then I booted to the LAMP partition (different OS installation)
    I opened it with Firefox as file:///Data/Temp/trinetra.html:
    nothing.
    I copied it to /Data/html/LAMP/trinetra.html and opened it with Firefox as file:///Data/html/LAMP/trinetra.html :
    nothing.
    I copied it to /Data/html/LAMP/trinetra.php and opened it as
    http://localhost/trinetra.php
    and got:
    I LOVE PHP!
    in big bold letters.

    The moral of the story:
    You need to save the file as *.php not *.html
    You need to have the file in the path of http://localhost
    You need to open it as localhost not as a file.

    If you got those three things right and it still doesn't work then let's work on http://localhost and where it points.
    Gigabyte GA-MA790GPT-UD3H - AMD Phenom II x3 720 - 8 GB RAM - 2009 - My first PC from parts!

  8. #18
    Join Date
    Aug 2009
    Location
    Bangalore
    Beans
    9
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: PHP not working in *.html in LAMP

    @Ridgeland: Thanks a lot for responding and helping me with my problem.....

    Few observations that I found after your suggestion......

    1. You are correct that I used to open the test.html (trinetra.html) as a file in Firefox and nothing is displayed.
    2. But after your direction to open the file with http://localhost/test.html
    I had placed the file in /home/test/public_html/ directory as index.html
    and changed the entries in /etc/apache2/sites-available/default to point to my new location than /var/www/
    and restared the Apache server. But I went into permission/ access problem.
    3. Later I tried with default location i.e. I placed the test.html in /var/www as index.html and restarted the Apache server....
    Boom that's it, I got "I love PHP" in big letters.

    Though I didn't changed the extension as php, still as html I could able to open the file in browser. But the catch is instead of opening the file with absolute path (i.e. the path in your machine), I tried to open as helped by Ridgeland like http://localhost/ or http://localhost/test.html. In both the cases the php snippet got executed without any problem even if the file extension is html (I wonder why it didn't worked for "Ridgeland").

    Ridgeland you saved my day ........

  9. #19
    Join Date
    Jan 2007
    Location
    Ridgeland WI US
    Beans
    464
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: PHP not working in *.html in LAMP

    Have fun...

    But... when the server sees a request for a *.php the server sends the *.php through an extra step to process any php code and display the result.

    You can set up the server so *.html is treated like *.php. In that case every html page even those that do not have php code in them still has to go through a wasted process of checking for php code but not finding any then displaying the result.

    My first efforts with *.html failed because the server was set up correctly and did not search *.html for php code. My hack of processing all *.html for php code wastes server resources. For my home server that is trivial. For a large corporation it would matter.
    Gigabyte GA-MA790GPT-UD3H - AMD Phenom II x3 720 - 8 GB RAM - 2009 - My first PC from parts!

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •