我有以下nginx配置。
mydomain.com / etc / nginx / sites-available / default
DNS设置 - 记录类型:ANAME,名称:@,IP:1.2.3.4
server {
listen 80;
listen [::]:80 ipv6only=on;
root /var/www/html/mydomain/public;
index index.php index.html;
server_name mydomain.com;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
stats.mydomain.com / etc / nginx / sites-available / piwik
DNS设置 - 记录类型:ANAME,名称:统计数据,IP:1.2.3.4
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name stats.mydomain.com;
root /var/www/piwik;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
我的主域名完美运行并正确处理php。但是,我的子域在浏览器中显示原始代码/ index.php。
我错过了什么?
任何帮助都将不胜感激。