raksmart活动促销

分享

写回答

发帖

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

国外VPS云主机 国外VPS云主机 1841 人阅读 | 1 人回复

发表于 2008-5-20 23:36:57 | 显示全部楼层 |阅读模式

请教nginx添加配置域名的问题。在网上淘了一会,淘到一点,请高手指点下。我主要想知道,添加多个域名的问题,
在google上搜到的一篇代码中,有一个片断是这样的,
  1. server {
  2. listen 12.34.56.78:80; # your server's public IP address
  3. server_name domain.com; # your domain name

  4. location / {
  5. root /srv/www/nginx/domain.com; # absolute path to your WordPress installation
  6. index index.php index.html index.htm;

  7. # this serves static files that exist without running other rewrite tests
  8. if (-f $request_filename) {
  9. expires 30d;
  10. break;
  11. }

  12. # this sends all non-existing file or directory requests to index.php
  13. if (!-e $request_filename) {
  14. rewrite ^(.+)$ /index.php?q=$1 last;
  15. }
复制代码
请教的问题一:

那么如果一个服务器有多个ip,那么指定一个ip给一个域名,就是随便一个ip了?
  1. server {
  2. listen 12.34.56.78:80; # 这个ip只要是服务器上有的ip就可以了?
  3. server_name domain.com ; # your domain name
复制代码
请教的问题二:
如果要多添加一个域名,是不是把一楼的代码片断直接复制,然后改一改直接添加到nginx.conf,如下:
  1. server {
  2. listen 12.34.56.78:80; # 这个改为123.123.123.123
  3. server_name domain.com; # 这个改为 yourdomain.com

  4. location / {
  5. root /srv/www/nginx/domain.com; # 这个改为第二个域名的路径。
  6. index index.php index.html index.htm;

  7. # this serves static files that exist without running other rewrite tests
  8. if (-f $request_filename) {
  9. expires 30d;
  10. break;
  11. }

  12. # this sends all non-existing file or directory requests to index.php
  13. if (!-e $request_filename) {
  14. rewrite ^(.+)$ /index.php?q=$1 last;
  15. }
复制代码

回答|共 1 个

riri11

发表于 2008-5-21 19:32:33 | 显示全部楼层

您不是研究的可以了么~~
您需要登录后才可以回帖 登录 | 注册

本版积分规则