Discussion:
[PHP-INSTALL] Installation issue
Jerry Adair
2008-07-06 07:25:51 UTC
Permalink
Hi,
 
I have (seemingly) successfully installed both Apache 2.2 and PHP 5.2.6 on my PC here at home.  I followed the installation instructions carefully and have visted the FAQ sites and help guides.  Still, I cannot get an embedded PHP script (in a HTML file) to be executed by Apache.  I can run PHP as stand-alone without problem and when I type in http://localhost I see the "It Works!" message.  There are no errors reported in the Apache error log.  I noticed in the PHP documentation that if I can see the php source when I select "View Source" from the browser that this means it is not being handed over to Apache, so there is a problem with configuration.  I have tried both methods (CGI and "As Module") but neither make a difference in the outcome.
 
HELP?!
 
Thanks,

Jerry
Keith Roberts
2008-07-06 09:30:04 UTC
Permalink
Subject: [PHP-INSTALL] Installation issue
Hi,   I have (seemingly) successfully installed both
Apache 2.2 and PHP 5.2.6 on my PC here at home.  I
followed the installation instructions carefully and have
visted the FAQ sites and help guides.  Still, I cannot get
an embedded PHP script (in a HTML file) to be executed by
Apache.  I can run PHP as stand-alone without problem and
when I type in http://localhost I see the "It Works!"
message.  There are no errors reported in the Apache error
log.  I noticed in the PHP documentation that if I can see
the php source when I select "View Source" from the
browser that this means it is not being handed over to
Apache, so there is a problem with configuration.  I have
tried both methods (CGI and "As Module") but neither make
a difference in the outcome.   HELP?!   Thanks,
Jerry
Hi Jerry. Your almost there.

As you state, the problem appears to be with your Apache
configuration.

In your Apache configuration file httpd.conf, you should
have the following entry to load the php module:

(I have split my Apache loadable modules section into a
seperate include file, as these modules can change from one
version to the next of Apache. This allows me to continue to
use my main customised httpd.conf file across upgrades, and
then just create a new loadable modules include file, for
the latest Apache version.)

#-----------------------------------------------------------
# Dynamic Shared Object (DSO) Support
Include conf/F8-dso-modules-2.2.8

# the php install script will look in httpd.conf file
# for 'LoadModule' directives, and create one if it does not
# exist.
#
LoadModule php5_module modules/libphp5.so

#-----------------------------------------------------------

That should load the module into Apache.

Assuming that the Apache php module is loaded, it looks like
the only thing left to do is edit your Apache httpd.conf
configuration file, to tell Apache to pass your php-enabled
web pages to the Apache php module for processing, like
this:

# AddType allows you to add to or override the MIME configuration
# file mime.types for specific file types.
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz

# php specific filetypes
AddType application/x-httpd-php .php
AddType application/x-httpd-php .hml
AddType application/x-httpd-php .htm
AddType application/x-httpd-php .html

Basically, you can use any filename extension you want for
php-enabled web pages, to send the contents of that file to
Apache's php module for processing. Just add it to the list
above, and php will process it.

I can't understand why the PHP installer doesn't modify this
part of the httpd.conf file, to complete the PHP Apache
module installation? Maybe that's an overdue bug
report/feature request to the php developers?

HTH

Kind Regards,

Keith

-----------------------------------------------------------------
Websites:
http://www.php-debuggers.net
http://www.karsites.net
http://www.raised-from-the-dead.org.uk

The mind of the prudent is ever getting knowledge, and the
eear of the wise is ever seeking, inquiring for and craving
knowledge. Pr. 18:15 Amp

All email addresses are challenge-response protected with
TMDA [http://tmda.net]
-----------------------------------------------------------------
Tommy Peterson
2008-07-06 12:09:32 UTC
Permalink
Keith,
If you can't get this working, and you are using a Windows, not Linux/Unix
machine, do the following (the online doc are not complete or detailed
enough I have found):

1) Rename the PHP file in your PHP directory to PHP.ini (add the .ini
extension to it).
2) In your Apache httpd.conf file (localed in the apache's conf directory
do the following

Here is the proper apache directives to load php, preferbly saved as
php.conf and included from your main config.

#load the php main library to avoid dll hell
Loadfile "C:\pathtophp\php5ts.dll"

#load the sapi so that apache can use php
LoadModule php5_module "C:\pathtophp\php5apache2_2.dll"

#set the php.ini location so that you don't have to waste time guessing
where it is
PHPIniDir "C:\pathtophp"

#Hook the php file extensions, notice that Addtype is NOT USED, since
that's just stupid
AddHandler application/x-httpd-php .php
AddHandler application/x-httpd-php-source .phps

3)
Do not copy any php files anywhere
Do not edit the system path. If you have deleted them.

