E
E
Evgeny Terentiev2013-12-18 16:11:47
Nginx
Evgeny Terentiev, 2013-12-18 16:11:47

How to properly organize nginx configuration?

Hello, help me solve a small problem on setting up nginx.
In general, there is such a php application structure
/home/WebRoot/ecommerce/
/home/WebRoot/ecommerce/domains
/home/WebRoot/ecommerce/domains/example.com/www - statics
/home/WebRoot/ecommerce/bootstrap.php
You need to teach nginx look for statics and if not found send everything to bootstrap.php
Here is the current configuration:

server {
    listen       80;
    server_name  example.com;
    charset utf-8;

    root /home/WebRoot/ecommerce/;    

    location / {
      try_files /domains/example.com/www$uri /domains/example.com/www$uri/ /bootstrap.php?$args;
    }

    location ~* ^.+.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$ {
    	access_log off;
   	#expires 1m;
    } 

    location ~ \.php$ {
  fastcgi_split_path_info ^(.+\.php)(/.+)$;
  fastcgi_pass	unix:/var/run/php5-fpm.sock;
  fastcgi_index	index.php;
  fastcgi_param 	APP_ENV local;
  fastcgi_param 	APP_DOMAIN example.com;
        fastcgi_param 	SCRIPT_FILENAME   $document_root$fastcgi_script_name;
        include        	fastcgi_params;
    }    
}

But the problem is that nginx, when requesting "/", works on the very first try_files argument and does not pass everything to /bootstrap.php$args
Please tell me how to organize the configuration correctly.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Burov, 2013-12-18
@zein

Add

location = / {
        try_files /domains/example.com/www/index.html /bootstrap.php?$args;
    }

PS: You have /domains/example.com/www$uri listed twice in try_files

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question