您的位置:首页 > 运维架构 > Nginx

ubuntu 14.4 nginx环境下安装PHP(版本>= 5.5.9)

2016-04-07 08:10 513 查看
ubuntu 14.4 nginx环境下安装PHP(版本>= 5.5.9)

首先安装软件包(命令行工具,cgi,fastCGI进程管理器以及其他)

sudo apt-get install php5-cli php5-cgi php5-mcrypt php5-mysql

安装FastCgi

sudo apt-get install php5-fpm

然后编辑nginx配置文件 已达到解析处理PHP的能力;

sudo vi /etc/nginx/sites-available/default

修改index的一行修改为:

index index.php index.html index.htm;

修改nginx的配置文件:/etc/nginx/sites-available/default 修改主机名

server_name localhost;

index index.html index.htm index.php;
pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
root          /var/www/html;
fastcgi_index index.php;
include fastcgi_params ;
fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
}


然后让nginx重启

sudo service nginx restart

sudo /etc/init.d/nginx restart

如果不成功,测试nginx服务器的配置是否错误;

nginx -t;

最后必须启动fastcgi php:

sudo apt-get install spawn-fcgi

spawn-fcgi -a 127.0.0.1 -p 9000 -C 10 -u www-data -f /usr/bin/php-cgi

(注:文件目录现在在 /var/www/html/目录下面。netstat -ntpl查看 cgi是否开启)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: