Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • December 09, 2016, 01:46:30 AM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Help Request: Php files on Apache server not loading right  (Read 3246 times)

barney

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 1,282
    • View Profile
    • Donate to Member
Help Request: Php files on Apache server not loading right
« on: June 24, 2010, 05:40:08 PM »
Folk,

I give up.  I've been fighting this problem for a couple of weeks, now, and cannot deduce or find a resolution.

I've installed Apache 2.2, PHP 5.x, & MySQL on a 64-bit Win7 box.  However, PHP files merely display the page as PHP code, at best.  Both Apache and PHP are 32-bit, MySQL is 64-bit.  The box in question is an Intel i3 4-core, 4 GB RAM.
I had the same problem with Win XP, and I think I had it with Win 2K.  However, I do not recall what resolved it.

All the Apache and PHP forum efforts have been treated as RTFM, with an automatic assumption that the manual has not been read  :mad:.  Google [many] searches have revealed a significant number of resolutions - none of which have worked for me.  Some of those resolutions involved WAMP/XAMPP, but that hasn't worked, either.  I dislike using WAMP/XAMPP for several reasons, but I tried both, anyway.  The results were significantly less than optimal  :'(.

Bottom line - one of 'em, at least - is that I cannot test a couple of gigs of Web code on the laptop.  While I can run against the server just fine, I'm not always connected to the server.  Since I'm likely to experience vascular surgery in the near future, I really need to get the laptop up to speed in this respect, as there is no reason carving my drumstick(s) should keep me non-productive (if ever I was that  ;D).

As I recall previous corrections for the older OSes, it was httpd.conf & php.ini corrections, but I cannot remember those for the life of me.  If needful to see those files, I can put 'em up on a site - they're too long to post here, methinks.
« Last Edit: June 29, 2010, 09:46:07 PM by mouser »

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 36,421
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: A [probable] RTFM conundrum ...
« Reply #1 on: June 24, 2010, 06:13:55 PM »
ok couple of quick simple questions first:

You say the PHP files merely display the page as PHP code text.

Are you for sure open the files through the apache web server? This is kind of an obvious question except i have dragged and drop local filed into my web browser before and been confused for a minute why the php wasn't being interpreted.  In other words, the php files, are you accessing them like http://localhost/myfile.php or http://127.0.0.1/myfile.php and not file://c:\myfile.php

Second question would be that it sure sounds like your apache httpd.conf file is not saying to interpret php files with the php interpreter.  One thing to watch out for is having multiple copies of httpd.conf in different locations and editing a useless one and wondering why the changes don't take.  you might want to first confirm that's not happening.

Then of course make sure you restart apache after you make a change.

Lastly, some recent changes made files that used to be marked as php with <? tags now can require <?php tags.  see if that's your problem.

barney

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 1,282
    • View Profile
    • Donate to Member
Re: A [probable] RTFM conundrum ...
« Reply #2 on: June 24, 2010, 07:00:50 PM »
All good points.

Access is via http://win74ggw/[php page or index.php] - localhost won't work, but that's due to entries in the httpd.conf file.

Only one copy of httpd.conf in existence - it's not correct, but it's the only one  :).  And, to verify the correct one is being edited, l'll usually make some innocuous but obvious change to be certain, then revert the change & try to do what I need to do  :tellme:.  (This is usually to change the index order from index.php to index.html, then back.)

Haven't used the short tag <? for years ... belt and suspenders attitude on most things  ;D.

There is one point you've inadvertently brought, though.  When system is booted, it may take several minutes before the Apache Monitor shows Apache as active.  It's also slow to restart via the Monitor.  My first thought was UAC issues, but that doesn't seem to be the case.  However, no discernible pattern, at times the restart will bring up the UAC permission window.

One other thing I should maybe mention is that I've seen complaints on restarting Apache that RewriteEngine is invalid in the .htaccess file in DocRoot.

Eóin

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 1,401
    • View Profile
    • Donate to Member
Re: A [probable] RTFM conundrum ...
« Reply #3 on: June 24, 2010, 07:07:29 PM »
Can you verify that mod_php is indeed loaded and running in Apache? Been years since I did this but I'm sure I remember there was some sanity test of sorts you could perform to make sure Apache and mod_php were fine before you'd then move on to configuring a site.

parkint

  • Supporting Member
  • Joined in 2010
  • **
  • Posts: 119
  • It's bad luck to be superstitious
    • View Profile
    • Donate to Member
Re: A [probable] RTFM conundrum ...
« Reply #4 on: June 24, 2010, 07:58:50 PM »
What is the contents of the .htaccess file in the DocRoot?
A bad "Rewrite" line could be your problem.

Another [basic] question.  Do you get proper response from an HTML page?


barney

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 1,282
    • View Profile
    • Donate to Member
Re: A [probable] RTFM conundrum ...
« Reply #5 on: June 24, 2010, 08:24:23 PM »
Unfortunately, other than trying to run phpinfo(), I don't know a way to verify mod_php except by checking the .conf/.ini files.  However, most everything I've found does not include mod_php save for Apache 1.x.  Seems it's being ... deprecated? ... or just replaced by FastCGI <shudder />.

HTML pages work just fine, although I've very few w/o some PHP content  ;)

