如标题所述,这个问题很奇怪。以下是详细信息:
1)使用" a1"创建A记录。意味着子域名为:a1.example.com
,
2)按"sudo mkdir -p /var/www/a1.example.com/html/"
3)按"sudo nano /etc/nginx/sites-available/a1.example.com"
4)在服务器块内部,核心部分:
server {
listen 80;
listen [::]:80;
root /var/www/a1.example.com/html;
index index.html index.htm;
server_name a1.example.com
location / {
try_files $uri $uri/ =404;
}
}
5)创建了链接:sudo ln -s /etc/nginx/sites-available/a1.example.com /etc/nginx/sites-enabled/
6)sudo nano /etc/nginx/nginx.conf
,取消注释:server_names_hash_bucket_size 64;
确保:include /etc/nginx/sites-enabled/*;
在那里
7)重新启动nginx:sudo service nginx restart
棘手的部分:通过这样做,第一个子域a1.example.com
正常工作。
但是,当我尝试按照上述确切步骤创建第二个子域b2.example.com
时,b2.example.com
根本无法正常工作:它会重定向到主页面,但网址仍为{{1} }}
什么可能是错的?
非常感谢你!配置b2.example.com
a1.example.com
配置server {
listen 80;
listen [::]:80;
root /var/www/a1.example.com/html;
index index.php index.html index.htm;
server_name a1.example.com;
rewrite ^/archives/(\d+)$ http://a1.example.com/?p=$1 permanent;
location / {
try_files $uri $uri/ /index.php?q=$uri&args;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
}
}
b2.example.com
来自access.log的日志的一部分
server {
listen 80;
listen [::]:80;
root /var/www/b2.example.com/html;
index index.php index.html index.htm;
server_name b2.example.com;
rewrite ^/archives/(\d+)$ http://b2.example.com/?p=$1 permanent;
location / {
try_files $uri $uri/ /index.php?q=$uri&args;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
}
}
我注意到了#34; 304"和" 301",http状态。但仍然没有线索
[my IP address] - - [04/Feb/2016:00:11:05 -0500] "GET / HTTP/1.1" 200 147 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:43.0) Gecko/20100101 Firefox/43.0"
[my IP address] - - [04/Feb/2016:00:11:05 -0500] "GET /favicon.ico HTTP/1.1" 404 142 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:43.0) Gecko/20100101 Firefox/43.0"
[my IP address] - - [04/Feb/2016:00:11:08 -0500] "GET / HTTP/1.1" 200 17176 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:43.0) Gecko/20100101 Firefox/43.0"
[my IP address] - - [04/Feb/2016:00:11:09 -0500] "GET /wp-includes/css/dashicons.min.css?ver=4.4.1 HTTP/1.1" 304 0 "http://b2.example.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:43.0) Gecko/20100101 Firefox/43.0"
[my IP address] - - [04/Feb/2016:00:11:09 -0500] "GET /wp-content/uploads/wp-less/themename/css/main-a800d37d44.css?ver=2.3.3 HTTP/1.1" 301 184 "http://b2.example.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:43.0) Gecko/20100101 Firefox/43.0"