nginx配置文件

主配置:

user				charlie;
worker_processes	4;
worker_rlimit_nofile 10000;
worker_shutdown_timeout	300;

error_log			/var/log/nginx/error.log debug;
#error_log			/var/log/nginx/nitice.log  notice;
#error_log			/var/log/nginx/info.log  info;

pid					logs/nginx.pid;

events {
	worker_connections  1024;
    multi_accept on;
	use epoll;
}

http {

	access_log		/var/log/nginx/access.log combined;
	open_file_cache max=200000 inactive=20s;
	open_file_cache_valid 30s;
	open_file_cache_min_uses 2;
	open_file_cache_errors on;
	reset_timedout_connection on;
	client_body_timeout 200s; # Use 5s for high-traffic sites
	client_header_timeout 200s;


	include			mime.types;

 ##
# Basic Settings
##
	sendfile on;

	tcp_nopush on;
	tcp_nodelay on;
	keepalive_timeout 900;
	keepalive_requests 10000;
	types_hash_max_size 2048;
	#proxy_buffering off;
	proxy_connect_timeout 1600;
	proxy_send_timeout 1600;
	proxy_read_timeout 1600;
	send_timeout 1600;
	default_type application/octet-stream;

	gzip on;
	gzip_disable "msie6";
	server_names_hash_max_size	1024;
	include			nginx-conf/*;

}

虚拟主机配置:

server {
	listen       8090;
	server_name  project.com	www.project.com;

	root		/home/charlie/www;
	index		index.html index.htm index.php;

	error_log	/var/log/nginx/debug.log debug;
	rewrite_log	on;

	error_page	404			/404.html;
	location =	/404.html {
		return	404 'sorry, file not found!';
	}

	error_page	500 502 503 504	/50x.html;
	location =	/50x.html {
		root	/usr/local/nginx/html;
	}

	location / {
		try_files $uri @rewrite;
	}

	location @rewrite {
		set		$static 0;

		if ($uri ~ \.(css|js|jpg|jpeg|png|gif|ico|woff|eot|svg|css\.map|min\.map)$) {
			set	$static 1;
		}

		if ($static = 0) {
			rewrite ^/(.*)$ /index.php?s=/$1 last ;
		}

	}


	location ~ /Uploads/.*\.php$ {
		 deny	all;
	}

	location ~ \.php/ {
		if ($request_uri ~ ^(.+\.php)(/.+?)($|\?)) { }
		fastcgi_pass	127.0.0.1:9000;
		fastcgi_index	index.php;
		include			fastcgi_params;
		fastcgi_param	SCRIPT_NAME     $1;
		fastcgi_param	PATH_INFO       $2;
		fastcgi_param	SCRIPT_FILENAME $document_root$1;
	}

	location ~ \.php$ {
		fastcgi_index	index.php;
		fastcgi_pass	127.0.0.1:9000;
		fastcgi_param	SCRIPT_FILENAME $document_root$fastcgi_script_name;
		include			fastcgi_params;
	}

	location ~ /\.ht {
		deny			all;
	}
}

你可能感兴趣的:(Linux运维)