centos php5.2.17,Centos7+Nginx1.8.1 + php 5.2.17 + php-fpm安装

1.先安装依赖包

准备工作:

# 安装编译工具:

yum install gcc automake autoconf libtool gcc-c++

# 安装基础库

yum install gd zlib zlib-devel openssl openssl-devel libxml2 libxml2-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libmcrypt libmcrypt-devel

yum安装的时候出现下面提示

No package libmcrypt available.

No package libmcrypt-devel available.

是因为版权原因没有这个源

解决方法安装第三方yum源(参考http://www.nginx.cn/2196.html)

wget http://www.atomicorp.com/installers/atomic

sh ./atomic

yum install php-mcrypt libmcrypt libmcrypt-devel

# 下载pcre 正则库

wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.bz2

tar jxf pcre-8.38.tar.bz2

cd pcre-8.38/

./configure --prefix=/usr/local/pcre

make && make install

2.下载软件

cd /usr/local/src

wget http://us.php.net/distributions/php-5.2.17.tar.gz

wget http://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gz

wget http://nginx.org/download/nginx-1.8.1.tar.gz

3.解压软件

tar -zxvf php-5.2.17.tar.gz

tar -zxvf nginx-1.8.1.tar.gz

这步非常重要,以php-fpm运行,5.2版本的一定要打补丁,不然你就完啦。。。

gzip -cd php-5.2.17-fpm-0.5.14.diff.gz | sudo patch -d php-5.2.17 -p1

别以为这样你就可以开始编译安装了,还早着呢,耐心看完再慢慢弄。

通过自己的安装过程,出现了下面一些问题。

(1) PHP编译报错configure: error: Cannot find libmysqlclient under /usr.

编译报错如下:

configure: error: Cannot find libmysqlclient under /usr.

Note that the MySQL client library is not bundled anymore!

这个错误时因为在64位的linux系统中,libmysqlclient 默认安装到了 /usr/lib64/mysql/ 目录下,但是php编译时,要去/usr/lib目录下查找

解决办法:在/usr/lib目录下创建一个软连接

[root@localhost php-5.2.17]# ls /usr/lib64/mysql/libmysqlclient*

/usr/lib64/mysql/libmysqlclient.a /usr/lib64/mysql/libmysqlclient.so /usr/lib64/mysql/libmysqlclient.so.20

/usr/lib64/mysql/libmysqlclient_r.so.18 /usr/lib64/mysql/libmysqlclient.so.18 /usr/lib64/mysql/libmysqlclient.so.20.2.0

/usr/lib64/mysql/libmysqlclient_r.so.18.1.0 /usr/lib64/mysql/libmysqlclient.so.18.1.0

[root@localhost php-5.2.17]# ln -s /usr/lib64/mysql/libmysqlclient.so.18 /usr/lib/libmysqlclient.so #这步现在就操作

(2)configure: error: Cannot find ldap libraries in /usr/lib

cp -frp /usr/lib64/libldap* /usr/lib/ #这步现在就操作

原因是安装了64位的系统,在lib64下面有这个文件,可能在lib这文件夹里面没有,所以强制复制一次。

编译php时出现 configure: error: Cannot find ldap.h,发现依赖于openldap包,通过yum解决问题:

yum install openldap.i386 openldap-clients.i386 openldap-devel.i386 openldap-servers.i386

yum安装完成了就ok了!

(3)centos安装 php时 出现 make: *** [ext/dom/node.lo] Error

curl -o php-5.2.17.patch https://mail.gnome.org/archives/xml/2012-August/txtbgxGXAvz4N.txt

cd php-5.2.17 #前提先解压PHP

patch -p0 -b <..>

会提示你一些patch成功的信息。就OK了。 #这步现在就操作

(4)php-fpm 启动出错

/usr/local/php5217/sbin/php-fpm start

Starting php_fpm –fpm-config /usr/local/php-5.2.14/etc/php-fpm.conf

Error in argument 1, char 1: no argument for option -

Usage: php-cgi [-q] [-h] [-s] [-v] [-i] [-f ]

解决方案:

重装编译安装php

./configure时加上这个参数–enable-fastcgi –enable-fpm –enable-force-cgi-redirect #这步现在不要操作,后面会一起给你配置参数的

现在好对上场了,终于开始编译安装了。

./configure --prefix=/usr/local/php5217 --with-mysql=/usr/local/mysql --with-mysql-sock=/var/lib/mysql/mysql.sock --with-iconv-dir=/usr/bin --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --with-curl --enable-fpm --enable-fastcgi --enable-force-cgi-redirect --enable-mbstring --with-gd --enable-gd-native-ttf --enable-zip

最后编译成功:

+--------------------------------------------------------------------+

| License: |

| This software is subject to the PHP License, available in this |

| distribution in the file LICENSE. By continuing this installation |

| process, you are bound by the terms of this license agreement. |

| If you do not agree with the terms of this license, you must abort |

| the installation process at this point. |

+--------------------------------------------------------------------+

Thank you for using PHP.

make && make install

安装完了不要着急,还有工作哦。

cp /usr/local/src/php-5.2.17/php.ini-recommended /usr/local/php5217/lib/php.ini

到此安装完毕。

安装nginx请参考。http://www.lampnick.com/php/131

喜欢 (2)or分享 (0)

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值