服務項目:網站建設、仿站、程序開發、APP開發設計、移動網站開發設計、企業網站設計、電子商務網站開發、網站維護、網站推廣、UX/UI 、HTML5、CSS3、JS / Jquery ...
          四川浚浚科技有限公司
          四川浚浚科技有限公司 (開發設計官網)TEL : 15308000360 / QQ : 38585404

          您的位置:首頁 > 技術經驗 > 服務器 > 正文

          NGINX多虛擬主機配置設置
          技術支持服務電話:15308000360 【7x24提供運維服務,解決各類系統/軟硬件疑難技術問題】

          1.nginx.conf 內容如下:

          worker_processes 1; 
          error_log /host/nginx/logs/error.log crit; 
          
          pid /host/nginx/logs/nginx.pid; 
          
          events { 
          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目錄下分別建立 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)$ 
          { 
          expires 15d; 
          } 
          
          #網站會加載很多JS、CSS,將它們在瀏覽器本地緩存1天 
          location ~ .*\.(js|css)?$ 
          { 
          expires 1d; 
          } 
          
          location /(WEB-INF)/ { 
          deny all; 
          } 
          
          #設定日志格式
          
          log_format access '$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.log access; #日志的路徑,每個虛擬機一個,不能相同 
          server_name_in_redirect off; 
          } 
          
          
          3.www_test1_com.conf和www_test2_com.conf,文件和上面的基本相同,具體的日志內容如下: www_test1_com.conf 如下:
          #設定日志格式
          log_format test1 '$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.log test1; #日志的路徑,每個虛擬機一個,不能相同
          server_name_in_redirect off;
          }
          
          www_test2_com.conf 如下:
          #設定日志格式
          log_format test2 '$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/test2/test2.log test2; #日志的路徑,每個虛擬機一個,不能相同
          server_name_in_redirect off;
          }
          



          上一篇:服務器高并發下的一些優化經驗
          下一篇:Apache開啟GZIP壓縮設置方法

          相關熱詞搜索:nginx 虛擬主機 配置方法 域名
          主站蜘蛛池模板: 久久99精品国产免费观看| 免费观看a级毛片| 91亚洲va在线天线va天堂va国产| 性xxxx18免费观看视频| 久久人人爽天天玩人人妻精品| 欧美亚洲国产精品久久高清| 亚洲精品自产拍在线观看动漫| 精品国产一区二区三区久久狼| 国产一级免费片| 黄色网站在线免费观看| 国产精品国产高清国产av| 99久久免费精品高清特色大片| 嫩草影院在线观看精品视频| 中文字幕无码精品亚洲资源网 | 亚洲婷婷第一狠人综合精品| 精品国产福利在线观看| 国产一国产a一级毛片| 黄色大片视频网站| 国产真实女人一级毛片| 3d玉蒲团之极乐宝鉴| 在线免费观看色片| a资源在线观看| 娇小老少配xxxxx丶| 三浦惠理子在线播放| 打扑克又痛又叫原声| 久久99精品久久久久久齐齐| 日本特黄特色aa大片免费| 久久精品国产亚洲av成人| 最近中文字幕免费mv在线视频| 亚洲伊人久久大香线蕉啊| 欧美日韩中文国产va另类| 亚洲精品456在线播放| 激情综合色五月丁香六月亚洲| 人妻少妇边接电话边娇喘| 男女下面的一进一出视频| 免费看电视电影| 精品一区二区三区视频在线观看| 加勒比色综合久久久久久久久 | 国产一级黄色片子| 萌白酱视频在线| 国产乱视频在线观看|