1

私は自分のウェブサイトを書き直して、eosgaming.comをwww.eosgaming.comに書き直そうとしています。

これが私のvirtual.confです

#
# A virtual host using mix of IP-, name-, and port-based configuration
#

#server {
#    listen       8000;
#    listen       somename:8080;
#    server_name  somename  alias  another.alias;

#    location / {
#        root   html;
#        index  index.html index.htm;
#    }
#}

server {
  listen 80;
  server_name eosgaming.com;
  rewrite ^/(.*) http://www.eosgaming.com/$1 permanent;
}

server {
    listen       80;
    server_name  .eosgaming.com;

    error_log /home/web/eosgaming.com/logs/error.log;

    root   /home/web/eosgaming.com/public_html/;
    index  index.html index.htm index.php;

    location ~ \.php$
    {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

server {
    listen       80;
    server_name  .forum.eosgaming.com;

    error_log /home/web/forums.eosgaming.com/logs/error.log;

    root   /home/web/forums.eosgaming.com/public_html/;
    index  index.html index.htm index.php;

    location ~ \.php$
    {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

server {
       listen   80;
       server_name .mysql.eosgaming.com;

       error_log /home/web/mysql.eosgaming.com/logs/error.log;

       root /usr/share/phpMyAdmin;

       location / {
           index  index.php;
       }

       ## Images and static content is treated different
       location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
           access_log        off;
           expires           360d;
       }

       location ~ /\.ht {
           deny  all;
       }

       location ~ /(libraries|setup/frames|setup/libs) {
           deny all;
           return 404;
       }

       location ~ \.php$ {
           include /etc/nginx/fastcgi_params;
           fastcgi_pass 127.0.0.1:9000;
           fastcgi_index index.php;
           fastcgi_param SCRIPT_FILENAME /usr/share/phpMyAdmin$fastcgi_script_name;
       }
}

server {
    listen       80;
    server_name  .source.eosgaming.com;

    error_log /home/web/source.eosgaming.com/logs/error.log;

    root   /home/web/source.eosgaming.com/public_html/;
    index  index.html index.htm index.php;

    location ~ \.php$
    {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

そして、これが私が得ているエラーです

[root@vd1 ~]# service nginx restart
nginx: [warn] conflicting server name "eosgaming.com" on 0.0.0.0:80, ignored
Stopping nginx:                                            [  OK  ]
Starting nginx: nginx: [warn] conflicting server name "eosgaming.com" on 0.0.0.0:80, ignored

この問題を解決するにはどうすればよいですか?自分のサイトにwwwを追加してもらいたいだけです。

4

2 に答える 2

1

最初の 2 つのサーバー ディレクティブを次のように 1 つにまとめることをお勧めします。

server {
    listen       80;
    server_name  eosgaming.com; #removed the . because its not needed

    if ($host ~* ^[^.]+\.[^.]+$) { #check if the host has no subdomain
        rewrite ^(.*)$ http://www.$host$1 permanent; #Rewrite the url to include www.
    }

    error_log /home/web/eosgaming.com/logs/error.log;

    root   /home/web/eosgaming.com/public_html/;
    index  index.html index.htm index.php;

    location ~ \.php$
    {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}
于 2012-12-15T20:46:18.373 に答える
0

.eosgaming.com;同等であるためeosgaming.com *.eosgaming.com;、と競合しserver_name eosgaming.com;ます。

于 2012-12-15T20:19:27.777 に答える