Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: PHP4 as CGI? |
|
Author |
|
Angela
Joined: 27 Oct 2006 Posts: 5 Location: Philippines
|
Posted: Fri 27 Oct '06 9:37 Post subject: PHP4 as CGI? |
|
|
Hello,
First off, this website has been quite helpful in getting SSL working for my Apache installation (I 've spent DAYS trying to get it to work with Apache 2.0.59!), and right now I'm happily coasting with Apache 2.2 and PHP5.1.6 (as well as MySQL).
However, I'm trying to get PHP4.4.4 to run concurrently, when I'm using php4.localhost instead of plain localhost (I'm using this tutorial as a guide) and while everything works now, I'm getting a 400 Bad Request whenever I try accessing PHP files in php4.localhost.
I've read a few docs/articles/threads/etc and I'm curious whether I'm having this problem because PHP 4.4.x can't run on Apache 2.2, hence the "special" dll build available on this site? Only that build is for running PHP 4.4.x as a module, not as a CGI... right?
Is running PHP4 with Apache 2.2 as CGI (as opposed to as a module) possible?
Thanks! |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
Posted: Fri 27 Oct '06 13:53 Post subject: Re: PHP4 as CGI? |
|
|
Angela wrote: | Hello,
However, I'm trying to get PHP4.4.4 to run concurrently, when I'm using php4.localhost instead of plain localhost (I'm using this tutorial as a guide) and while everything works now, I'm getting a 400 Bad Request whenever I try accessing PHP files in php4.localhost.
|
Code: |
<Directory "C:/Program Files/Apache Group/PHP4/">
Allow from all
</Directory>
|
Change the Directory where ever your cgi is and put it into your vhost.
Quote: |
Only that build is for running PHP 4.4.x as a module, not as a CGI... right?
|
right, you must take the php.exe for cgi. Why don't you want to run as modul? |
|
Back to top |
|
Brian
Joined: 21 Oct 2005 Posts: 209 Location: Puyallup, WA USA
|
Posted: Fri 27 Oct '06 17:56 Post subject: |
|
|
One reason I see for not running as module is stability. On Windows Apache and PHP are NOT stable if you call command line apps as in exec, shell_exec, virtual, and so on.
Example, I use ImageMagick heavily, very heavily in fact, and when I use command line via PHP module, about once a day to twice or more sometimes the HTTP server service must be stopped or killed, then started again.
When you take the execution of scripts outside Apache, hence CGI/FCGI, you don't need to worry about a thread crashing and bringing down the entire server. This problem plagues only Windows, and sadly the PHP / Apache dev teams don't recognize Windows as a viable hosting option, you MUST learn *nix to be a real sysadmin ... in their eyes.
I use a blend of PHP4 and PHP5, and I run FCGI and module. If a person does not call upon any command line scripts then I strongly suspect the module is a better way to go for speed, though Steffen has proven FCGI is better for memory management as well as being darn near as fast as SAPI. The module provides a better avenue of configuration for shared hosting environments. |
|
Back to top |
|
Angela
Joined: 27 Oct 2006 Posts: 5 Location: Philippines
|
Posted: Sat 28 Oct '06 1:04 Post subject: |
|
|
Thanks, I will try that once I am back at the office (I'm at home right now and it's the weekend). I have <Directory "D:/8. WWW - OLD"> in my cirtual host entry for php4.localhost, but I see why allowing php4 might (probably?) work.
I'm attempting to run PHP4 as CGI because I'm already running PHP5 as a module, like I said in my earlier post.
Brian, we're not using any CLI for our scripts, although it's possible in the future. Thanks for that info, I didn't know about that |
|
Back to top |
|
Brian
Joined: 21 Oct 2005 Posts: 209 Location: Puyallup, WA USA
|
Posted: Sat 28 Oct '06 1:39 Post subject: |
|
|
You can run PHP4 and PHP5 as SAPI at same time. Example you can run 4 as perhaps php4 and 5 as just PHP, it just depends.
You can also use .php for both, but run from different directories / locations. You can control PHP execution from the HTTPD.CONF or an include to limit or exanp how and where PHP is executed.
Q: Do you want to run PHP 4 and 5 from same vhost, or from different directories? |
|
Back to top |
|
Angela
Joined: 27 Oct 2006 Posts: 5 Location: Philippines
|
Posted: Sat 28 Oct '06 1:58 Post subject: |
|
|
I'm doing it the way this tutorial is doing it -- from different virtual hosts/directories. I don't want to rename my file extensions, as we're only "keeping" PHP4 in order to maintain the older systems while we're upgrading them to PHP5.
Both as SAPI -- what do you mean? The way I understand it, you mean both as an Apache module? I've read that it's not possible, and when I tried it, Apache wouldn't start. Is there a way to do that? I'd like to mimic live environment as much as possible, even if it's just for maintenance purposes, so if there is... please share
I'm including the relevant parts from my httpd.conf (I'd posted elsewhere, so I'm taking the info from there) in case that makes things a little clearer. As a refresher, everything works -- PHP5.1.6 works on localhost fine, I can access php4.localhost, but not serving PHP
Code: | ### PHP loader thingie
LoadModule php5_module "c:/php5/php5apache2.dll"
AddHandler application/x-httpd-php .php
# configure the path to php.ini
PHPIniDir "c:/php5"
### We now instruct apache to run PHP 4.4.4 on our D:/8. WWW - OLD directory
NameVirtualHost *:80
<VirtualHost *:80>
ServerName localhost
DocumentRoot "D:/8. WWW"
</VirtualHost>
<VirtualHost *:80>
ServerName php4.localhost
DocumentRoot "D:/8. WWW - OLD"
ServerAdmin seasonalplume at gmail.com
DirectoryIndex index.php index.html index.htm
ErrorLog logs/php4_error.log
CustomLog logs/php4_access.log combined
<Directory "D:/8. WWW - OLD">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
### PHP 4 Stuff now
# sort of patterned after php documentation
# SetEnv PHPRC "c:/php4"
# ScriptAlias /cgi-bin/ "D:/8. WWW - OLD/cgi-bin"
# Action application/x-httpd-php "c:/php4/php.exe"
# from the tutorial at devzone.zend.com/node/view/id/633
SetEnv PHPRC "c:/php4"
ScriptAlias /cgi-bin/ "D:/8. WWW - OLD/cgi-bin"
#Action php4-script /cgi-bin/php-cgi.exe
Action php4-script "c:/php4/php.exe"
AddHandler php4-script .php
</VirtualHost> |
|
|
Back to top |
|
Angela
Joined: 27 Oct 2006 Posts: 5 Location: Philippines
|
Posted: Mon 30 Oct '06 4:18 Post subject: |
|
|
Adding the below to the virtual host for php4.localhost isn't working
Code: | <Directory "C:/php4/">
Allow from all
</Directory> |
Any other ideas/suggestions? I'm still getting the same error. The error log for php4.localhost has a series of these errors:
Quote: | [Mon Oct 30 09:43:45 2006] [error] [client 127.0.0.1] Invalid URI in request GET / HTTP/1.1 |
As far as I know, I'm using the right php.exe for CGI -- PHP4 has no php-cgi.exe, and according to the php docs, when you're setting up PHP4 for CGI, you still use php.exe for PHP4, and php-cgi.exe is just for PHP5.
As a refresher, this is now my config relating to PHP5 module loading and PHP4 on a virtual host, "php4.localhost" --
Code: | ### PHP loader thingie
LoadModule php5_module "c:/php5/php5apache2.dll"
AddHandler application/x-httpd-php .php
# configure the path to php.ini
PHPIniDir "c:/php5"
### Virtual Host entry for php4.localhost
<VirtualHost *:80>
ServerName php4.localhost
DocumentRoot "D:/8. WWW - OLD"
ServerAdmin seasonalplume-at-gmail.com
DirectoryIndex index.php index.html index.htm
ErrorLog logs/php4_error.log
CustomLog logs/php4_access.log combined
<Directory "D:/8. WWW - OLD">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<Directory "C:/php4/"> # removing the slash doesn't work either
Allow from all
</Directory>
# PHP 4 Stuff now
SetEnv PHPRC "c:/php4"
ScriptAlias /cgi-bin/ "D:/8. WWW - OLD/cgi-bin"
ScriptAlias /php/ "c:/php4/"
#Action application/x-httpd-php "/php/php.exe"
Action php4-script "c:/php4/php.exe"
AddHandler php4-script .php
</VirtualHost> |
Thanks so much. I'm really quite at a loss and am rather distressed this is happening. |
|
Back to top |
|
Angela
Joined: 27 Oct 2006 Posts: 5 Location: Philippines
|
Posted: Mon 30 Oct '06 11:00 Post subject: |
|
|
Hello,
It works now. Thanks to those who tried to help, I appreciate it. |
|
Back to top |
|
|
|
|
|
|