4) Delete any additions from you httpd.conf and php.ini that you have made
to try to get it to work.

5) restart your apache server. It should work.

***@yahoo.com on Sunday, July 6, 2008 at 3:25 AM wrote:
Hi,
I have (seemingly) successfully installed both Apache 2.2 and PHP 5.2.6
on my PC here at home. I followed the installation instructions
carefully and have visted the FAQ sites and help guides. Still, I cannot
get an embedded PHP script (in a HTML file) to be executed by Apache. I
can run PHP as stand-alone without problem and when I type in [
http://localhost ]http://localhost I see the "It Works!"
message. There are no errors reported in the Apache error log. I
noticed in the PHP documentation that if I can see the php source when I
select "View Source" from the browser that this means it is not
being handed over to Apache, so there is a problem with configuration. I
have tried both methods (CGI and "As Module") but neither make
a difference in the outcome.
HELP?!
Thanks,
Jerry
Jerry Adair
2008-07-06 15:02:26 UTC
Permalink
Hi Tommy/Keith/Newsgroup,
 
Thank you for the input, I REALLY appreciate it.  I did everything you said but it still does not work.  A few observations:
 
1) Yes I am running on Windows XP.  So it seems that I shouldn't do any of the "*.so" stuff that Keith mentioned, that seems like a UNIX thing.  If I can just get the thing to work, I will split my PHP definitions off into another file just as Keith recommends.  However for now I just want it to work.
 
2) What exactly am I supposed to rename in the php directory?  Your email just said "rename the PHP file" ... the documentation says to rename either the php.ini-recommended or php.ini-dist as php.ini.  So I renamed the php.ini-recommended to php.ini in my PHP directory, which I installed in C:\php.
 
3) Here are the changes I made to conf\httpd.conf:
#JRA added this
#Preload the PHP interpreter so that Apache can find it
#even if it's not in the path
LoadFile "C:\php\php5ts.dll"
LoadModule php5_module "C:\php\php5apache2_2.dll"
PHPIniDir "C:\php"
AddHandler application/x-httpd-php .php
AddHandler application/x-httpd-php-source .phps
 
The problem with this is that I cannot find the "application" directory ANYWHERE.  I downloaded what I thought was/is the latest version of Apache from a mirror site, but there is no application directory.  Nothing in the instructions mentions such a directory, that I read anyway.  Do I just need to create it manually?  Confusing.  I tried these definitions with both forward and backward slashes, and it made no difference.
 
4) I did not copy the php.ini file anywhere.
 
5) I did add "C:\php" to the PATH environment variable.  Is that really a problem?

6) I have issued many "bin\httpd.exe -k [start|stop]" commands recently, nothing has changed.
 
7) Below is what I get when typing http://localhost into a browser window:
<html><body>
<h1>It works!</h1>
<?php
echo "PHP test\n";
?>
</body></html>

Note that I modified the file a bit just to see if I could get the php echo text to appear in the browser in addition to the It works! text...
 
8) Is there an installation issue at work here?  Do I need to install PHP only AFTER installing Apache?
 
Thanks for any help.  I am LOST!

Jerry


""Tommy Peterson"" <***@americaschoice.org> wrote in message news:***@ncee.org...
Keith,
If you can't get this working, and you are using a Windows, not Linux/Unix machine, do the following (the online doc are not complete or detailed enough I have found):

1) Rename the PHP file in your PHP directory to PHP.ini (add the .ini extension to it).
2) In your Apache httpd.conf file (localed in the apache's conf directory do the following

Here is the proper apache directives to load php, preferbly saved as php.conf and included from your main config.

#load the php main library to avoid dll hell
Loadfile "C:\pathtophp\php5ts.dll"

#load the sapi so that apache can use php
LoadModule php5_module "C:\pathtophp\php5apache2_2.dll"

#set the php.ini location so that you don't have to waste time guessing where it is
PHPIniDir "C:\pathtophp"

#Hook the php file extensions, notice that Addtype is NOT USED, since that's just stupid
AddHandler application/x-httpd-php .php
AddHandler application/x-httpd-php-source .phps

3)
Do not copy any php files anywhere
Do not edit the system path. If you have deleted them.

