![在 Ubuntu 14.04 中安装 nginx 1.6.2 版本时出错](https://linux22.com/image/1423878/%E5%9C%A8%20Ubuntu%2014.04%20%E4%B8%AD%E5%AE%89%E8%A3%85%20nginx%201.6.2%20%E7%89%88%E6%9C%AC%E6%97%B6%E5%87%BA%E9%94%99.png)
我的服务器是 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;
}