Chinaunix首页 | 论坛 | 博客
  • 博客访问: 265022
  • 博文数量: 78
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 852
  • 用 户 组: 普通用户
  • 注册时间: 2013-05-06 11:01
个人简介

不做第二个别人,永远做第一个自己。

文章分类

全部博文(78)

文章存档

2014年(60)

2013年(18)

分类: LINUX

2014-04-10 11:16:55

nginx结合php,配置如下:

 
Configure Nginx to execute PHP script.
This example shows to use PHP-FPM ( PHP FastCGI Process Manager ). 

安装php & php-fpm 

# yum  –enablerepo=epel -y install php php-mbstring php-pear php-fpm 
 
配置php-fpm
# vim /etc/php-fpm.d/
# 39 行
user = ngnx; apache change nginx;
# 41 行
group = nginx;  
 
# /etc/rc.d/init.d/php-fpm start 
Starting php-fpm: [ OK ]
# chkconfig php-fpm on 
 
配置nginx支持php
# vim /etc/nginx/conf.d/default.conf 
在 server 部分中添加
 location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        /etc/nginx/fastcgi_params;
    }

注意:这个有的时候会识别不出来$document_root,改成网站的根目录就可以了;

# /etc/rc.d/init.d/nginx restart 
Stopping nginx: [ OK ]
Starting nginx: [ OK ]
 
创建一个php.info的脚本,测试一下是否配置成功;
# echo "" > /usr/share/nginx/html/info.php
访问地址是:
阅读(437) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~