linux的nginx添加域名,请教nginx添加配置域名的问题。

请教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]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值