PDA

View Full Version : Getting PHP to work with Apache Win32


Charles Capps
05-19-1999, 06:05 PM
Ok, I'm fed up.[nbsp][nbsp]:(

As I don't have the means or guts to do a compile of PHP into Apache Win32, I tried the instructions listed at http://www.php.net/manual/install-windows95-nt.php3 but they don't seem to work too well...[nbsp][nbsp]Getting 400 Bad Request errors when I try to run a simple PHP script.

Could someone provide any tips on getting it installed?[nbsp][nbsp]Thanks...[nbsp][nbsp]*sigh*[nbsp][nbsp]I'm attempting to avoid that mailing list at all costs.[nbsp][nbsp]:)
------------------
"Okay, so I'm not "SANE" so to speak, but uh... I'm the lovable kind of psycho"
http://solareclipse.net/

Justin
05-19-1999, 11:11 PM
In your apache config file (httpd.conf) you should have these lines in there somewhere:

AddType application/x-httpd-php3 .php3 .php
AddType application/x-httpd-php3-source .phps

Those two should be there already and commented out - just uncomment them. Next you need these two (just a few lines down):

Action application/x-httpd-php3[nbsp][nbsp] /cgi-bin/php3/php.exe
Action application/x-httpd-source /cgi-bin/php3/php.exe

Then make sure php.exe and it's dll's are in a /php3 directory of your cgi-bin. This isn't as efficient as having it compiled into the core (something I haven't attemted yet and probably won't either) but for local testing / authoring of scripts it works fine. I would not, however, do a similar setup on a real web server, as this makes php.exe accessible from the web - but for local testing, although a little cumbersome, it works fine.

With that setup, it's like running php.exe as a script... I haven't had a problem doing it this way yet :)

The 400 bad request error, in this situation, usually means that it couldn't find php.exe in the specified location (or the location wasn't specified).

HTH...

<after reading the link above...>
I checked out the instructions in the guide you linked to above, and I like that idea better... they are setting up your php directory (c:\php3) as a ScriptAlias - aka another cgi-bin. So the above would be, instead:

Action application/x-httpd-php3[nbsp][nbsp] /php3/php.exe
Action application/x-httpd-source /php3/php.exe

I set mine up like that just now, and it sure makes it easier when you have several VirtualHosts set up locally - before I had to copy the php files into each cgi-bin hehe - now it works from one location :)

Those instructions should work though... let me know if not though.
</update>

Justin
[This message has been edited by Justin (edited 05-19-99)]

Charles Capps
05-20-1999, 12:38 AM
BAH![nbsp][nbsp]Now it works...[nbsp][nbsp]I was trying to route the Action to the path on the disk, not the path as it appeared on the server!

Yay![nbsp][nbsp]:-)
------------------
"Okay, so I'm not "SANE" so to speak, but uh... I'm the lovable kind of psycho"
http://solareclipse.net/

SneakyDave
05-20-1999, 11:36 AM
Hey, I'm trying to do the same thing, I THINK I've got Apache up and going with all the PHP extensions added.

I think I have a problem with PHP. Everytime I run the php.exe, I get a not found on the configuration file, although everything, including the registry, is correct.

I believe its because it wants php on my C drive, c:\PHP3\, but its currently on my D drive, d:\PHP3\.
Has anybody successfully used it anywhere than c:\php3\?

One question regarding both, if I wanted to reinstall everything, would it be as simple as deleting everything, and reinstalling, and possible changing a couple of the PHP registry entries?

I'm having some fun with it!

Thanks!
Sneaky

Justin
05-20-1999, 12:02 PM
I don't believe there are any registry entries needed for php... I just dropped the exe in a directory and it works...

For the ini file, make sure it's in your Windows directory (not Windows/System) and it's called php3.ini (it comes under php3.something that needs renamed...).

Let me know if this helps.

------------------
Justin Nelson
FutureQuest Support

SneakyDave
05-20-1999, 12:32 PM
That's where my php.ini is at, c:\windows\
I think it just doesn't like being on the D: drive.

I didn't think I needed any registry entries either, but there are some assigned, they originally were assigned to the c:\php3\ directory, but I changed them to the d:\php3\ directory. I'll move everything over to C: and see if that fixes it.

Sneaky
C is for cookie, that's good enough for me - Cookie Monster

Justin
05-20-1999, 03:42 PM
That's where my php.ini is at, c:\windows\
Unless this is a typo, that's your problem - it's php3.ini...

------------------
Justin Nelson
FutureQuest Support

SneakyDave
05-20-1999, 06:22 PM
Maybe that IS the problem, thanks Justin

SneakyDave
05-20-1999, 11:07 PM
Yep, that WAS the problem, thanks Justin

SneakyDave
05-20-1999, 11:47 PM
Well, now I have PHP working, but I think Apache is screwed up. Here's what I have:
PHP in D:\php3\ directory
httpd.conf has these entries:
AddType application/x-httpd-php3 .php3 .php
AddType application/x-httpd-php3-source .phps
Action application/x-httpd-php3[nbsp][nbsp] /php3/php.exe
Action application/x-httpd-source /php3/php.exe

php3.ini has these entries:
doc_root = \big\dom\xsneakydave
extension_dir =[nbsp][nbsp][nbsp][nbsp][nbsp]\php3

Ok, now when I have the Apache console running and I try to execute a PHP script, I get the dreaded &quot;The requested URL /php3/php.exe/junk.php3 was not found on this server.&quot; error.

When I do a localhost, I get the directory \big\dom\xsneakydave index from my hard drive, but when I execute a script, something must be set to make it think the script is in \php3\php3.exe?

Thanks for your time...
Sneaky

Justin
05-21-1999, 04:04 AM
That's because that is where you told apache to look for php.exe. You need to set up a ScriptAlias.

ScriptAlias /php3/ &quot;d:/php3/&quot;

Remember to use forward slashes like Unix, not backslashes. But that is just like the cgi-bin - when you ask the web server for /cgi-bin/, it points to wherever you set it to, eg /big/dom/xblah/cgi-bin/. You can map that to any drive you like, even a network drive I think.

I used to have it running in the cgi-bin, meaning I had php.exe and all of the DLL's in there - but now I run 3 different sites locally, so putting it in one central location was best (c:/php3 in my case).

Just put that directive in bold above in your httpd.conf file near the same statement for the cgi-bin and you should be all set :)

Lemme know...

------------------
Justin Nelson
FutureQuest Support

SneakyDave
05-21-1999, 07:58 PM
That's totally confusing to me, but I tried it out and it didn't work, same error, I have these two ScriptAliases:
ScriptAlias /cgi-bin/ &quot;D:/Apache/cgi-bin/&quot;
ScriptAlias /php3/ &quot;d:/php3/&quot;

My PHP3 script is in d:/big/dom/xsneakydave/

I'll mess around with it more this weekend.

Thanks
Sneaky

Justin
05-22-1999, 12:32 AM
You're running your cgi-bin in the apache directory? What you should do (keeping with mirroring FQ's directory structure) is:

ScriptAlias /cgi-bin/ &quot;d:/big/dom/xsneakydave/cgi-bin/&quot;
ScriptAlias /php3/ &quot;d:/php3/&quot;;

DocRoot &quot;d:/big/dom/xsneakydave/www&quot;[nbsp][nbsp]<-- Note: no ending slash

That should do it... I hope :)

------------------
Justin Nelson
FutureQuest Support

SneakyDave
05-22-1999, 11:44 AM
Justin, I think I have something else hosed up, mind if I email you with the details? Thanks
Sneaky