Solved

PHP won't serve page

Posted on 2006-11-21
7
297 Views
Last Modified: 2010-03-04
I am running apache 2.2 with PHP 5.2 on windows 2000 server

My apache server is serving up htm/html fine.

My PHP install doesn't seem to want to serve up PHP pages.  I have a test.php created as follows:

<?
phpinfo()
?>

When I tried running PHP as a module, the page was blank.

When I tired runnign PHP as CGI, I simply get the text of my php page.

My HTTP.conf has the following added:

#BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
ScriptAlias /php/ "C:\PHP"
Action application/x-httpd-php "C:\PHP\php-cgi.exe"
#END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL


My mimi.types has the following added:

application/x-httpd-php      php
application/x-httpd-php-source      phps

Where do I go from here?
0
Comment
Question by:jeffreyscottsmith
  • 4
  • 3
7 Comments
 
LVL 13

Expert Comment

by:rhickmott
ID: 17992485
You want to stick with modules if you can its far more efficient than CGI. Not that it matters much but add a; to your phpinfo() declaration and actually declare it as PHP if you havent set the INI path then php will use defaults and short tags may not be switched on by default causing it to be ignored

So basiclly your index.php page should look like

<?php
        phpinfo();
?>

in your httpd.conf

Under your Load Modules

LoadModule php5_module "C:/www/PHP/php5apache2_2.dll"

( Substitute your PHP path and note the 2_2.dll make sure its there )



# ------------------------------------------ MIME Types -----------------------------------------------

DefaultType text/plain

<IfModule mime_module>
    TypesConfig conf/mime.types
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddType application/x-httpd-php .php
    PHPIniDir "C:/www/php"
</IfModule>


Substitute PHPIniDir for yours and make sure your correct php.ini file is in that folder.

Lastly Add index.php to your DirectoryIndex string.
0
 

Author Comment

by:jeffreyscottsmith
ID: 17997175
Ok, I get my test.php to launch.  Here is something extremely strange.  My httpd.conf area for PHP is below:
____________________________________________________________________

PHPIniDir "C:\PHP\"
LoadModule php5_module "C:/PHP/php5apache2_2.dll"

# ------------------------------------------ MIME Types -----------------------------------------------

DefaultType text/plain

<IfModule mime_module>
TypesConfig conf/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
PHPIniDir "C:/www/php"
</IfModule>

____________________________________________________________________


Here is what is very, very strange,  My PHP directory is c:\php and my ini file is there.

If I comment out the PHPIniDir "C:\PHP\" (which is the correct location) test.php won't load.

If I change to the correct directory or comment out PHPIniDir "C:/www/php" in the section you gave me, test.php won't load.

I guess what I am saying is if I change either of the phpinidir paths or comment out, the page doesn't serve.

What is going on?
0
 
LVL 13

Expert Comment

by:rhickmott
ID: 17997333
Most Odd try changing

=============
PHPIniDir "C:\PHP\"
LoadModule php5_module "C:/PHP/php5apache2_2.dll"
=============
to
=============
LoadModule php5_module "C:/PHP/php5apache2_2.dll"
PHPIniDir "C:/PHP"
=============

It might be something to do with you calling it before after the module and the fact you have got it twice.

Loose it from the <IfModule mime_module> section.

So it should look like.

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

LoadModule php5_module "C:/PHP/php5apache2_2.dll"
PHPIniDir "C:/PHP"

DefaultType text/plain

<IfModule mime_module>
      TypesConfig conf/mime.types
      AddType application/x-compress .Z
      AddType application/x-gzip .gz .tgz
      AddType application/x-httpd-php .php
</IfModule>

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

See what that gives you.


At the top of your test.php ( if it doesent have it already)

add

<?php
     phpinfo();
?>

In the first box it will say

Configuration File (php.ini) Path

Mine says c:\windows\php.ini because im too lazy to change it :) but mine Is in there so its not an issue.

if it says C:\WINDOWS\ or a directory with no php.ini after it then it hasent loaded one full stop and its just using the system defaults.

Ideally you want this to say C:\PHP\php.ini
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

Author Comment

by:jeffreyscottsmith
ID: 17997458
Ok, it didn't work until I put things back.  However, it did show me that my PHP.ini is pointed to my winnt directory and there is no php.ini there.  Where is that path coming from?
0
 
LVL 13

Accepted Solution

by:
rhickmott earned 250 total points
ID: 17997536
Thats the default system path C:\WINNT\

If there is no

PHPIniDir

Specified then it will look in there first and you will find that if you dump php.ini in there then it will use it. The idea is though to keep it in the one location for simplicity which is why they introduced PHPIniDir.

According to http://www.php.net/manual/en/install.windows.apache2.php

The order is

LoadModule php5_module "c:/php/php5apache2.dll"                     ( 2_2.dll for you )
AddType application/x-httpd-php .php

# configure the path to php.ini
PHPIniDir "C:/php"

Which would seem to confirm this.


I still think the extra
PHPIniDir "C:/www/php"

Will cause more problems as its basically setting a right value wrong value try commenting it out first and if PHP still works then delete it.
0
 

Author Comment

by:jeffreyscottsmith
ID: 17997682
ok, it works now. I kept the 1st instance and deleted the second.

Thanks.
0
 
LVL 13

Expert Comment

by:rhickmott
ID: 17997944
No Problem :)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now