1
回答
Ubuntu系统VPS下Nginx配置多域名失败,是否是配置的原因?
华为云数据库免费试用   

系统环境Ubuntu 14.04 x86。

我之前是完全按照VPS-Ubuntu中文这篇文章的方法来从头配置Nginx主机,可是当我在"/etc/nginx/sites-enabled/"目录下放入另外一个域名的信息的时候,都无法配置成功,使用“service nginx restart”重启Nginx服务的时候也都是失败(Fail)……

VPS上“/etc/nginx/sites-enabled/”目录下有“default”和“*.xxx.com”两个配置文件,代码分别如下:

default:

server {
   listen 80 default_server;
   listen [::]:80 default_server ipv6only=on;

   root /var/www;
   index index.html index.htm index.php;

   server_name *.*.*.*(主机所在IP地址);

   location / {
      # First attempt to serve request as file, then
      # as directory, then fall back to displaying a 404.
      try_files $uri $uri/ =404;
      # Uncomment to enable naxsi on this location
      # include /etc/nginx/naxsi.rules
        if (!-e $request_filename)
        {
                rewrite ^/(.+)$ /index.php last;
        }
   }
   
   location ~ \.php$ {
      include /etc/nginx/fastcgi_params;
      fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
      fastcgi_pass  127.0.0.1:9000;
      }
}


另外一个配置文件如下
server   {
   listen       80;
   server_name *.xxx.com;
   index index.html index.htm index.php;
   root  /var/www/*/;
   location ~ \.php$ {
      include /etc/nginx/fastcgi_params;
      fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
      fastcgi_pass  127.0.0.1:9000;
      }
   }

是不是我这样配置有冲突造成配置失败的呢?请教一下应该如何正确配置?

举报
candura
发帖于3年前 1回/451阅

以下是问题补充:

  • @candura :重启Nginx服务的时候系统就说了个“Fail”,后面我看error.log的时候,发现了这一条“2015/07/03 22:37:16 [emerg] 5169#0: unknown directive "?server" in /etc/nginx/sites-enabled/*.xxx.com:1” (3年前)
顶部