Nginx 的虛擬主機配置示例
[代碼] 兩個虛擬主機,純靜態http {
02 index index.html;
03
04 server {
05 server_name www.domain1.com;
06 access_log logs/domain1.access.log main;
07
08 root /var/www/domain1.com/htdocs;
09 }
10
11 server {
12 server_name www.domain2.com;
13 access_log logs/domain2.access.log main;
14
15 root /var/www/domain2.com/htdocs;
16 }
17 }
[代碼] A Default Catchall Virtual Hosthttp {
02 index index.html;
03
04 server {
05 listen 80 default;
06 server_name _;
07 access_log logs/default.access.log main;
08
09 server_name_in_redirect off;
10
11 root /var/www/default/htdocs;
12 }
13 } [代碼] 指定所有的二級域名server {
02 # Replace this port with the right one for your requirements
03 listen 80 ; #could also be 1.2.3.4:80
04
05 # Multiple hostnames separated by spaces. Replace these as well.
06 server_name star.yourdomain.com *.yourdomain.com; # Alternately: _
07
08 root /PATH/TO/WEBROOT/$host;
09
10 error_page 404 errors/404.html;
11 access_log logs/star.yourdomain.com.access.log;
12
13 index index.php index.html index.htm;
14
15 # serve static files directly
16 location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
17 access_log off;
18 expires max;
19 }
20
21 location ~ \.php$ {
22 include fastcgi_params;
23 fastcgi_intercept_errors on;
24 # By all means use a different server for the fcgi processes if you need to
25 fastcgi_pass 127.0.0.1:YOURFCGIPORTHERE;
26 }
27
28 location ~ /\.ht {
29 deny all;
30 }
31 }
[火星人
]
Nginx 的虛擬主機配置示例已經有665次圍觀
http://coctec.com/docs/service/show-post-14969.html