nginxを使用するのは初めてですが、cpanel以外のものを使用するのは初めてです... wwwを含めるとnginxを使用してドメインを取得するのに問題があります。 URLにwwwのドメインがnginxで動作していない
私は、名前付き設定ファイルまたはnginxのサーバー設定で間違いを犯したのかどうかはわかりません。私はちょっと急いで学んでいて、基本的な設定で何らかのエラーが出たら驚くことはありません。私は最新のnginx & php-fpmを実行します。私のドメインの問題とは別に動作します。
サブドメインを実行しようとしていますが、動作していますが、wwwを使用しています。 404になります。私はメインの.orgサーバドメインからネームサーバなどを使用します。 私はここに誰かが私が作っている、または作られている間違いを見つけられることを願って、関連性の高いものを投稿します。
$TTL 86400
mydomain.com. IN SOA ns1.servername.org. server.servername.org. (
2002012013; Serial
1H ; Refresh (change 1H to 6H in 3 days or so)
1800 ; Retry (change to 1H in 3 days)
2W ; Expire
1D); Minimum
mydomain.com. IN NS ns1.servername.org.
mydomain.com. IN NS ns2.servername.org.
ns1.servername.org. IN A 184.xxx.xxx.147
ns2.servername.org. IN A 184.xxx.xxx.148
mail.servername.org. IN A 184.xxx.xxx.146
mydomain.com. IN A 184.xxx.xxx.146
mydomain.com. IN MX 0 mail.servername.org.
@ A 184.xxx.xxx.146
www A 184.xxx.xxx.146
nginx.confの用途は、/ etc/nginxの/ * /サイト対応などが
etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
184.xxx.xxx.146 server.servername.org servername.org
named.confの
...
view "localhost_resolver" {
/* This view sets up named to be a localhost resolver (caching only nameserver).
* If all you want is a caching-only nameserver, then you need only define this view:
*/
# match-clients { 127.0.0.0/24; };
# match-destinations { localhost; };
match-clients { any; };
match-destinations { any; };
recursion no;
zone "servername.org" {
type master;
file "/var/named/servername.org.db";
};
// optional - we act as the slave (secondary) for the delegated domain
zone "mydomain.com" IN {
type slave;
file "/var/named/mydomain.com.db";
masters {10.10.0.24;};
};
allow-notify { 184.xxx.xxx.146; };
};
mydomain.com.db。 とnginxの「mydomain.com」設定
server {
server_name www.mydomain.com;
rewrite ^(.*) http://mydomain.com$1 permanent;
}
server {
listen 80;
server_name mydomain.com www.mydomain.com;
# access_log /srv/www/mydomain.com/logs/access.log;
error_log /srv/www/mydomain.com/logs/error.log;
root /srv/www/mydomain.com/public_html;
set $noadmin 1;
location/{
try_files $uri $uri/ /index.php?$args;
index index.html index.htm index.php;
}
# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
location ~ \.flv$ {
flv;
root /srv/www/mydomain.com/public_html;
}
location ~ \.mp4$ {
root /srv/www/mydomain.com/public_html;
mp4;
}
# use fastcgi for all php files
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /srv/www/mydomain.com/public_html$fastcgi_script_name;
include fastcgi_params;
}
# deny access to apache .htaccess files
location ~ /\.ht
{
deny all;
}
}
この時の私の恐ろしい試みは種類の動作しているようだので、私は、サブドメインにアクセスすることができ、私はwww.mydomain.comが、しばらく接続しない理由に貼り付けていますhttp://mydomain.comとなります。私は読んでいる/私は一緒に行くより多くを学ぶ、私は変更が何を理解するまで変更したくないです。私はURLより多くを壊してしまうかもしれません。
ありがとう:)第2のサーバーブロックからwwwを削除することは私のためのトリックでした。トップの書き換えは誰でもwwwを使用しているためです。代わりにhttp //に送信され、それも今働いていますが、私はそれをより効率的にすることができます。ご協力いただきありがとうございます! http://wiki.nginx.org/Pitfalls#Taxing_Rewrites – DOA
時にはserver_nameディレクティブを追加するには、 'http {server_names_hash_bucket_size NN}'を増やす必要があります。ここで、NNは32以上の数値です – nurettin