Symfony2 nginx 标准配置文件

Symfony2 nginx 标准配置文件 适用于ubuntu+nginx+php5-fpm+Symfony2 2.4

server {
	#******************************site setting*****************************
	#listen   80; ## listen for ipv4; this line is default and implied
	#listen   [::]:80 default ipv6only=on; ## listen for ipv6

	root /var/web/host/Symfony/web;
	server_name host.thephoenixorg.com;
	server_name localhost;
	#******************************rewrite setting*****************************
	rewrite ^/app\.php/?(.*)$ /$1 permanent;

	location @rewriteapp {
        	rewrite ^(.*)$ /app.php/$1 last;
	}
	#******************************location setting*****************************
	#
	#autoindex on;
	charset utf-8;
	location / {
	    index app.php;
	    try_files $uri @rewriteapp;
  	}
	#*****************************error page setting*****************************
	#error_page 404 /404.html;
	#error_page 500 502 503 504 /50x.html;
	#location = /50x.html {
	#	root /usr/share/nginx/www;
	#}
	#*******************************php-fpm setting*****************************
	location ~ ^/.+\.php(/.*)?$ {
	    set $script $fastcgi_script_name;
  	    if ($document_uri ~ ^(.+\.php)(/.*)) {
	        set $script    $1;
	        set $path_info $2;
	    }
		# With php5-fpm-socket:
		fastcgi_pass unix:/tmp/php5-fpm.sock;
		include fastcgi_params;
		fastcgi_param SCRIPT_FILENAME $document_root$script;
 	    fastcgi_param SCRIPT_NAME     $script;
	    fastcgi_param PATH_INFO       $path_info;
	    fastcgi_param DOCUMENT_URI    $document_uri;
		fastcgi_index index.php;
	}
}

发表评论

电子邮件地址不会被公开。 必填项已用*标注