4) Delete any additions from you httpd.conf and php.ini that you have made to try to get it to work.

5) restart your apache server. It should work.
Miles Thompson
2008-07-06 15:20:05 UTC
Permalink
Tommy Peterson's instructions look right. (Although I've never installed on
a Windows box.)

When you "stopped" Apache, did you check to see if an older instance was
running. That often catches the experts.

Did you do a check on Apache's configuration? (Usually apache2ctl -check)

Is Apache running as a service?

Does Apache render HTML?

Create this file, phpinfo.php, and put it in your docroot (webroot, however
you think of it):

<?php
phpinfo();
?>

Then this URL: http://localhost/phpinfo.php should tell you about your PHP
and Apache configuration, IF correctly installed and configured.

It's not generally recommended to parse HTML files a PHP files because the
interpreter has to look at every line, not just the sequences set apart by
PHP's open and close tags.

Apart from that I can't be much help. The other alternative is to grab one
of the WAMP packages which does a complete install of MySQL, Apache and PHP.

Good luck with this - Miles
Post by Jerry Adair
Hi Tommy/Keith/Newsgroup,
Thank you for the input, I REALLY appreciate it. I did everything you said
1) Yes I am running on Windows XP. So it seems that I shouldn't do any of
the "*.so" stuff that Keith mentioned, that seems like a UNIX thing. If I
can just get the thing to work, I will split my PHP definitions off into
another file just as Keith recommends. However for now I just want it to
work.
2) What exactly am I supposed to rename in the php directory? Your email
just said "rename the PHP file" ... the documentation says to rename either
the php.ini-recommended or php.ini-dist as php.ini. So I renamed the
php.ini-recommended to php.ini in my PHP directory, which I installed in
C:\php.
#JRA added this
#Preload the PHP interpreter so that Apache can find it
#even if it's not in the path
LoadFile "C:\php\php5ts.dll"
LoadModule php5_module "C:\php\php5apache2_2.dll"
PHPIniDir "C:\php"
AddHandler application/x-httpd-php .php
AddHandler application/x-httpd-php-source .phps
The problem with this is that I cannot find the "application" directory
ANYWHERE. I downloaded what I thought was/is the latest version of Apache
from a mirror site, but there is no application directory. Nothing in the
instructions mentions such a directory, that I read anyway. Do I just need
to create it manually? Confusing. I tried these definitions with both
forward and backward slashes, and it made no difference.
4) I did not copy the php.ini file anywhere.
5) I did add "C:\php" to the PATH environment variable. Is that really a
problem?
6) I have issued many "bin\httpd.exe -k [start|stop]" commands recently,
nothing has changed.
<html><body>
<h1>It works!</h1>
<?php
echo "PHP test\n";
?>
</body></html>
Note that I modified the file a bit just to see if I could get the php echo
text to appear in the browser in addition to the It works! text...
8) Is there an installation issue at work here? Do I need to install PHP
only AFTER installing Apache?
Thanks for any help. I am LOST!
Jerry
Keith,
If you can't get this working, and you are using a Windows, not Linux/Unix
machine, do the following (the online doc are not complete or detailed
1) Rename the PHP file in your PHP directory to PHP.ini (add the .ini extension to it).
2) In your Apache httpd.conf file (localed in the apache's conf directory do the following
Here is the proper apache directives to load php, preferbly saved as
php.conf and included from your main config.
#load the php main library to avoid dll hell
Loadfile "C:\pathtophp\php5ts.dll"
#load the sapi so that apache can use php
LoadModule php5_module "C:\pathtophp\php5apache2_2.dll"
#set the php.ini location so that you don't have to waste time guessing where it is
PHPIniDir "C:\pathtophp"
#Hook the php file extensions, notice that Addtype is NOT USED, since that's just stupid
AddHandler application/x-httpd-php .php
AddHandler application/x-httpd-php-source .phps
3)
Do not copy any php files anywhere
Do not edit the system path. If you have deleted them.
4) Delete any additions from you httpd.conf and php.ini that you have made
to try to get it to work.
5) restart your apache server. It should work.
Tommy Peterson
2008-07-06 18:32:04 UTC
Permalink
Also, since you made changes to the httpd.conf file, run a apache -t or a
httpd -t, depending upon the apache version, from the command line. It
will show you syntax errors, for example, if it can't find one of the php
files you added a statement for in the httpd.conf file. It will even give
you the line number.


