我已经在Ubuntu 13.04 x64服务器上工作了,我已经成功安装了NGINX和PHP-FPM,并确保它们也能正常工作。但是,在修改配置的配置文件以匹配Yii的配置文件后,我得到一个空白页。
这是我的NGINX配置文件:
#config file
server {
listen 80;
set $host_path "/usr/share/nginx/html/something";
server_name something.com;
root /usr/share/nginx/html/something;
set $yii_bootstrap "index.php";
charset utf-8;
location / {
index index.html $yii_bootstrap;
try_files $uri $uri/ /$yii_bootstrap?$args;
}
location ~ ^/(protected|framework|themes/\w+/views) {
deny all;
}
#avoid processing of calls to unexisting static files by yii
location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
try_files $uri =404;
}
location ~ \.php$ {
#fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
set $fsn /$yii_bootstrap;
if (-f $document_root$fastcgi_script_name){
set $fsn $fastcgi_script_name;
}
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
这是有效的原始配置文件:
server {
listen 80;
root /usr/share/nginx/html;
index index.php index.html index.htm;
server_name campusplugin.com;
location / {
try_files $uri $uri/ /index.html;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
#fastcgi_pass 127.0.0.1:9000;
location / {
try_files $uri $uri/ /index.html;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
#fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
我刚刚更改了根目录,因为我已将文件保存在根目录中指定的相应目录中。
但是,每当我尝试访问该网站时,我都会看到一个空白页面。 我不知道我哪里出错了。我是NGINX的新手。
请帮帮我。
答案 0 :(得分:1)
有时当你使用带有php-fpm的Nginx时,php不会显示错误,因此Nginx会返回空页。
1)如果你想看到这个“隐藏”错误,请尝试为nginx设置错误日志,在server_name下面添加:
error_log /path/to/your/error-log/fpm-error.log;