我对nginx还比较陌生,我正在尝试从Apache导入遗留站点。我想去掉虚拟目录,但不幸的是我不能。
虚拟目录指向主站点上的同一根目录。代码中有一种逻辑,可以检测虚拟目录并根据该信息加载数据,这就是它存在的原因。
下面是我要开始工作的配置:
server {
listen 80;
large_client_header_buffers 4 32k;
server_name site.domain.com;
access_log /var/log/sites/site.access.log;
error_log /var/log/sites/site.error.log error;
location / {
root /var/www/php/site;
index index.php;
include /etc/nginx/conf.d/php.inc;
}
location /sitea {
root /var/www/php/site;
index index.php;
include /etc/nginx/conf.d/php.inc;
}
location ~ /\.ht {
deny all;
}
}
php.inc的内容:
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
我已经尝试了谷歌提供的每一项功能,以使它发挥作用,但无论我做什么,我仍然会得到以下错误:
2018/11/15 20:28:32 [debug] 5056#5056: *1 http script var: "/sitea/index.php"
2018/11/15 20:28:32 [debug] 5056#5056: *1 trying to use file: "/sitea/index.php" "/var/www/php/site/sitea/index.php"
2018/11/15 20:28:32 [debug] 5056#5056: *1 trying to use file: "=404" "/var/www/php/site=404"
2018/11/15 20:28:32 [debug] 5056#5056: *1 http finalize request: 404, "/sitea/index.php?requestType=home" a:1, c:1
2018/11/15 20:28:32 [debug] 5056#5056: *1 http special response: 404, "/sitea/index.php?requestType=home"
2018/11/15 20:28:32 [debug] 5056#5056: *1 http set discard body
2018/11/15 20:28:32 [debug] 5056#5056: *1 xslt filter header
2018/11/15 20:28:32 [debug] 5056#5056: *1 HTTP/1.1 404 Not Found
如能为正确的方向提供帮助,我们将不胜感激。
注意:使用
alias
VS
root
通过Alias,我可以得到以下信息:
2018/11/15 20:37:38[错误]5189 5189:*1个fastcgi在stderr中发送:
从上游读取响应头时,“主脚本未知”,
客户端:,服务器:site.domain.com,请求:“get
/sitea/index.php?requesttype=home http/1.1“,上游:
“fastcgi://unix:/run/php/php7.0-fpm.sock:”,主机:“site.domain.com”
可能的解决方案
我不确定这是否是正确的方法,但它起作用了。
如果我在主文件夹中为虚拟目录创建了一个符号链接,那么站点将被加载。我宁愿在nginx做这个,但是如果我必须走这条路,我会的。思想?