码迷,mamicode.com
首页 > Web开发 > 详细

nginx安装CentOS6,支持php

时间:2015-06-12 15:11:26      阅读:205      评论:0      收藏:0      [点我收藏+]

标签:nginx

1. Install nginx from Ngnix web with stable version
vi /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/6/x86_64/
gpgcheck=0
enabled=1

yum -y install nginx

vi /etc/nginx/nginx.conf
#set it within number of CPU cores
worker_processes 2;
#uncomment ( enable gzip )
gzip on;

vi /etc/nginx/conf.d/default.conf
#change to your server‘s name
server_name 192.168.2.5;

service nginx start; chkconfig nginx on

2. enable centos 6 updates repo
yum -y install php php-mbstring php-pear php-fpm

vi /etc/php.ini
date.timezone = Asia/Shanghai
expose_php = Off
magic_quotes_gpc = Off
short_open_tag = On

vi /etc/php-fpm.d/www.conf
user = nginx
group = nginx

service php-fpm start; chkconfig php-fpm on

vi /etc/nginx/conf.d/default.conf
# add follows in a "server" section
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;
        include        /etc/nginx/fastcgi_params;
    }

service nginx restart

echo "<?php phpinfo() ?>" > /usr/share/nginx/html/info.php


本文出自 “Ilovecat(个人笔记)” 博客,请务必保留此出处http://hj192837.blog.51cto.com/655995/1661169

nginx安装CentOS6,支持php

标签:nginx

原文地址:http://hj192837.blog.51cto.com/655995/1661169

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!