欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

詳解阿里云nginx服務(wù)器多站點(diǎn)的配置

 更新時(shí)間:2016年12月15日 11:13:21   作者:xxw1996  
本篇文章主要介紹了阿里云nginx服務(wù)器多站點(diǎn)的配置,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來(lái)看看吧

阿里云nginx服務(wù)器多站點(diǎn)的配置

今天配置了一下多站點(diǎn),記錄一下配置的過程...

1、首先要找到nginx 配置文件之所在,阿里云上的nginx.conf 文件上 /alidata/server/nginx-1.4.4/conf 中。

2、然后在conf目錄下創(chuàng)建一個(gè)vhosts 目錄,  這個(gè)目錄是用來(lái)存放不同站點(diǎn)的配置文件的。

3、然后呢, 在nginx.conf 最后 加入一行 include /alidata/server/nginx/conf/vhosts/*.conf;

user www www; 
worker_processes 1; 
 
error_log /alidata/log/nginx/error.log crit; 
pid    /alidata/server/nginx/logs/nginx.pid; 
 
#Specifies the value for maximum file descriptors that can be opened by this process.  
worker_rlimit_nofile 65535; 
 
events  
{ 
 use epoll; 
 worker_connections 65535; 
} 
 
 
http { 
  include    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; 
  client_max_body_size 8m; 
 
  sendfile on; 
  tcp_nopush   on; 
 
  keepalive_timeout 60; 
 
  tcp_nodelay 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; 
 
  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; 
  #limit_zone crawler $binary_remote_addr 10m; 
  log_format '$remote_addr - $remote_user [$time_local] "$request" ' 
         '$status $body_bytes_sent "$http_referer" ' 
         '"$http_user_agent" "$http_x_forwarded_for"'; 
          
  # 加入下面一行 表示將 vhosts 下面所有的 conf 文件包含進(jìn)來(lái) 
  include /alidata/server/nginx/conf/vhosts/*.conf; 
} 

4、然后,就是在vhosts 目錄下寫 你對(duì)應(yīng)站點(diǎn)的 conf 文件了。下面給出一個(gè)范例

server { 
  listen    80; 
  # 這個(gè)表示 網(wǎng)站域名, 可以是二級(jí)甚至多級(jí)域名 
  server_name localhost demo.com www.demo.com test.demo.com; 
 
  # 表示默認(rèn)索引文件 
  index index.html index.htm index.php; 
   
  # 該站點(diǎn)對(duì)應(yīng)的網(wǎng)站根目錄所在 
  root /alidata/www/demo; 
 
  location ~ .*\.(php|php5)?$ 
  { 
    #fastcgi_pass unix:/tmp/php-cgi.sock; 
    fastcgi_pass 127.0.0.1:9000; 
    fastcgi_index index.php; 
    include fastcgi.conf; 
  } 
  location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ 
  { 
    expires 30d; 
  } 
  location ~ .*\.(js|css)?$ 
  { 
    expires 1h; 
  } 
 
  # 偽靜態(tài)規(guī)則 
  include /alidata/server/nginx/conf/rewrite/phpwind.conf; 
  access_log /alidata/log/nginx/access/phpwind.log; 
} 

5、如果還要繼續(xù)添加, 直接復(fù)制文件。然后修改一下 server_name, root, 和access_log(如果有必要的話) 就OK了。

6、然后,不要立馬重啟nginx,應(yīng)該要先測(cè)試一下nginx 配置文件是否正常. 找到nginx 的 sbin目錄。 注意, 這個(gè)地方是nginx 的sbin 目錄(這個(gè)目錄與nginx 的conf 目錄是同級(jí)目錄)。linux 下有許多與sbin同名的目錄。 容易搞錯(cuò)。 在阿里云服務(wù)器上一般默認(rèn)的目錄是 /alidata/server/nginx-1.4.4/sbin。

7、輸入 cd /alidata/server/nginx-1.4.4/sbin,然后輸入  ./nginx -t ,如果控制臺(tái)顯示下面兩行,則表示配置成功了,否則請(qǐng)根據(jù)提示繼續(xù)檢查配置文件。

nginx: the configuration file /alidata/server/nginx/conf/nginx.conf syntax is ok

nginx: configuration file /alidata/server/nginx/conf/nginx.conf test is successful

8、配置成功之后, 就 需要重啟 nginx 服務(wù)器。 在sbin目錄下輸入命令:./nginx -s reload, 然后整個(gè)過程就完成了。

另外, 總結(jié)一下nginx 的幾個(gè)常用命令:

啟動(dòng)  

./nginx 

重啟  

./nginx -s reload 

關(guān)閉 

ps -ef | grep nginx   # 查詢nginx主進(jìn)程號(hào) 

從容停止   kill -QUIT 主進(jìn)程號(hào) 

快速停止   kill -TERM 主進(jìn)程號(hào) 

強(qiáng)制停止   kill -9 nginx 

若nginx.conf配置了pid文件路徑,如果沒有,則在logs目錄下 

kill -信號(hào)類型 '/usr/local/nginx/logs/nginx.pid'  

判斷配置文件是否正確 

./nginx -t 

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論