php php-fpm nginx
安装yum源remi
rpm -Uvh http://mirrors.opencas.cn/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
安装软件
一.php php-fpm
使用remi源的包
yum --enablerepo=remi install php php-fpm
二.安装nginx
安装nginx源 (centos6系统以下直接安装http://nginx.org/packages/centos/5/x86_64/RPMS/nginx-1.8.0-1.el5.ngx.x86_64.rpm)
rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
yum install nginx
三.配置
vi /etc/nginx/nginx.conf
修改
location ~ \.php$ {
root /usr/share/nginx/html; #修改为网站路径
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #document_root指的是上面的root,对这个路径下php文件使用php-fpm解析
include fastcgi_params;
}
三.启动php-fpm,nginx
/etc/init.d/nginx start
/etc/init.d/php-fpm start
若修改配置文件则使用/etc/init.d/nginx reload 加载
四.测试
在nginx路径下
cd /usr/share/nginx/html
vi index.php
- <?php
- phpinfo();
- ?>