nginx/windows: nginx多虚拟…
2016-03-04 09:58
706 查看
1.nginx.conf内容如下:
worker_processes 2;
error_log /host/nginx/logs/error.log
crit;
pid /host/nginx/logs/nginx.pid;
events {
use
epoll;
worker_connections 64;
}
http {
include
/host/nginx/conf/mime.types;
default_type
application/octet-stream;
#charset gb2312;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
keepalive_timeout 60;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 128k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
client_body_temp_path /host/nginx/client_body_temp;
proxy_temp_path /host/nginx/proxy_temp;
fastcgi_temp_path /host/nginx/fastcgi_temp;
gzip on;
gzip_min_length 1k;
gzip_buffers
4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types
text/plain application/x-javascript text/css
application/xml;
gzip_vary on;
client_header_timeout 3m;
client_body_timeout
3m;
send_timeout
3m;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
#设定虚拟主机
include
/host/nginx/conf/vhost/www_test_com.conf;
include
/host/nginx/conf/vhost/www_test1_com.conf;
include
/host/nginx/conf/vhost/www_test2_com.conf;
}
2.在conf目录下建立个vhost目录,在vhost目录下分别建立
<
4000
p style="white-space:normal;text-transform:none;word-spacing:0px;color:rgb(69,69,69);padding-bottom:0px;padding-top:0px;font:14px/21px tahoma, helvetica, arial;padding-left:0px;margin:0px;letter-spacing:normal;padding-right:0px;background-color:rgb(255,255,255);text-indent:0px;">
www_test_com.conf,www_test1_com.conf,www_test2_com.conf 3个文件
www_test_com.conf代码如下:
server {
listen
202.***.***.***:80;
#换成你的IP地址
client_max_body_size 100M;
server_name
www.test.com; #换成你的域名
charset gb2312;
index index.html index.htm index.php;
root
/host/wwwroot/test;
#你的站点路径
#打开目录浏览,这样当没有找到index文件,就也已浏览目录中的文件
autoindex on;
if (-d
$request_filename) {
rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
}
error_page
404 /404.html;
location = /40x.html {
root /host/wwwroot/test;
#你的站点路径
charset
on;
}
# redirect server error pages to the static page
/50x.html
#
error_page
500 502 503
504 /50x.html;
location = /50x.html {
root
/host/wwwroot/test;
#你的站点路径
charset
on;
}
#将客户端的请求转交给fastcgi
location ~
.*\.(php|php5|php4|shtml|xhtml|phtml)?$ {
fastcgi_pass
127.0.0.1:9000;
include /host/nginx/conf/fastcgi_params;
}
#网站的图片较多,更改较少,将它们在浏览器本地缓存15天
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
worker_processes 2;
error_log /host/nginx/logs/error.log
crit;
pid /host/nginx/logs/nginx.pid;
events {
use
epoll;
worker_connections 64;
}
http {
include
/host/nginx/conf/mime.types;
default_type
application/octet-stream;
#charset gb2312;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
keepalive_timeout 60;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 128k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
client_body_temp_path /host/nginx/client_body_temp;
proxy_temp_path /host/nginx/proxy_temp;
fastcgi_temp_path /host/nginx/fastcgi_temp;
gzip on;
gzip_min_length 1k;
gzip_buffers
4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types
text/plain application/x-javascript text/css
application/xml;
gzip_vary on;
client_header_timeout 3m;
client_body_timeout
3m;
send_timeout
3m;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
#设定虚拟主机
include
/host/nginx/conf/vhost/www_test_com.conf;
include
/host/nginx/conf/vhost/www_test1_com.conf;
include
/host/nginx/conf/vhost/www_test2_com.conf;
}
2.在conf目录下建立个vhost目录,在vhost目录下分别建立
<
4000
p style="white-space:normal;text-transform:none;word-spacing:0px;color:rgb(69,69,69);padding-bottom:0px;padding-top:0px;font:14px/21px tahoma, helvetica, arial;padding-left:0px;margin:0px;letter-spacing:normal;padding-right:0px;background-color:rgb(255,255,255);text-indent:0px;">
www_test_com.conf,www_test1_com.conf,www_test2_com.conf 3个文件
www_test_com.conf代码如下:
server {
listen
202.***.***.***:80;
#换成你的IP地址
client_max_body_size 100M;
server_name
www.test.com; #换成你的域名
charset gb2312;
index index.html index.htm index.php;
root
/host/wwwroot/test;
#你的站点路径
#打开目录浏览,这样当没有找到index文件,就也已浏览目录中的文件
autoindex on;
if (-d
$request_filename) {
rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
}
error_page
404 /404.html;
location = /40x.html {
root /host/wwwroot/test;
#你的站点路径
charset
on;
}
# redirect server error pages to the static page
/50x.html
#
error_page
500 502 503
504 /50x.html;
location = /50x.html {
root
/host/wwwroot/test;
#你的站点路径
charset
on;
}
#将客户端的请求转交给fastcgi
location ~
.*\.(php|php5|php4|shtml|xhtml|phtml)?$ {
fastcgi_pass
127.0.0.1:9000;
include /host/nginx/conf/fastcgi_params;
}
#网站的图片较多,更改较少,将它们在浏览器本地缓存15天
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
相关文章推荐
- nginx的 CPU参数worker_proce…
- nginx的valid_referers指令防盗链
- Nginx+CI框架出现404错误怎么解决
- ubuntu+nginx+php7+mysql 安装
- Nginx配置Restful风格url
- nginx上搭建HLS流媒体服务器
- LNMP第二部分nginx、php配置
- nginx配置文件nginx.conf解读
- 发现一个nginx LUA开发Web App的框架
- Scaling CloudFlare’s Massive WAF
- centos6 yum 安装nginx 不成功解决办法
- nginx 同一端口根据不同域名转发到不同端口
- Nginx+CI出现404错误
- Nginx+CI出现404错误
- Nginx配置文件各配置项详细说明
- ubuntu下的nginx+php配置与常见问题
- CORS其实很简单:NGINX 一招搞定针对特定域名和端口跨域,动态决定跨域到哪里
- nginx location匹配
- nginx-1.5.10 之mips编译到RT5350
- nginx的配置系统