Solved

PHP won't serve page

Posted on 2006-11-21
7
313 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 

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

Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

631 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