By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,389 Members | 2,010 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,389 IT Pros & Developers. It's quick & easy.

Problem installing PHP5 on WinXP and Apache2

P: n/a
I'm having trouble getting PHP installed on my system. I downloaded
the zip file and extracted the files to C:\php. Following the
documentation, I did the following

- added C:\php to my PATH
- added the following lines to the httpd.conf file for Apache

# Adding module references for PHP
LoadModule php5_module "c:/php/php5apache2.dll"
AddType application/x-httpd-php .php

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

I tried it both with and without the last slash on the PHPIniDir, made
no difference.

- I copied and renamed php.ini-recommended as php.ini.
- One bit of advice in the documentation said to copy this file to "the
apache directory", which is a bit vauge. There's lots of Apache
directories. I tried it in both Apache2 and htdocs, no difference.

It does not seem to be processing PHP commands at all. The sample I'm
using is

<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo 'Hello World'; ?>
</body>
</html>

If I bring up the page and View Source, this is exactly what I get.
Its my understanding that if PHP were working correctly I'd just see
the Hello World, and not the surrounding PHP script.

Also, I checked my Apache logs, nothing relevent within. Anyone know
what I might have missed?

Thanks!

Oct 19 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Ma*******@gmail.com wrote:
I'm having trouble getting PHP installed on my system. I downloaded
the zip file and extracted the files to C:\php. Following the
documentation, I did the following

- added C:\php to my PATH
- added the following lines to the httpd.conf file for Apache

# Adding module references for PHP
LoadModule php5_module "c:/php/php5apache2.dll"
AddType application/x-httpd-php .php

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

I tried it both with and without the last slash on the PHPIniDir, made
no difference.

- I copied and renamed php.ini-recommended as php.ini.
- One bit of advice in the documentation said to copy this file to "the
apache directory", which is a bit vauge. There's lots of Apache
directories. I tried it in both Apache2 and htdocs, no difference.

It does not seem to be processing PHP commands at all. The sample I'm
using is

<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo 'Hello World'; ?>
</body>
</html>

If I bring up the page and View Source, this is exactly what I get.
Its my understanding that if PHP were working correctly I'd just see
the Hello World, and not the surrounding PHP script.

Also, I checked my Apache logs, nothing relevent within. Anyone know
what I might have missed?

Thanks!

Two things:
1. I think PHPIniDir may need to be "C:\php"
2. Did you restart apache? It needs to be restarted to pick up changes
in the httpd.conf.

-david-

Oct 19 '05 #2

P: n/a
David Haynes wrote:
Ma*******@gmail.com wrote:
I'm having trouble getting PHP installed on my system. I downloaded
the zip file and extracted the files to C:\php. Following the
documentation, I did the following

- added C:\php to my PATH
- added the following lines to the httpd.conf file for Apache

# Adding module references for PHP
LoadModule php5_module "c:/php/php5apache2.dll"
AddType application/x-httpd-php .php

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

I tried it both with and without the last slash on the PHPIniDir,
made no difference.

- I copied and renamed php.ini-recommended as php.ini.
- One bit of advice in the documentation said to copy this file to
"the apache directory", which is a bit vauge. There's lots of
Apache directories. I tried it in both Apache2 and htdocs, no
difference.

It does not seem to be processing PHP commands at all. The sample
I'm using is

<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo 'Hello World'; ?>
</body>
</html>

If I bring up the page and View Source, this is exactly what I get.
Its my understanding that if PHP were working correctly I'd just see
the Hello World, and not the surrounding PHP script.

Also, I checked my Apache logs, nothing relevent within. Anyone
know what I might have missed?

Thanks!

Two things:
1. I think PHPIniDir may need to be "C:\php"
2. Did you restart apache? It needs to be restarted to pick up
changes in the httpd.conf.

-david-


Also restart the computer as sometimes the path variable doesn't "set"
right.

--

Oct 19 '05 #3

P: n/a
Like I said, I've tried it with and without the slash. I've restarted
apache, and restarted the computer. I've confirmed that PHP does work
by invoking it from the command line - confirmed that the PATH is set
correctly as well. So the problem has to be in Apache.

Apache works fine, it has been up and running for quite some time. I
added the lines above to the end of the file. Do they need to be in a
certain place in the file?

If it would help, I have a very simple script set up on my server.

http://maddman.damnserver.com/test/

If anyone has any ideas what the problem could be, I'd be very
grateful. I could post my httpd.conf if that would help.

Oct 20 '05 #4

P: n/a
>
If it would help, I have a very simple script set up on my server.

http://maddman.damnserver.com/test/


Does it work if you give that file a .php extension (i.e. test.php)?

http://uk2.php.net/manual/en/install.windows.php

is a good source of tips, especially the user comments with links to other
articles.
Oct 20 '05 #5

P: n/a
> I'm having trouble getting PHP installed on my system.

I know it's troublesome when the correct php.ini or the required
php*.dll files are NOT in proper place. Tell us what's your phpinfo()
file says?

Before loosing all your hairs, you might try a simpler solution. Get
the zip file for xampp package and extract that to a root drive ...
i.e. in d: or e:. Then run that xamppstart.bat file.

And you are ready to run! Should you hate these solution, just delete
that e:\xampp folder! No registry were hurt during installing this
system ;)

http://www.apachefriends.org/en/

--
Raqueeb Hassan
Bangladesh

Oct 20 '05 #6

P: n/a
Ma*******@gmail.com wrote:
Like I said, I've tried it with and without the slash. I've restarted
apache, and restarted the computer. I've confirmed that PHP does work
by invoking it from the command line - confirmed that the PATH is set
correctly as well. So the problem has to be in Apache.

Apache works fine, it has been up and running for quite some time. I
added the lines above to the end of the file. Do they need to be in a
certain place in the file?

If it would help, I have a very simple script set up on my server.

http://maddman.damnserver.com/test/

If anyone has any ideas what the problem could be, I'd be very
grateful. I could post my httpd.conf if that would help.


Rename your 'index.html' file to 'index.php'.

Carl.
Oct 20 '05 #7

P: n/a
That did the trick! It works fine as index.php. I was under the
impression that any <?php...> in an html file would be treated as a
script - is this not the case? Do I need to make every file with a
script a .php? I need to do some reading it seems.

Thanks!

Oct 20 '05 #8

P: n/a
>That did the trick! It works fine as index.php. I was under the
impression that any <?php...> in an html file would be treated as a
script - is this not the case?
No. And you can bet that the string '<?php' occurs not infrequently
in image and audio files, too.
Do I need to make every file with a
script a .php? I need to do some reading it seems.


You need to identify every PHP script as a php script with
MIME type application/x-httpd-php. This is often done
with a directive in the Apache config file like:
AddType application/x-httpd-php .php
You could to this to the file extension .php3, or .txt, or .html,
or .gif if you want. (In the case of .gif, that's pretty nasty,
and in the case of .html, it means all pure html files will be
processed by PHP, which is a bit of overhead but probably not too
bad.) The AddType directive can also be used in .htaccess files
on a per-directory basis.

Gordon L. Burditt
Oct 20 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.