我使用 Bind9 创建了一个 DNS 区域,并且我非常确定我做对了,因为当我输入我的域名时它会转到我的服务器 IP。
现在轮到 nginx 了,这是我的实际配置:
server{
listen 80 ;
server_name mahkamaty.com;
return 301 http://www.mahkamaty.com$request_uri;
}
server {
listen 80 ;
server_name www.mahkamaty.com;
root /usr/share/nginx/www/mahkamaty.com/;
index index.php;
location / {
try_files $uri $uri/ /index.php?$uri&$args;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass php5-fpm-sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
}
}
server{
listen 80 ;
server_name www.questions.mahkamaty.com;
return 301 http://questions.mahkamaty.com$request_uri;
}
server {
listen 80 ;
server_name questions.mahkamaty.com;
root /usr/share/nginx/www/mahkamaty.com/questions/app/webroot/;
index index.php;
location / {
try_files $uri $uri/ /index.php?$uri&$args;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass php5-fpm-sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
}
}
当我访问 mahkamaty.com 时,它返回 nginx 的默认页面,这意味着它与 server_name 不匹配。您能帮忙吗?
PS:我已经上传了之前保存的配置,因此 nginx 中的文件可能存在所有权问题,请确认或否认这一点。