nginx多站点配置
一:nginx.conf 主文件配置(/opt/nginx/conf/nginx.conf)
user www www;
worker_processes 4;
worker_cpu_affinity 0001 0010 0100 1000;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid logs/nginx.pid;
#google_perftools_profiles /tmp/tcmalloc;
events {
use epoll;
worker_connections 65535;
}
http {
include mime.types;
default_type application/octet-stream;
\#log\_format main '$remote\_addr - $remote\_user \[$time\_local\] "$request" '
\# '$status $body\_bytes\_sent "$http\_referer" '
\# '"$http\_user\_agent" "$http\_x\_forwarded\_for"';
\#access\_log logs/access.log main;
server\_names\_hash\_bucket\_size 128;
client\_header\_buffer\_size 32k;
large\_client\_header\_buffers 4 32k;
client\_max\_body\_size 300m;
sendfile on;
tcp\_nopush on;
fastcgi\_connect\_timeout 300;
fastcgi\_send\_timeout 300;
fastcgi\_read\_timeout 300;
fastcgi\_buffer\_size 64k;
fastcgi\_buffers 4 64k;
fastcgi\_busy\_buffers\_size 128k;
fastcgi\_temp\_file\_write\_size 128k;
\#keepalive\_timeout 0;
keepalive\_timeout 60;
tcp\_nodelay on;
server\_tokens off;
gzip on;
gzip\_min\_length 1k;
gzip\_buffers 4 16k;
gzip\_http\_version 1.1;
gzip\_comp\_level 2;
gzip\_types text/plain application/x-javascript text/css application/xml;
gzip\_vary on;
server
\{
listen 80;
server\_name \_;
charset utf-8;
\#include rewrite.conf;
index index.php index.html index.htm;
server\_name\_in\_redirect off;
\#root /var/www/;
\#location ~ .\*\\.(php|php5)?$
\# \{
\# fastcgi\_pass unix:/tmp/php-cgi.sock;
\# fastcgi\_index index.php;
\# include fcgi.conf;
\# \}
\# location /status \{
\# stub\_status on;
\# access\_log off;
\# \}
\# location ~ .\*\\.(gif|jpg|jpeg|png|bmp|swf)$
\# \{
\# expires 30d;
\# \}
\# location ~ .\*\\.(js|css)?$
\# \{
\# expires 12h;
\# \}
\# access\_log off;
\}
include /usr/local/nginx/conf/vhost/*.conf;
}
二:nginx_site.conf(/opt/nginx/conf/vhost/nginx_site.conf)
server{
listen 80;
server_name www.88888888.com 88888888.com;
#include rewrite.conf;
#charset utf-8;
root /var/www/site;
index index.php index.html index.htm;
location ~ .*\.(php|php5)?$ {
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
#root /var/www/site;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /var/www/site$fastcgi_script_name;
# include fastcgi_params;
}
location /status {
stub_status on;
access_log off;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 30d;
}
location ~ .*\.(js|css)?$ {
expires 12h;
}
access\_log off;
location ~ /\\.ht \{
deny all;
}
}
三:nginx_fly.conf(/opt/nginx/conf/vhost/nginx_fly.conf)
server{
listen 80;
server_name fly.88888888.com;
#include rewrite.conf;
#charset utf-8;
root /var/www/union;
index index.php index.html index.htm;
location ~ .*\.(php|php5)?$ {
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /var/www/site$fastcgi_script_name;
# include fastcgi_params;
}
location /status {
stub_status on;
access_log off;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 30d;
}
location ~ .*\.(js|css)?$ {
expires 12h;
}
access\_log off;
location ~ /\\.ht \{
deny all;
}
}
还没有评论,来说两句吧...