码迷,mamicode.com
首页 > 其他好文 > 详细

Nginx配置

时间:2015-07-03 17:28:27      阅读:151      评论:0      收藏:0      [点我收藏+]

标签:centos   php-fpm安装   nginx配置   

环境问题
Linux(centos6.6):
     Linux xiao-wei 2.6.32-504.16.2.el6.x86_64 #1 SMP Wed Apr 22 06:48:29 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Nginx:
     nginx version: nginx/1.8.0
Mysql:
     mysql  Ver 14.14 Distrib 5.6.24, for Linux (x86_64) using  EditLine wrapper
php:
     PHP 5.6.8 (cli) (built: Apr 30 2015 00:05:13) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies


注:安装过程参考以下文章

一、安装准备:
yum -y install gcc automake autoconf libtool make

yum -y install gcc gcc-c++ glibc

yum -y install libmcrypt-devel mhash-devel libxslt-devel \
libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel \
zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel \
ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel \
krb5 krb5-devel libidn libidn-devel openssl openssl-devel

*此时会发现libmcrypt-devel mhash-devel没有安装(源没有发现该安装包!!_!!)

源码编译安装,去http://www.sourceforge.net下载Libmcrypt,mhash,mcrypt安装包 
libmcrypt(libmcrypt-2.5.8.tar.gz );mcrypt(mcrypt-2.6.8.tar.gz ); mhash(mhash-0.9.9.9.tar.gz )

2 .先安装Libmcrypt
#tar -zxvf libmcrypt-2.5.8.tar.gz
#cd libmcrypt-2.5.8
#./configure
#make
#make install 说明:libmcript默认安装在/usr/local 

3.安装mhash
#tar -zxvf mhash-0.9.9.9.tar.gz
#cd mhash-0.9.9.9
#./configure
#make
#make install

4.安装mcrypt
#tar -zxvf mcrypt-2.6.8.tar.gz
#cd mcrypt-2.6.8
#LD_LIBRARY_PATH=/usr/local/lib ./configure
#make
#make install

二、php-fpm安装

wget http://cn2.php.net/distributions/ (注:这里需要找相应服务器下载相应版本)
tar zvxf php-5.6.24.tar.gz
cd php-5.6.24
./configure --prefix=/usr/local/php  --enable-fpm --with-mcrypt \
--enable-mbstring --disable-pdo --with-curl --disable-debug  --disable-rpath \
--enable-inline-optimization --with-bz2  --with-zlib --enable-sockets \
--enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex \
--with-mhash --enable-zip --with-pcre-regex --with-mysql --with-mysqli \
--with-gd --with-jpeg-dir

*出现checking for known struct flock definition... configure: error: Don‘t know how to define struct flock on this system, set --enable-opcache=no错误*
解决方法:(参考 http://blog.linuxeye.com/342.html )

configure前运行export LD_LIBRARY_PATH=/lib/:/usr/lib/:/usr/local/lib

make all install

以上就完成了php-fpm的安装。

下面是对php-fpm运行用户进行设置
#cd /usr/local/php
#cp etc/php-fpm.conf.default etc/php-fpm.conf
#vi etc/php-fpm.conf
修改
user = www-data
group = www-data

如果www-data用户不存在,那么先添加www-data用户
#groupadd www-data
#useradd -g www-data www-data

三、编译安装nginx
然后按照http://www.nginx.cn/install 安装nginx

修改nginx.conf文件
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

四、创建php文件

在/usr/local/nginx/html下创建index.php文件,输入如下内容

<?php
    echo phpinfo();
?>


五、启动服务

启动php-fpm和nginx

/usr/local/php/sbin/php-fpm 
#手动打补丁的启动方式/usr/local/php/sbin/php-fpm start

sudo /usr/local/nginx/nginx


六、测试

版权声明:本文为博主原创文章,未经博主允许不得转载。

Nginx配置

标签:centos   php-fpm安装   nginx配置   

原文地址:http://blog.csdn.net/zhongyi_yang/article/details/46743591

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