请教nginx添加配置域名的问题。
发布时间:2008-05-20 22:54:42来源:红联作者:suzee
请教nginx添加配置域名的问题。在网上淘了一会,淘到一点,请高手指点下。我主要想知道,添加多个域名的问题,
在google上搜到的一篇代码中,有一个片断是这样的,[code]server {
listen 12.34.56.78:80; # your server's public IP address
server_name domain.com; # your domain name
location / {
root /srv/www/nginx/domain.com; # absolute path to your WordPress installation
index index.php index.html index.htm;
# this serves static files that exist without running other rewrite tests
if (-f $request_filename) {
expires 30d;
break;
}
# this sends all non-existing file or directory requests to index.php
if (!-e $request_filename) {
rewrite ^(.+)$ /index.php?q=$1 last;
}[/code]请教的问题一:
那么如果一个服务器有多个ip,那么指定一个ip给一个域名,就是随便一个ip了?[code]server {
listen 12.34.56.78:80; # 这个ip只要是服务器上有的ip就可以了?
server_name domain.com ; # your domain name[/code]请教的问题二:
如果要多添加一个域名,是不是把一楼的代码片断直接复制,然后改一改直接添加到nginx.conf,如下:[code]server {
listen 12.34.56.78:80; # 这个改为123.123.123.123
server_name domain.com; # 这个改为 yourdomain.com
location / {
root /srv/www/nginx/domain.com; # 这个改为第二个域名的路径。
index index.php index.html index.htm;
# this serves static files that exist without running other rewrite tests
if (-f $request_filename) {
expires 30d;
break;
}
# this sends all non-existing file or directory requests to index.php
if (!-e $request_filename) {
rewrite ^(.+)$ /index.php?q=$1 last;
}[/code]