Stupid newbie question (PHP's document_root in nginx and apache)
Nuno Magalhães
nunomagalhaes at eu.ipp.pt
Wed Feb 18 02:24:50 MSK 2009
Hi,
Nginx is working fine for me, serves PHP through fast-cgi, all is
cool. But, the code i working on runs both on nginx and apache, so i'm
running into trouble.
Specificaly, using this PHP-code:
<?php
print "documento root: ".$_SERVER['DOCUMENT_ROOT'];
?>
...will output in
nginx 0.6.34: /var/www/nginx-default
apache 2.2.3: /var/www/pea/
Both with PHP5
Yes, different paths, since they're on two different machines. Both
are running Debian unstable. My problem is the end / that nginx
doesn't have and apache does. Is there a basic fix for this? Is there
a standard? I'm using nginx as my test server and eventually i'll try
to replace apache on the other machine, but i'd like to grok the beast
first.
This is my /etc/nginx/nginx.conf
user www-data;
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
root /var/www/nginx-default;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
tcp_nodelay on;
gzip on;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
And my /etc/nginx/fastcgi_params
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
#fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param SERVER_SOFTWARE none;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
#fastcgi_param SERVER_NAME $server_name;
fastcgi_param SERVER_NAME none;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
How can i check this force-redirect thing? Through phpinfo()? Sorry
for the basic question but i couldn't really find anything useful and
#nginx on freenode right now has 70 non-persons. Is there a thorough
manual i can RTFM to fiddle eficiently with the conf file?
TIA,
Nuno Magalhães
LU#484677
More information about the nginx
mailing list