LAMP环境搭建系列之六:Nginx运行php-fpm

先安装php在说:

// 安装加密和转码依赖库
cd /data/ide
tar zxvf libmcrypt-2.5.8.tar.gz  
tar zxvf mhash-0.9.9.9.tar.gz  
tar zxvf mcrypt-2.6.8.tar.gz  
tar zxvf libiconv-1.14.tar.gz  
      
cd /data/ide/libmcrypt-2.5.8  
./configure  
make && make install  
      
cd /data/ide/mhash-0.9.9.9  
./configure  
make && make install  
      
cd /data/ide/mcrypt-2.6.8  
LD_LIBRARY_PATH=/usr/local/lib ./configure  
make && make install  
      
cd /data/ide/libiconv-1.14  
./configure --prefix=/usr/local/libiconv
make && make install

// 更新动态链接库,添加 /usr/local/lib
vi /etc/ld.so.conf  
include ld.so.conf.d/*.conf  
/usr/local/lib
:wq  
ldconfig

// 创建php安装目录和配置文件目录  
mkdir /data/server/php
mkdir /data/server/php/etc
  
cd /data/ide  
tar zxvf php-5.6.32.tar.gz  
cd php-5.6.32  

./configure --prefix=/data/server/php \
--with-config-file-path=/data/server/php/etc \
--enable-fpm \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--enable-inline-optimization \
--enable-gd-native-ttf \
--enable-sockets \
--enable-zip \
--enable-calendar \
--enable-intl \
--enable-soap \
--enable-xml \
--enable-ftp \
--enable-shmop \
--enable-sysvsem \
--enable-mbstring \
--enable-exif \
--enable-opcache \
--with-gettext \
--with-zlib \
--with-bz2 \
--with-iconv-dir=/usr/local/libiconv \
--with-gd \
--with-xmlrpc \
--with-curl \
--with-mhash \
--with-mcrypt \
--with-openssl \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-libxml-dir \
--disable-ipv6 \
--disable-debug \
--disable-rpath

make && make install

我们先把php配置文件设置一下,顺便修改时区!

cp /data/ide/php-5.6.32/php.ini-production /data/server/php/etc/php.ini
vi /data/server/php/etc/php.ini
date.timezone = PRC
:wq
rm -rf /etc/php.ini
ln -s /data/server/php/etc/php.ini /etc/php.ini
然后我们还需要设置php-fpm 配置文件,解注释pid即可!

cp /data/server/php/etc/php-fpm.conf.default /data/server/php/etc/php-fpm.conf
vi /data/server/php/etc/php-fpm.conf
user = nginx
group = nginx
pid = run/php-fpm.pid
:wq
我们提前设置web目录为/data/www,且下面放置一个phpinfo();的脚本文件index.php !

接下来我们配置Nginx:

chown -R nginx:nginx /data/www

vi /data/server/nginx/conf/nginx.conf


location / {
    root   /data/www;								# 修改目录
    index  index.html index.php;						# 修改引导文件
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
    root           /data/www;							# 修改目录
    index 	   index.html index.php;					# 修改引导文件
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;		# 替换成 $document_root
    include        fastcgi_params;
}

其实Nginx的配置文件里面已经有了php的配置,只是注释状态。

我们只需要解注释,并修改web目录和引导文件,最重要的修改时将 /scripts 替换成 $document_root

完成了,启动 php-fpm 和 nginx 就能访问了。

最后做一下随机启动设置:

vi /etc/rc.d/rc.local

/data/server/php/sbin/php-fpm
/data/server/nginx/sbin/nginx

:wq



点击下载用到的源码包:  http://download.csdn.net/download/konkon2012/10126484



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

咆哮的程序猿

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值