PHP_SELF is empty!

Last two days, I am playing or learning to play with nginx web server. I have heard some reputation about it and saw some performance chart in the web. I liked it for its, as claimed, extremely low memory footprint for one of my small VPS.

After reading some tutorial in Projanmo Forum, I am successfully configured nginx, with with fastcgi, php-fpm, mysql etc. When I visit the website, I found some problems. Some section were not working. Later I found, where I used $_SERVER[‘PHP_SELF’] were not not working. Later investigating the phpinfo(); I have seen that some global php variables are empty. I found nothing on net. Later alamgir bro, helped to sort out. In fact the whole tutorial is contributed by him.

Solving this issue is real easy. Just add the following the in your nginx php configuration section.

include        fastcgi_params

The changed codes may look like: [copied directly from his mail]

location ~ \.php$ {
root           /www;
fastcgi_index  index.php;

include        fastcgi_params;  #newly added

fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;



hope this will save your time :-).

  • Roshambo

    Dude, this really helped me out. Thanks for posting this — it totally answered a bunch of my questions.

  • Miao

    Thanks for your sharing. The same problem has been bothered me for quite a while before your article was found.

  • Thanx God i’ve found your article.. it really helped me.. I have some problems as you friends.. but it really works.. thanx again.. ionly had some other codes but in general everything is quite as written at your email,,

  • admin

    Thanks Andrew and Miao for your comment. I am glad to know that people had not wonder like me with this problem.

  • Andrew Hallock

    Thank you! I spent hours trying to get this to work.

  • nice info , thanks for that .