情況:
伺服器A和伺服器B安裝相同的Ubuntu 14.04,相同的nginx版本(1.4.6),相同的虛擬主機(domain.com)和joomla資料夾(從伺服器A到B的rsync-ed)
但伺服器 A 只能顯示其首頁,並且會在任何選單項目上顯示「未指定檔案輸入」。
如果我更改/etc/hosts,以便在伺服器B測試後伺服器A的IP將使用domain.com,它不會立即失敗。幾分鐘後,錯誤就會出現。
nginx 的錯誤日誌中有一些訊息,如下所示:
2015/02/23 12:01:57 [error] 15515#0: *260609 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined property: JPagination::$pagesTotal in /var/www/joomla/templates/ashton/html/com_content/featured/default.php on line 76" while reading response header from upstream, client: 10.224.202.152, server: www.domain.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "www.domain.com"
答案1
透過新增「fastcgi_param SCRIPT_FILENAME」解決了這個問題
示例如下
server {
listen 80;
root /var/www/joomla;
index index.php index.html index.htm;
server_name www.domain.com;
location / {
try_files $uri $uri/ /index.php?q=$request_uri;
}
location ~ \.php$ {
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;
}
}