Thread: [cgiwrap-users] RE: #!/usr/bin/php
Brought to you by:
nneul
From: Neulinger, N. <nn...@um...> - 2002-08-09 14:23:44
|
Run it with cgiwrapd and see what it says.=20 You should not have to put the #! line or make the php file executable with the new options enabled.=20 -- Nathan ------------------------------------------------------------ Nathan Neulinger EMail: nn...@um... University of Missouri - Rolla Phone: (573) 341-4841 Computing Services Fax: (573) 341-4216 > -----Original Message----- > From: Daniel Nolte [mailto:dr...@gm...]=20 > Sent: Friday, August 09, 2002 9:13 AM > To: Neulinger, Nathan > Cc: cgi...@li... > Subject: #!/usr/bin/php >=20 >=20 > Hi, >=20 > do I have to put a #!/usr/bin/php in the beginning of every php file? > Of is there a way that is not need? Since I get an >=20 > CGIWrap encountered an error while attempting to execute > this script: >=20 > Error Message: Exec format error > Error Number: 8 >=20 > With adding #!/usr/bin/php - it works. >=20 >=20 >=20 > My configuration: > ./configure \ > --with-perl=3D/usr/bin/perl \ > --with-local-contact-name=3DWebVector \ > --with-local-contact-email=3Ds...@ph... \ > --with-local-contact-url=3Dhttp://support.phpmagic.de \ > --with-local-site-url=3Dhttp://www.phpmagic.de \ > --with-install-group=3Droot \ > --with-install-dir=3D/usr/lib/cgi-bin/cgiwrap \ > --with-cgi-dir=3Dhtdocs \ > --with-httpd-user=3Dwww-data \ > --with-php-path=3D/usr/bin/php \ > --with-php-interpreter \ > --with-php-cgiwrap \ > --with-minimum-uid=3D1000 \ > --with-logging-file=3D/var/log/apache/cgiwrap.log >=20 >=20 > <VirtualHost phpmagic.de> > ServerName phpmagic.de > ServerAlias phpmagic.de > DocumentRoot /var/chroot/_nossh/k060881/htdocs/phpmagic.de > ServerAdmin web...@ph...> > ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ > AddHandler cgi-wrapperd .php > AddHandler cgi-wrapperd .phtml > AddHandler cgi-wrapperd .cgi > Action cgi-wrapper /cgi-bin/cgiwrap/cgiwrap/k060881 > Action cgi-wrapperd /cgi-bin/cgiwrap/cgiwrapd/k060881 > </VirtualHost> >=20 >=20 >=20 >=20 >=20 |
From: Daniel N. <dr...@gm...> - 2002-08-09 15:06:17
|
Hi, > Looks from the output below like the php options didn't get build or > something... Make sure to do a make clean after you configure, and make > sure that PHP was detected properly when you ran configure. If it didn't > find php when you ran configure, it would have disabled the php > handling. What's configure output look like? *irghs* My fault I did a: " --with-php-path=/usr/bin/php4 " instead of " --with-php=/usr/bin/php4 ". Now it works nearly perfekt. I just have to work a bit on PATH_TRANSLATED. At the moment: PATH_TRANSLATED: '/var/chroot/_nossh/k060881/htdocs/phpmagic.de/k060881/test.php' Home Dir: '/var/chroot/_nossh/k060881' Script Base Directory: '/var/chroot/_nossh/k060881/htdocs' Script Absolute Path: '/var/chroot/_nossh/k060881/htdocs/test.php' But the real Script Absolute Path is /var/chroot/_nossh/k060881/phpmagic.de/test.php That is PATH_TRANSLATED where the last appereance of the username is removed. Is it possible to change that ?:) COMPLETE OUTPUT: *g* <OUTPUT> Initializing Logging Redirecting STDERR to STDOUT Setting SIGXCPU to default behaviour Environment Variables: QUERY_STRING: '' SCRIPT_NAME: '/cgi-bin/cgiwrap/cgiwrapd' SCRIPT_FILENAME: '/usr/lib/cgi-bin/cgiwrap/cgiwrapd' PATH_INFO: '/k060881/test.php' PATH_TRANSLATED: '/var/chroot/_nossh/k060881/htdocs/phpmagic.de/k060881/test.php' REMOTE_USER: '<NULL>' REMOTE_HOST: '<NULL>' REMOTE_ADDR: '80.142.156.229' Trying to extract user from PATH_INFO. Retrieved User Name: 'k060881' User Data Retrieved: UserID: 'k060881' UID: '1004' GID: '2000' Home Dir: '/var/chroot/_nossh/k060881' Script Base Directory: '/var/chroot/_nossh/k060881/htdocs' Fetching script string Trying to extract script from PATH_INFO Extracted PATH_INFO 'test.php' Building script path Condensing slashes. Script Relative Path: 'test.php' Script Absolute Path: '/var/chroot/_nossh/k060881/htdocs/test.php' Checking for special interpreted script (php). Interpreter Path: '/usr/bin/php4' Fixing Environment Variables. Environment Variables: QUERY_STRING: '' SCRIPT_NAME: '/cgi-bin/cgiwrap/cgiwrapd/k060881/test.php' SCRIPT_FILENAME: '/var/chroot/_nossh/k060881/htdocs/test.php' PATH_INFO: '' PATH_TRANSLATED: '/var/chroot/_nossh/k060881/htdocs' REMOTE_USER: '<NULL>' REMOTE_HOST: '<NULL>' REMOTE_ADDR: '80.142.156.229' Logging Request (File) UIDs/GIDs Changed To: RUID: '1004' EUID: '1004' RGID: '2000' EGID: '2000' Changing current directory to '/var/chroot/_nossh/k060881/htdocs' Output of script follows: ===================================================== X-Powered-By: PHP/4.1.2 Content-type: text/html just a test </OUTPUT> Bye Daniel |
From: Neulinger, N. <nn...@um...> - 2002-08-09 15:20:58
|
Re PATH_TRANSLATED... I guess i'm just not sure what it's "supposed" to be. You're saying that the script is physically located at: /var/chroot/_nossh/k060881/htdocs/test.php and that path translated is set to this by cgiwrap: /var/chroot/_nossh/k060881/htdocs and is originally this by apache: /var/chroot/_nossh/k060881/htdocs/phpmagic.de/k060881/test.php I'm willing to change what cgiwrap does, so long as someone can provide me a pointer to a reference that says exactly what PATH_TRANSLATED is supposed to do, assuming that cgiwrap has the necessary information at the time. It does clearly look like it's bogus from cgiwrap. I see this definition on one site: Definition: A virtual-to-physical mapping of PATH_INFO, which can be used directly as an absolute path or file, available as an environment variable for CGI scripts.=20 I've also seen this on oreilly's site: Besides passing query information to a CGI script, you can also pass additional data, known as extra path information, as part of the URL. The extra path information depends on the server knowing where the name of the program ends, and understanding that anything following the program name is "extra." Here is how you would call a script with extra path information: http://some.machine/cgi-bin/display.pl/cgi/cgi_doc.txt Since the server knows that display.pl is the name of the program, the string "/cgi/cgi_doc.txt" is stored in the environment variable PATH_INFO. Meanwhile, the variable PATH_TRANSLATED is also set, which maps the information stored in PATH_INFO to the document root directory (e.g., /usr/local/etc/httpd/ public/cgi/cgi-doc.txt).=20 That one makes it look like it should be DOCUMENT_ROOT + PATH_INFO. I can do that if those vars are passed. (I believe they are). But is that what y'all think that cgiwrap should set it do? Alternatively, I can just leave it alone, and merely strip out the "/user/" part? -- Nathan ------------------------------------------------------------ Nathan Neulinger EMail: nn...@um... University of Missouri - Rolla Phone: (573) 341-4841 Computing Services Fax: (573) 341-4216 > -----Original Message----- > From: Daniel Nolte [mailto:dr...@gm...]=20 > Sent: Friday, August 09, 2002 10:06 AM > To: Neulinger, Nathan > Cc: cgi...@li... > Subject: RE: #!/usr/bin/php >=20 >=20 > Hi, >=20 > > Looks from the output below like the php options didn't get build or > > something... Make sure to do a make clean after you configure, and > make > > sure that PHP was detected properly when you ran configure. If it > didn't > > find php when you ran configure, it would have disabled the php > > handling. What's configure output look like? >=20 > *irghs* > My fault I did a: " --with-php-path=3D/usr/bin/php4 " instead of > " --with-php=3D/usr/bin/php4 ". Now it works nearly perfekt. >=20 >=20 > I just have to work a bit on PATH_TRANSLATED. >=20 > At the moment:=20 >=20 > PATH_TRANSLATED: > '/var/chroot/_nossh/k060881/htdocs/phpmagic.de/k060881/test.php' >=20 > Home Dir: '/var/chroot/_nossh/k060881' >=20 > Script Base Directory: '/var/chroot/_nossh/k060881/htdocs' >=20 > Script Absolute Path: '/var/chroot/_nossh/k060881/htdocs/test.php' >=20 >=20 > But the real Script Absolute Path is=20 > /var/chroot/_nossh/k060881/phpmagic.de/test.php >=20 > That is PATH_TRANSLATED where the last appereance of the username is > removed. Is it possible to change that ?:) >=20 >=20 > COMPLETE OUTPUT: *g* >=20 > <OUTPUT> > Initializing Logging > Redirecting STDERR to STDOUT >=20 > Setting SIGXCPU to default behaviour >=20 >=20 > Environment Variables: > QUERY_STRING: '' > SCRIPT_NAME: '/cgi-bin/cgiwrap/cgiwrapd' > SCRIPT_FILENAME: '/usr/lib/cgi-bin/cgiwrap/cgiwrapd' > PATH_INFO: '/k060881/test.php' > PATH_TRANSLATED: > '/var/chroot/_nossh/k060881/htdocs/phpmagic.de/k060881/test.php' > REMOTE_USER: '<NULL>' > REMOTE_HOST: '<NULL>' > REMOTE_ADDR: '80.142.156.229' >=20 >=20 > Trying to extract user from PATH_INFO. > Retrieved User Name: 'k060881' >=20 > User Data Retrieved: > UserID: 'k060881' > UID: '1004' > GID: '2000' > Home Dir: '/var/chroot/_nossh/k060881' >=20 > Script Base Directory: '/var/chroot/_nossh/k060881/htdocs' > Fetching script string >=20 > Trying to extract script from PATH_INFO > Extracted PATH_INFO 'test.php' > Building script path >=20 > Condensing slashes. >=20 > Script Relative Path: 'test.php' > Script Absolute Path: '/var/chroot/_nossh/k060881/htdocs/test.php' > Checking for special interpreted script (php). > Interpreter Path: '/usr/bin/php4' >=20 > Fixing Environment Variables. >=20 > Environment Variables: > QUERY_STRING: '' > SCRIPT_NAME: '/cgi-bin/cgiwrap/cgiwrapd/k060881/test.php' > SCRIPT_FILENAME: '/var/chroot/_nossh/k060881/htdocs/test.php' > PATH_INFO: '' > PATH_TRANSLATED: '/var/chroot/_nossh/k060881/htdocs' > REMOTE_USER: '<NULL>' > REMOTE_HOST: '<NULL>' > REMOTE_ADDR: '80.142.156.229' >=20 > Logging Request (File) >=20 > UIDs/GIDs Changed To: > RUID: '1004' > EUID: '1004' > RGID: '2000' > EGID: '2000' >=20 > Changing current directory to '/var/chroot/_nossh/k060881/htdocs' >=20 >=20 >=20 > Output of script follows: > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > X-Powered-By: PHP/4.1.2 > Content-type: text/html >=20 > just a test >=20 > </OUTPUT> >=20 > Bye > Daniel >=20 >=20 >=20 >=20 >=20 |
From: Daniel N. <dr...@gm...> - 2002-08-09 15:38:09
|
Hi, > You're saying that the script is physically located at: > /var/chroot/_nossh/k060881/htdocs/test.php no, it is physically located in /var/chroot/_nossh/k060881/htdocs/phpmagic.de/test.php (For testing reason, I also placed a test.php in /var/chroot/_nossh/k060881/htdocs/test.php - so that I'm able to access it. But I requested /var/chroot/_nossh/k060881/htdocs/phpmagic.de/test.php, cgiwrap just constructed a wrong path out of it :()) >I'm willing to change what cgiwrap does, so long as someone can provide >me a pointer to a reference that says exactly what PATH_TRANSLATED is >supposed to do, assuming that cgiwrap has the necessary information at >the time. > It does clearly look like it's bogus from cgiwrap. > That one makes it look like it should be DOCUMENT_ROOT + PATH_INFO. I > can do that if those vars are passed. (I believe they are). I think the PATH_INFO will for cgiwrap - cgiwrap itself. So it wouldn't be really useable > Alternatively, I can just leave it alone, and merely strip out the > "/user/" part? This will work, aslong the username will never occur as directoryname. For me it's fine. And would really help me and should work for everyone else, too. Bye daniel |
From: Neulinger, N. <nn...@um...> - 2002-08-09 17:12:50
|
I just committed a change that results in slightly different behavior. Examples: (my home dir is /afs/umr.edu/users/nneul, server docroot is /local/apache-root/htdocs) /cgi-bin/cgiwrapd/nneul/test/fred Input: /local/apache-root/htdocs/nneul/test/fred Output: /local/apache-root/htdocs/fred i.e. DOCROOT + PATH_INFO Unfortunately, with ~, I can't handle in a straightforward manner at the moment, so it makes no change. (Apache already changes P_T to include user home dir.) /cgi-bin/cgiwrapd/~nneul/test/fred Input: /afs/umr.edu/users/nneul/public_html/test/fred Output: /afs/umr.edu/users/nneul/public_html/test/fred -- Nathan ------------------------------------------------------------ Nathan Neulinger EMail: nn...@um... University of Missouri - Rolla Phone: (573) 341-4841 Computing Services Fax: (573) 341-4216 > -----Original Message----- > From: Daniel Nolte [mailto:dr...@gm...]=20 > Sent: Friday, August 09, 2002 10:38 AM > To: Neulinger, Nathan > Cc: cgi...@li... > Subject: RE: #!/usr/bin/php >=20 >=20 > Hi,=20 >=20 > > You're saying that the script is physically located at: > > /var/chroot/_nossh/k060881/htdocs/test.php >=20 > no, it is physically located in > /var/chroot/_nossh/k060881/htdocs/phpmagic.de/test.php >=20 > (For testing reason, I also placed a test.php in > /var/chroot/_nossh/k060881/htdocs/test.php - so that I'm able=20 > to access > it. But I requested > /var/chroot/_nossh/k060881/htdocs/phpmagic.de/test.php, cgiwrap just > constructed a wrong path out of it :()) >=20 >=20 > >I'm willing to change what cgiwrap does, so long as someone=20 > can provide > >me a pointer to a reference that says exactly what PATH_TRANSLATED is > >supposed to do, assuming that cgiwrap has the necessary=20 > information at > >the time. > > It does clearly look like it's bogus from cgiwrap. > > That one makes it look like it should be DOCUMENT_ROOT +=20 > PATH_INFO. I > > can do that if those vars are passed. (I believe they are). >=20 > I think the PATH_INFO will for cgiwrap - cgiwrap itself. So=20 > it wouldn't > be really useable >=20 > > Alternatively, I can just leave it alone, and merely strip out the > > "/user/" part? >=20 > This will work, aslong the username will never occur as directoryname. > For me it's fine. And would really help me and should work=20 > for everyone > else, too. >=20 > Bye > daniel >=20 >=20 >=20 >=20 |
From: Neulinger, N. <nn...@um...> - 2002-08-09 17:14:03
|
I suppose that if the DOCUMENT_ROOT environment variable is present, I can just shortcut, and immediately set it to docroot+pi... I'll try that shortly. -- Nathan ------------------------------------------------------------ Nathan Neulinger EMail: nn...@um... University of Missouri - Rolla Phone: (573) 341-4841 Computing Services Fax: (573) 341-4216 > -----Original Message----- > From: Neulinger, Nathan=20 > Sent: Friday, August 09, 2002 12:13 PM > To: 'Daniel Nolte' > Cc: cgi...@li... > Subject: RE: #!/usr/bin/php >=20 >=20 > I just committed a change that results in slightly different behavior. >=20 > Examples: (my home dir is /afs/umr.edu/users/nneul, server=20 > docroot is /local/apache-root/htdocs) >=20 > /cgi-bin/cgiwrapd/nneul/test/fred > Input: /local/apache-root/htdocs/nneul/test/fred > Output: /local/apache-root/htdocs/fred >=20 > i.e. DOCROOT + PATH_INFO >=20 > Unfortunately, with ~, I can't handle in a straightforward=20 > manner at the moment, so it makes no change. (Apache already=20 > changes P_T to include user home dir.) >=20 > /cgi-bin/cgiwrapd/~nneul/test/fred > Input: /afs/umr.edu/users/nneul/public_html/test/fred > Output: /afs/umr.edu/users/nneul/public_html/test/fred >=20 > -- Nathan >=20 > ------------------------------------------------------------ > Nathan Neulinger EMail: nn...@um... > University of Missouri - Rolla Phone: (573) 341-4841 > Computing Services Fax: (573) 341-4216 >=20 >=20 > > -----Original Message----- > > From: Daniel Nolte [mailto:dr...@gm...]=20 > > Sent: Friday, August 09, 2002 10:38 AM > > To: Neulinger, Nathan > > Cc: cgi...@li... > > Subject: RE: #!/usr/bin/php > >=20 > >=20 > > Hi,=20 > >=20 > > > You're saying that the script is physically located at: > > > /var/chroot/_nossh/k060881/htdocs/test.php > >=20 > > no, it is physically located in > > /var/chroot/_nossh/k060881/htdocs/phpmagic.de/test.php > >=20 > > (For testing reason, I also placed a test.php in > > /var/chroot/_nossh/k060881/htdocs/test.php - so that I'm able=20 > > to access > > it. But I requested > > /var/chroot/_nossh/k060881/htdocs/phpmagic.de/test.php, cgiwrap just > > constructed a wrong path out of it :()) > >=20 > >=20 > > >I'm willing to change what cgiwrap does, so long as someone=20 > > can provide > > >me a pointer to a reference that says exactly what=20 > PATH_TRANSLATED is > > >supposed to do, assuming that cgiwrap has the necessary=20 > > information at > > >the time. > > > It does clearly look like it's bogus from cgiwrap. > > > That one makes it look like it should be DOCUMENT_ROOT +=20 > > PATH_INFO. I > > > can do that if those vars are passed. (I believe they are). > >=20 > > I think the PATH_INFO will for cgiwrap - cgiwrap itself. So=20 > > it wouldn't > > be really useable > >=20 > > > Alternatively, I can just leave it alone, and merely strip out the > > > "/user/" part? > >=20 > > This will work, aslong the username will never occur as=20 > directoryname. > > For me it's fine. And would really help me and should work=20 > > for everyone > > else, too. > >=20 > > Bye > > daniel > >=20 > >=20 > >=20 > >=20 >=20 |
From: Daniel N. <dr...@gm...> - 2002-08-09 18:03:31
|
Hi >I suppose that if the DOCUMENT_ROOT environment variable is present, I >can just shortcut, and immediately set it to docroot+pi... I'll try that >shortly. Wonderfull, any idee when I can test it ?:) *g Bye Daniel |
From: Daniel N. <dr...@gm...> - 2002-08-09 14:32:03
|
> You should not have to put the #! line or make the php file executable > with the new options enabled. Btw. Do you have a amazon wishlist ?:) The Output: (with a #!/usr/bin/php the script works) Initializing Logging Redirecting STDERR to STDOUT Setting SIGXCPU to default behaviour Environment Variables: QUERY_STRING: '' SCRIPT_NAME: '/cgi-bin/cgiwrap/cgiwrapd' SCRIPT_FILENAME: '/usr/lib/cgi-bin/cgiwrap/cgiwrapd' PATH_INFO: '/k060881/test.php' PATH_TRANSLATED: '/var/chroot/_nossh/k060881/htdocs/phpmagic.de/k060881/test.php' REMOTE_USER: '<NULL>' REMOTE_HOST: '<NULL>' REMOTE_ADDR: '80.142.156.229' Trying to extract user from PATH_INFO. Retrieved User Name: 'k060881' User Data Retrieved: UserID: 'k060881' UID: '1004' GID: '2000' Home Dir: '/var/chroot/_nossh/k060881' Script Base Directory: '/var/chroot/_nossh/k060881/htdocs' Fetching script string Trying to extract script from PATH_INFO Extracted PATH_INFO 'test.php' Building script path Condensing slashes. Script Relative Path: 'test.php' Script Absolute Path: '/var/chroot/_nossh/k060881/htdocs/test.php' Fixing Environment Variables. Environment Variables: QUERY_STRING: '' SCRIPT_NAME: '/cgi-bin/cgiwrap/cgiwrapd/k060881/test.php' SCRIPT_FILENAME: '/var/chroot/_nossh/k060881/htdocs/test.php' PATH_INFO: '' PATH_TRANSLATED: '/var/chroot/_nossh/k060881/htdocs' REMOTE_USER: '<NULL>' REMOTE_HOST: '<NULL>' REMOTE_ADDR: '80.142.156.229' Logging Request (File) UIDs/GIDs Changed To: RUID: '1004' EUID: '1004' RGID: '2000' EGID: '2000' Changing current directory to '/var/chroot/_nossh/k060881/htdocs' Output of script follows: ===================================================== ***************** * CGIWrap Error * ***************** CGIWrap encountered an error while attempting to execute this script: Error Message: Exec format error Error Number: 8 This message usually indicates there is a problem with the script itself. Often this indicates either that the #! line of the script is incorrect, or the script was uploaded in binary mode instead of ascii mode. Check to make sure that the script does not have control-M's at the end of every line. That will prevent it from executing. An easy fix that takes care of this most of the time is to put '#!/.../perl --' instead of '#!/.../perl' on the first line of the script. This is typically a problem if the script was edited or uploaded from a DOS/Windows/Macintosh station to a unix based server. If you are not the owner of this script, please forward this error and the URL that caused it to the script owner. That is often the component in the URL right after /cgiwrap/. **************************************** * Local Information and Documentation: * **************************************** Web Site: http://www.phpmagic.de Contact Name: WebVector Contact EMail: su...@ph... Contact Web Site: http://support.phpmagic.de **************** * Server Data: * **************** Server Administrator/Contact: web...@ph...> Server Name: phpmagic.de Server Port: 80 Server Protocol: HTTP/1.1 ***************** * Request Data: * ***************** User Agent/Browser: Mozilla/4.0 (compatible; MSIE 5.0; Windows XP) Opera 6.04 [de] Request Method: GET Remote Address: 80.142.156.229 Remote Port: 1802 |