currently need to config a cgi which have not got a clue on my apache aerver how shall i set up and implement it so this can handle :
* Form handling
* Database access
* Searching
* Imagemap handling
setting up cgi on the apache server to handle php file?
Moderator: General Moderators
-
phpXploration
- Forum Newbie
- Posts: 1
- Joined: Mon Dec 12, 2005 1:22 pm
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Is there a reason you need CGI and not ISAPI? CGI will, to all intents and purposes will work just the same but is slower. Better off to run PHP as a module for apache.
When you set PHP up to use Apache on linux it's far easier to compile apache with apxs first and then add the compile flag --with-apxs[2]=/usr/local/apache/bin/apxs to PHP at ./configure in order to set up your httpd.conf for you.
If you really do *need* or indeed prefer to use CGI then the configuration of httpd.conf is relatively trivial.
You just need to create a script alias for the PHP binary and tell apache how to handle the php files (Change php4 to php if you're ony using CGI -- I have this configuration simply because I'm running PHP4 and 5 in parallel)...
You can set this up differently for any <Virtualhost>'s you have too 
When you set PHP up to use Apache on linux it's far easier to compile apache with apxs first and then add the compile flag --with-apxs[2]=/usr/local/apache/bin/apxs to PHP at ./configure in order to set up your httpd.conf for you.
If you really do *need* or indeed prefer to use CGI then the configuration of httpd.conf is relatively trivial.
You just need to create a script alias for the PHP binary and tell apache how to handle the php files (Change php4 to php if you're ony using CGI -- I have this configuration simply because I'm running PHP4 and 5 in parallel)...
Code: Select all
ScriptAlias /cgi /usr/bin
Action php4-cgi /cgi/php-cgi
AddHandler php4-cgi .php4I've also been trying to setup php on cgi mode but seems I have some problems. Reason I need to use cgi-mode is that I need to run php5 in parallel to php4, which runs as apache module.
I'm running apache2 on Debian, packages I have installed are: php5-cgi, php5-cli, php5-common, php5-gd andphp5-mysql.
Installation seems to be ok. I can do "/var/www/cgi-bin/php test.php" and get the correct output (test.php contains just call to phpinfo()).
However when I try to configure virtual host to use php5-cgi I run into problems. Here's my config (hostnames removed):
I have symlinked /var/www/cgi-bin/php to /projects/www/cgi-bin/php. Here's what I get in browser when I try to load the same test.php, now located in /projects/www:
What is happening here?
I'm running apache2 on Debian, packages I have installed are: php5-cgi, php5-cli, php5-common, php5-gd andphp5-mysql.
Installation seems to be ok. I can do "/var/www/cgi-bin/php test.php" and get the correct output (test.php contains just call to phpinfo()).
However when I try to configure virtual host to use php5-cgi I run into problems. Here's my config (hostnames removed):
Code: Select all
<VirtualHost x.y.z:*>
ServerAdmin x@y.z
ServerAlias x.y.z
DocumentRoot /projects/www
<Directory />
AddHandler php5-script .php
Action php5-script /cgi-bin/php
Options FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>Code: Select all
Warning: Unexpected character in input: ' ' (ASCII=15) state=1 in /usr/lib/cgi-bin/php5 on line 2102
Warning: Unexpected character in input: ' ' (ASCII=3) state=1 in /usr/lib/cgi-bin/php5 on line 2102
Warning: Unexpected character in input: ' in /usr/lib/cgi-bin/php5 on line 2102
Warning: Unexpected character in input: ' in /usr/lib/cgi-bin/php5 on line 2102
Parse error: parse error, unexpected T_STRING in /usr/lib/cgi-bin/php5 on line 2102To add some more info, there's nothing in apache logs that would help solve this.
Php installation is definetly ok, just tested the same thing but this time without virtual host, ie. copied test.php to new dir under "master" www-root and added
to apache config. Everything worked fine, phpinfo() reported php5 as it should.
So there's something wrong with my virtual host configuration but I can't figure out what :/
Php installation is definetly ok, just tested the same thing but this time without virtual host, ie. copied test.php to new dir under "master" www-root and added
Code: Select all
<Directory /var/www/test/>
AddHandler php5-script .php
Action php5-script /cgi-bin/php
</Directory>So there's something wrong with my virtual host configuration but I can't figure out what :/
Ok sorry to spam this thread but got it working. I just needed to add
ScriptAlias /cgi-bin /var/www/cgi-bin
inside virtualhost directives. I had tried this before but there was something else wrong at the time so didn't think of to try it again before now.. Maybe my monologue will be of help to someone else
ScriptAlias /cgi-bin /var/www/cgi-bin
inside virtualhost directives. I had tried this before but there was something else wrong at the time so didn't think of to try it again before now.. Maybe my monologue will be of help to someone else