来源 v
51cto
http://blog.s135.com/tags/nginx/
中文文档:http://wiki.nginx.org/NginxChs
#用户 用户组
user www www;
#工作进程,根据硬件调整,有人说几核cpu,就配几个,我觉得可以多一点
worker_processes 5;
#错误日志
error_log logs/error.log;
#pid文件位置
pid logs/nginx.pid;
worker_rlimit_nofile 8192;
events {
#工作进程的最大连接数量,根据硬件调整,和前面工作进程配合起来用,尽量大,但是别把cpu跑到100%就行
worker_connections 4096;
}
http {
include conf/mime.types;
#反向代理配置,可以打开proxy.conf看看
include /etc/nginx/proxy.conf;
#fastcgi配置,可以打开fastcgi.conf看看
include /etc/nginx/fastcgi.conf;
default_type application/octet-stream;
#日志的格式
log_format main ‘$remote_addr – $remote_user [$time_local] $status ‘
‘”$request” $body_bytes_sent “$http_referer” ‘
‘”$http_user_agent” “$http_x_forwarded_for”’;
#访问日志
access_log logs/access.log main;
sendfile on;
tcp_nopush on;
#根据实际情况调整,如果server很多,就调大一点
server_names_hash_bucket_size 128; # this seems to be required for some vhosts
#这个例子是fastcgi的例子,如果用fastcgi就要仔细看
server { # php/fastcgi
listen 80;
#域名,可以有多个
server_name domain1.com www.domain1.com;
#访问日志,和上面的级别不一样,应该是下级的覆盖上级的
access_log logs/domain1.access.log main;
root html;
location / {
index index.html index.htm index.php;
}
#所有php后缀的,都通过fastcgi发送到1025端口上
#上面include的fastcgi.conf在此应该是有作用,如果你不include,那么就把fastcgi.conf的配置项放在这个下面。
location ~ .php$ {
fastcgi_pass 127.0.0.1:1025;
}
}
#这个是反向代理的例子
server { # simple reverse-proxy
listen 80;
server_name domain2.com www.domain2.com;
access_log logs/domain2.access.log main;
#静态文件,nginx自己处理
location ~ ^/(images|javascript|js|css|flash|media|static)/ {
root /var/www/virtual/big.server.com/htdo
51cto
http://blog.s135.com/tags/nginx/
中文文档:http://wiki.nginx.org/NginxChs
#用户 用户组
user www www;
#工作进程,根据硬件调整,有人说几核cpu,就配几个,我觉得可以多一点
worker_processes 5;
#错误日志
error_log logs/error.log;
#pid文件位置
pid logs/nginx.pid;
worker_rlimit_nofile 8192;
events {
#工作进程的最大连接数量,根据硬件调整,和前面工作进程配合起来用,尽量大,但是别把cpu跑到100%就行
worker_connections 4096;
}
http {
include conf/mime.types;
#反向代理配置,可以打开proxy.conf看看
include /etc/nginx/proxy.conf;
#fastcgi配置,可以打开fastcgi.conf看看
include /etc/nginx/fastcgi.conf;
default_type application/octet-stream;
#日志的格式
log_format main ‘$remote_addr – $remote_user [$time_local] $status ‘
‘”$request” $body_bytes_sent “$http_referer” ‘
‘”$http_user_agent” “$http_x_forwarded_for”’;
#访问日志
access_log logs/access.log main;
sendfile on;
tcp_nopush on;
#根据实际情况调整,如果server很多,就调大一点
server_names_hash_bucket_size 128; # this seems to be required for some vhosts
#这个例子是fastcgi的例子,如果用fastcgi就要仔细看
server { # php/fastcgi
listen 80;
#域名,可以有多个
server_name domain1.com www.domain1.com;
#访问日志,和上面的级别不一样,应该是下级的覆盖上级的
access_log logs/domain1.access.log main;
root html;
location / {
index index.html index.htm index.php;
}
#所有php后缀的,都通过fastcgi发送到1025端口上
#上面include的fastcgi.conf在此应该是有作用,如果你不include,那么就把fastcgi.conf的配置项放在这个下面。
location ~ .php$ {
fastcgi_pass 127.0.0.1:1025;
}
}
#这个是反向代理的例子
server { # simple reverse-proxy
listen 80;
server_name domain2.com www.domain2.com;
access_log logs/domain2.access.log main;
#静态文件,nginx自己处理
location ~ ^/(images|javascript|js|css|flash|media|static)/ {
root /var/www/virtual/big.server.com/htdo