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

来源:互联网 发布:软件逆向工程师 编辑:程序博客网 时间:2024/06/03 12:23

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是否开启)

0 0
原创粉丝点击