我的服务器是 Ubuntu 14.04,info.php 是空白的 :( 我真的不知道发生了什么,我想安装最新版本的 nginx
我遵循以下步骤:
安装 nginx
apt-get install python-software-properties'
add-apt-repository ppa:nginx/stable
apt-get update
apt-get install nginx
安装 php
sudo apt-get install php5-fpm php5-mysql
sudo nano /etc/php5/fpm/php.ini
取消注释行
cgi.fix_pathinfo=0
sudo service php5-fpm restart
sudo nano /etc/nginx/sites-available/default
编辑文件
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.php index.html index.htm;
server_name localhost;
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
sudo service nginx restart
创建文件并保存
sudo nano /usr/share/nginx/html/info.php
<?php
phpinfo();
?>
请帮忙安装最新版本的 nginx。
答案1
有解决办法!!
添加代码行
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
例子:
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
include fastcgi_params;
}