Navigate
Home
ArticleWiki
Forum
Journal
Search
Newsletter
Links
Tech News
expertsrt.com
Welcome Guest.
Username:

Password:

Remember me

Apache 2.2 and PHP 5 not working
Welcome, Guest. Please login or register.
August 29, 2008, 03:07:39 PM
11291 Posts in 1243 Topics by 838 Members
Latest Member: gjpino
Experts Round Table Network  |  Serverside Technology  |  PHP  |  Apache 2.2 and PHP 5 not working « previous next »
Pages: [1]
Author Topic: Apache 2.2 and PHP 5 not working  (Read 1364 times)
Jack

Offline Offline

Posts: 2


« on: January 09, 2008, 06:39:41 AM »

Hi all. I am new to this environment and I hope you can help me with my test server running as Localhost on my laptop.

I have installed Apache2.2 and php5 together with MySql 5 and PHPMyAdmin. On the face of it all seems to be working, I can view the Apache test page, phpinfo page and the PHPMyAdmin home page with Mysql database. However, when I try to view an file called test.htm with php code embeded in the html and all I get is the HTML in the localhost browser window not the php. The directory for Apache and php has been changed to D:\www, does this make a difference? Any suggestions please?

Regards
Jack
Logged
GrandSchtroumpf
Mentor

Offline Offline

Posts: 408



« Reply #1 on: January 09, 2008, 01:59:27 PM »

That's because your Apache server is not configured to process php on files that end in ".htm".
Rename your file from "test.htm" to "test.php" and it should work.
Another solution is to change your Apache configuration, but i don't recommend that.  If you want to work with ".htm" uri's instead of ".php" uri's, then it's better to use mod-rewrite.

Cheers.
Logged
VGR
Mentor

Offline Offline

Posts: 680



WWW
« Reply #2 on: January 10, 2008, 02:47:02 PM »

IMHO you should definitely change this line in your httpd.conf file and then restart Apache :

AddType application/x-httpd-php .php

into :

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

you'll lose less than 3% CPU speed on pure static HTML but on the reverse side you'll be able NOT to rename all your pages once they get dynamic.
It's better than play silly games with mod_rewrite ;-)
Logged

techie overlord, answers all kind of questions on http://www.europeanexperts.org
Jack

Offline Offline

Posts: 2


« Reply #3 on: January 11, 2008, 10:43:28 AM »

I have changed the httpd.conf file as you suggested and its ok now. thank's for your help.
Regards
Jack
Logged
GrandSchtroumpf
Mentor

Offline Offline

Posts: 408



« Reply #4 on: January 11, 2008, 12:26:57 PM »

> It's better than play silly games with mod_rewrite ;-)
Depends if you want your pages to work on mutualized hosting plans where you often cannot change apache's settings.
And who talked about renaming all the pages?  AFAIK, for the time being, there is only one file named "test.htm".
I love mod-rewrite and pretty uri's.  Decoupling uri and file-name is great for flexibility and ease of management.
Logged
CrYpTiC_MauleR
Site Builder

Offline Offline

Posts: 487



WWW
« Reply #5 on: January 12, 2008, 07:36:35 PM »

Also isn't that a security risk running .html and .htm as PHP files. Many times those types of files are assumed trusted serverside and not expected to contain executable PHP code. I suggest still using .php extensions and just make a simple 1 line mod_rewrite rule that will make xyz.html redirect transparently in background to xyz.php so user sees xyz.html in browser but server runs the file xyz.php that way you know only .php files will contain executable code and you limit the risk of some code your's or a 3rd party's from accidentally running malicious code in what would have been a benign .html file.
Logged

[x] Fight | www.crypticmauler.com
"You must be
Pages: [1]
« previous next »
    Jump to: