Welcome! Log In Create A New Profile

Advanced

direct access to page index.php by default

Posted by eki33 
direct access to page index.php by default
May 24, 2012 02:12PM
Hi all,

I'm trying to configure NGINX to define index.php as default home page.

The code here below doesn't work (the browser displays "no input file specified" with this config) but works well with a static index.html. however, a call to a php page from a static index.html home page works fine.


nginx.conf code:
location / {
root mnt/opt/www/mvc/;
index index.php;
}

location ~ \.php$ {
include /mnt/opt/etc/nginx/fastcgi_params;
}

fastcgi_params code:
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
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;

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;résulats dans access.log:
[24/May/2012:17:01:54 +0000] "GET / HTTP/1.1"404 36 "-"

Nota1 : error.log has no events.
Nota2 : nginx use php-fast-cgi

How could I make a default direct index.php working?

Thank you
Re: direct access to page index.php by default
May 24, 2012 02:31PM
The fastcgi settings must be inside the location block.
Re: direct access to page index.php by default
May 24, 2012 03:52PM
I think it's inside, cause I use an include instruction

I noticed that php is working fine for any other php scripts on this server

It's just the first index.php page that I can't define as default.

Thanks



Edited 1 time(s). Last edit at 05/24/2012 03:53PM by eki33.
Re: direct access to page index.php by default
May 26, 2012 07:22AM
OK, I think I found the solution for this issue;

The doc_root parameter in the PHP.INI must be set with the same value of the root parameter in the nginx.conf
Like this, php pages are found and run.

However, I still have a problem because I would like to use 3 differents servers (domains), using the same phpfcgi. And each of the 3 servers has different root folders, therefore I have only one server working fine with PHP files (the one with corresponding doc_root)

How to get the 3 servers working? multiple doc_root? mutliple php.ini? (I don't want multiple instances of PHP (very few memory!))

Thanks in advance
Re: direct access to page index.php by default
May 26, 2012 03:12PM
In php.ini you can add multiple sites with the [path.....] setting which can be different for each site just like you would do with nginx.

ea.:

[PATH=s:/webroot/forums.site.nl]
open_basedir = s:/webroot/forums.site.nl
doc_root = s:/webroot/forums.site.nl
upload_max_filesize = 32M

[PATH=s:/webroot/sdsc.site.nl]
open_basedir = s:/webroot/sdsc.site.nl
doc_root = s:/webroot/sdsc.site.nl
upload_max_filesize = 128M
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 145
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready