PHP_SELF not set

I am trying to configure cacti under nginx. It makes heavy use of the
$_SERVER[‘PHP_SELF’] variable, but this isn’t getting set. I’ve tried
setting it explicitly; e.g.

fastcgi_param PHP_SELF $fastcgi_script_name;

but when I dump the $_SERVER variable from PHP it’s still not set. I’ve
tried passing other variables to PHP this way as a test, and I can see
them when I dump $_SERVER, so I’m wondering if nginx is stripping this,
and if there’s a workaround. I’m using the Ubuntu nginx 0.6.35 package
under jaunty.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,6565,6565#msg-6565

On Fri, Sep 11, 2009 at 21:15, durist [email protected] wrote:

I am trying to configure cacti under nginx. It makes heavy use of the $_SERVER[‘PHP_SELF’] variable, but this isn’t getting set. I’ve tried setting it explicitly; e.g.

 fastcgi_param PHP_SELF $fastcgi_script_name;

but when I dump the $_SERVER variable from PHP it’s still not set. I’ve tried passing other variables to PHP this way as a test, and I can see them when I dump $_SERVER, so I’m wondering if nginx is stripping this, and if there’s a workaround. I’m using the Ubuntu nginx 0.6.35 package under jaunty.

The latest stable version is 7.6.1, you could try compiling from
source. What’s Ubuntu’s default fastcgi_params file? Here are a few on
mine:

fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param DOCUMENT_URI $document_uri;

Are those on yours? I’ve commented out fastcgi_param DOCUMENT_ROOT
because i define that under each virtual host. Your nginx.conf could
also provide some clues, as well as PHP’s error log (set php.ini to
log to a file) and nginx’s error.log as well.

HTH,
Nuno Magalhães

vesperto Wrote:

Are those on yours? I’ve commented out
fastcgi_param DOCUMENT_ROOT
because i define that under each virtual host.
Your nginx.conf could
also provide some clues, as well as PHP’s error
log (set php.ini to
log to a file) and nginx’s error.log as well.

Thanks, I do have SCRIPT_NAME defined, and it is getting passed
correctly. There seems to be something special about PHP_SELF; it isn’t
defined in my nginx.conf or in my fastcgi_params, and when I dump
$_SERVER from php it’s set to a zero-length string. Again, explicitly
setting it in nginx.conf or fastcgi_params doesn’t do anything.

I can make cacti work by replacing all references to PHP_SELF with
REQUEST_URI, but that’s not a very maintainable solution.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,6565,6578#msg-6578

I can make cacti work by replacing all references to PHP_SELF with REQUEST_URI, but that’s not a very maintainable solution.

I have PHP_SELF in some parts of some sites (none i can find right
now…), anyway, i tried a simple

<?php echo $_SERVER['PHP_SELF'] ?>

in the index.php of a site’s docroot and it outputed /index.php, as
expected. What’s your php and php-cgi version?

vesperto Wrote:

expected. What’s your php and php-cgi version?
I am using the current Ubuntu jaunty packages:

ii php5-cgi 5.2.6.dfsg.1-3ubuntu4.2
server-side, HTML-embedded scripting languag
ii php5-cli 5.2.6.dfsg.1-3ubuntu4.2
command-line interpreter for the php5 script
ii php5-common 5.2.6.dfsg.1-3ubuntu4.2
Common files for packages built from the php
ii php5-gd 5.2.6.dfsg.1-3ubuntu4.2 GD
module for php5
ii php5-mysql 5.2.6.dfsg.1-3ubuntu4.2
MySQL module for php5
ii php5-snmp 5.2.6.dfsg.1-3ubuntu4.2
SNMP module for php5

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,6565,6586#msg-6586

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs