nginx多虚拟主机配置.docx_第1页
nginx多虚拟主机配置.docx_第2页
nginx多虚拟主机配置.docx_第3页
nginx多虚拟主机配置.docx_第4页
nginx多虚拟主机配置.docx_第5页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1.nginx.conf内容如下:程序代码worker_processes 1;error_log/host/nginx/logs/error.logcrit;pid/host/nginx/logs/nginx.pid;eventsworker_connections64;httpinclude/host/nginx/conf/mime.types;default_typeapplication/octet-stream;#charsetgb2312;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;gzipon;gzip_min_length1k;gzip_buffers 4 16k;gzip_http_version 1.0;gzip_comp_level 2;gzip_typestext/plain application/x-javascripttext/css application/xml;gzip_varyon;client_header_timeout3m;client_body_timeout3m;send_timeout3m;sendfileon;tcp_nopushon;tcp_nodelayon;#设定虚拟主机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目录下分别建立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_;#换成你的域名 charset gb2312; index index.htmlindex.htm index.php; root/host/wwwroot/test; #你的站点路径 #打开目录浏览,这样当没有找到index文件,就也已浏览目录中的文件 autoindexon;if(-d $request_filename) rewrite/(.*)(/)$ http:/$host/$1$2/ permanent; error_page404/404.html; location=/40x.html root/host/wwwroot/test; #你的站点路径 charseton; # redirect server error pages to thestaticpage/50x.html # error_page 500 502 503 504/50x.html; location=/50x.html root/host/wwwroot/test;#你的站点路径 charseton; #将客户端的请求转交给fastcgi location.*.(php|php5|php4|shtml|xhtml|phtml)?$ fastcgi_pass :9000; include/host/nginx/conf/fastcgi_params; #网站的图片较多,更改较少,将它们在浏览器本地缓存15天 location.*.(gif|jpg|jpeg|png|bmp|swf)$ expires15d; #网站会加载很多JS、CSS,将它们在浏览器本地缓存1天 location.*.(js|css)?$ expires1d; location/(WEB-INF)/ deny all; #设定日志格式 log_formataccess$remote_addr - $remote_user $time_local $request $status $body_bytes_sent $http_referer $http_user_agent $http_x_forwarded_for; #设定本虚拟主机的访问日志 access_log/host/nginx/logs/down/access.logaccess; #日志的路径,每个虚拟机一个,不能相同 server_name_in_redirectoff;3.www_test1_com.conf和www_test2_com.conf,文件和上面的基本相同,具体的日志内容如下:www_test1_com.conf如下:程序代码. #设定日志格式 log_formattest1$remote_addr - $remote_user $time_local $request $status $body_bytes_sent $http_referer $http_user_agent $http_x_forwarded_for; #设定本虚拟主机的访问日志 access_log/host/nginx/logs/test1/test1.logtest1; #日志的路径,每个虚拟机一个,不能相同 server_name_in_redirectoff;www_test2_com.conf如下:程序代码. #设定日志格式 log_formattest2$remote_addr - $remote_user $time_local $request $status $body_bytes_sent $http_referer $ht

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论