不工作我是新來使用nginx的,好了,新的使用任何非的cPanel ...我有越來越域使用nginx的,當你包括WWW工作的問題。在網址中。WWW域在nginx的
www.mydomain.com > not work 404
mydomain.com > works
我不知道我是否犯了命名配置文件或服務器配置爲nginx錯誤。我有點急於學習,如果我在基本配置上犯了一些錯誤,我不會感到驚訝。我運行最新的nginx & php-fpm,除了我的域名問題它的作品。
我(想?)運行子域,他們的工作,但使用WWW。將導致404。我使用名稱服務器等從我的主要.org服務器域。 我將在後面發佈所有相關信息,希望這裏有人能夠發現我製作/製作的錯誤。
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
$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的/啓用的站點 -/*; 和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將。我一直在閱讀/學習,我不想在修改之前做出修改。我最終可能會破壞更多的網址。
謝謝:)從第二服務塊去除WWW的伎倆對我來說,在上面重寫是如此使用WWW的人。被髮送到http //,而現在也在工作,儘管我發現我可以提高效率。謝謝你的幫助! http://wiki.nginx.org/Pitfalls#Taxing_Rewrites – DOA 2012-04-02 05:14:46
有時添加更多的服務器名稱的指令可能需要以增加'HTTP {server_names_hash_bucket_size NN}'其中NN是一個數字> = 32 – nurettin 2015-05-24 05:41:14