If those are hte results you are getting for trying to browser, through
your server, for a php file Apache doesn't know what a php file is.
Post by Miles Thompson
Tommy Peterson's instructions look right. (Although I've never
installed on a Windows box.)
When you "stopped" Apache, did you check to see if an older
instance was running. That often catches the experts.
Did you do a check on Apache's configuration? (Usually apache2ctl -check)
Is Apache running as a service?
Does Apache render HTML?
Create this file, phpinfo.php, and put it in your docroot (webroot,
<?php
phpinfo();
?>
Then this URL: [ http://localhost/phpinfo.php
]http://localhost/phpinfo.php should tell you about your PHP and Apache
configuration, IF correctly installed and configured.
It's not generally recommended to parse HTML files a PHP files because
the interpreter has to look at every line, not just the sequences set
apart by PHP's open and close tags.
Apart from that I can't be much help. The other alternative is to grab
one of the WAMP packages which does a complete install of MySQL, Apache
and PHP.
Good luck with this - Miles
On Sun, Jul 6, 2008 at 12:02 PM, Jerry Adair <[
Hi Tommy/Keith/Newsgroup,
Thank you for the input, I REALLY appreciate it. I did everything you
1) Yes I am running on Windows XP. So it seems that I shouldn't do any
of the "*.so" stuff that Keith mentioned, that seems like a
UNIX thing. If I can just get the thing to work, I will split my PHP
definitions off into another file just as Keith recommends. However for
now I just want it to work.
2) What exactly am I supposed to rename in the php directory? Your email
just said "rename the PHP file" ... the documentation says to
rename either the php.ini-recommended or php.ini-dist as php.ini. So I
renamed the php.ini-recommended to php.ini in my PHP directory, which I
installed in C:\php.
#JRA added this
#Preload the PHP interpreter so that Apache can find it
#even if it's not in the path
LoadFile "C:\php\php5ts.dll"
LoadModule php5_module "C:\php\php5apache2_2.dll"
PHPIniDir "C:\php"
AddHandler application/x-httpd-php .php
AddHandler application/x-httpd-php-source .phps
The problem with this is that I cannot find the "application"
directory ANYWHERE. I downloaded what I thought was/is the latest
version of Apache from a mirror site, but there is no application
directory. Nothing in the instructions mentions such a directory, that I
read anyway. Do I just need to create it manually? Confusing. I tried
these definitions with both forward and backward slashes, and it made no
difference.
4) I did not copy the php.ini file anywhere.
5) I did add "C:\php" to the PATH environment variable. Is
that really a problem?
6) I have issued many "bin\httpd.exe -k [start|stop]" commands
recently, nothing has changed.
7) Below is what I get when typing [ http://localhost/ ]http://localhost
<html><body>
<h1>It works!</h1>
<?php
echo "PHP test\n";
?>
</body></html>
Note that I modified the file a bit just to see if I could get the php
echo text to appear in the browser in addition to the It works! text...
8) Is there an installation issue at work here? Do I need to install PHP
only AFTER installing Apache?
Thanks for any help. I am LOST!
Jerry
""Tommy Peterson"" <[
Keith,
If you can't get this working, and you are using a Windows, not
Linux/Unix machine, do the following (the online doc are not complete or
1) Rename the PHP file in your PHP directory to PHP.ini (add the .ini extension to it).
2) In your Apache httpd.conf file (localed in the apache's conf directory do the following
Here is the proper apache directives to load php, preferbly saved as
php.conf and included from your main config.
#load the php main library to avoid dll hell
Loadfile "C:\pathtophp\php5ts.dll"
#load the sapi so that apache can use php
LoadModule php5_module "C:\pathtophp\php5apache2_2.dll"
#set the php.ini location so that you don't have to waste time guessing where it is
PHPIniDir "C:\pathtophp"
#Hook the php file extensions, notice that Addtype is NOT USED, since that's just stupid
AddHandler application/x-httpd-php .php
AddHandler application/x-httpd-php-source .phps
3)
Do not copy any php files anywhere
Do not edit the system path. If you have deleted them.
4) Delete any additions from you httpd.conf and php.ini that you have
made to try to get it to work.
5) restart your apache server. It should work.
Continue reading on narkive:
Loading...