I guess the .htaccess is short enough to post.  It's one I've used for quite a while now, although I don't understand everything I know about it  :(.
# Enable Server-Side Includes
AddType text/html .shtml
AddHandler server-parsed .shtml
AddHandler server-parsed .html
Options FollowSymLinks Includes

# Define default pages
DirectoryIndex index.html index.php

# Linking Control - allow only blank or listed referers
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?win7rc3ggw/.*$ [NC]
RewriteRule \.(bmp|gif|jpg|png)$ - [F]

# Prevent viewing of htaccess
<Files ~ "^\.ht">
order allow,deny
deny from all
satisfy all
</Files>

# Disable directory listing from this point
Options +Indexes

# Omit certain file types from the directory listing
IndexIgnore *.bmp *.gif *.jpg *.png

#Handle HTML as PHP
AddHandler application/x-httpd-php .html

barney

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 1,282
    • View Profile
    • Donate to Member
Resolved? Re: A [probable] RTFM conundrum ...
« Reply #6 on: June 26, 2010, 11:23:01 PM »
OK, this seems to have been resolved ... at least, PHP is showing properly now, although the index order is not being followed.

I loaded the httdp.conf file in WinMerge, along with a known good file from another machine.  After poring over it for what seemed hours, I kept finding some lines that were indicated as being different even though they were, visually, identical.  I deleted those lines, then retyped them.  Suddenly, stuff works.

Barring any other evidence, I'm constrained to assume that there were non-visible characters in the replaced lines that Apache could recognize even though I couldn't see them.  I suppose I should have loaded both files into a hex editor (PSPad has that capability, though it's seldom used on my part.) to see what the difference was, but by the time I thought of that, I'd already implemented the changes.

At any rate, although I don't fully understand the whys & wherefores, so far things seem to be fixed.  Sorry to have troubled you with such a simplistic issue.

Deozaan

  • Charter Member
  • Joined in 2006
  • ***
  • Points: 1
  • Posts: 7,721
    • View Profile
    • The Blog of Deozaan
    • Read more about this member.
    • Donate to Member
Re: A [probable] RTFM conundrum ...
« Reply #7 on: June 29, 2010, 04:14:26 PM »
I'm not sure, but it could have been different EOL characters.


barney

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 1,282
    • View Profile
    • Donate to Member
Re: A [probable] RTFM conundrum ...
« Reply #8 on: June 29, 2010, 06:11:33 PM »
That's something to consider if a similar file is encountered in the future.  Uncertain, though.  *nix uses LF for EOL, Mac uses CR, and Win uses both - so if one or the other were missing, the line would not display properly in the editor (I use PSPad for .htaccess/.conf/.ini files, with CR+LF as default line ending, when working in Windows).  Unless Win looks at the order, i.e., LF+CR as opposed to CR+LF?  I'm really not certain there, but I don't think that matters.  If I get time, I'll put a text file in PSPad in hex, then change the order, see what transpires.

Since I frequently hit CTRL while typing, I'm inclined to think that may have been the cause.  I usually can tell that's happened because some hot-keyed app will pop up, stealing the focus while I'm typing merrily away.  It's possible, I'd guess, that some CTRL-key combos could put a non-visible character in a text string when it doesn't activate an application.  Another area of ignorance, but I seem to remember having that problem with VB apps back in the corporate days.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 36,421
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: A [probable] RTFM conundrum ...
« Reply #9 on: June 29, 2010, 06:32:27 PM »
ps -- just a pet peeve -- when starting a new topic, can we all make sure we try to specify topic titles that will help people searching identify the topic contents.

barney

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 1,282
    • View Profile
    • Donate to Member
Re: A [probable] RTFM conundrum ...
« Reply #10 on: June 29, 2010, 06:46:32 PM »
Mouser,

I'd love to have done so ... but what title would have been appropriate?  I really was at a loss as to what the title should be.  If you have a better one, by all means, change it  :Thmbsup:.

[Side note](I've seen a number of threads here that ended up far afield of the original topic.  Nature of the beast, methinks  ;D.)

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 36,421
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: A [probable] RTFM conundrum ...
« Reply #11 on: June 29, 2010, 07:00:37 PM »
Just something like "Help Request: Php files on Apache server not loading right"

it doesn't have to be perfect -- but hitting the 3 main points:
  • Looking for assistance
  • Php
  • Apache

would go along way to making the thread something that someone with similar problem would find and think to read.

barney

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 1,282
    • View Profile
    • Donate to Member
Re: A [probable] RTFM conundrum ...
« Reply #12 on: June 29, 2010, 08:26:43 PM »
OK, that works.  How do we go about changing the thread title?  You?  Me?

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 36,421
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Help Request: Php files on Apache server not loading right
« Reply #13 on: June 29, 2010, 09:46:27 PM »
i cant do it but mainly i was just making the point for future posts and posters.

barney

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 1,282
    • View Profile
    • Donate to Member
Re: Help Request: Php files on Apache server not loading right
« Reply #14 on: June 29, 2010, 10:01:47 PM »
Understood  :-[.  However, your point still stands.  If there's a possibility that rewording the topic could save someone else some of the grief, it's a thing worth doing.

Anent the search function, guess Google has spoiled me:  I had, until now, assumed that the search engine scanned posts, not just topics.  Makes me curious what I might have missed in past searches  :o ;D.