nginx多站点配置
2015-11-21 16:08
645 查看
一: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;
}
}
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;
}
}
相关文章推荐
- nginx 配置多个server 只有localhost可以访问
- 进一步了解nginx工作原理
- nginx虚拟配置
- nginx日志切割
- 嵌入式之Linux系统裁剪和定制---(kernel+busyboxy+dropbear+nginx)
- CentOS安装Nginx负载
- nginx rewrite不支持if 嵌套也不支持逻辑或和逻辑并
- nginx的301与302如何配置
- nginx $document_uri 参数使用
- CentOS下安装Nginx
- 转:Nginx配置指令location匹配符优先级和安全问题
- 解决yum安装nginx报No package nginx available
- nginx.conf绑定虚拟目录执行PHP
- Nginx日志分析脚本
- windows10打不开nginx应该怎么办?
- nginx负载均衡的5策略
- Nginx绑定多个域名
- Nginx配置服务器SSI
- Nginx服务器配置404页面
- nginx的操作指令