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
Solved

PHP won't serve page

Posted on 2006-11-21
7
306 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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 

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

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Apache HTTP to HTTPS redirect please. 5 54
Need assistance modifying php script 3 55
PHP_POST() error message 9 67
AWS EC2 HTTP & HTTPS 2 44
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

856 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