首页 > Linux, PHP, 项目实施 > CentOS 6.3 64位中安装及配置php-5.4.3
201212月11

CentOS 6.3 64位中安装及配置php-5.4.3

安装支持套件

yum -y install gcc gcc-c++ autoconf 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 openldap openldap-devel nss_ldap openldap-clients openldap-servers
如果前面已经安装了LNMP安装时所需要的支持套件,则此处不需要再安装,前面已经讲过,具体位置在我的Linux项目实施系列教程:CentOS 6.3 64位环境说明、软件下载、库及编译工具安装

安装支持库

1) pcre-8.30.tar.gz   下载
# tar zxvf pcre-8.30.tar.gz
# cd pcre-8.30
# ./configure
# make
# make install
2) libiconv-1.14.tar.gz  下载
# tar zxvf libiconv-1.14.tar.gz
# cd libiconv-1.14
# ./configure
# make
# make install
3) libmcrypt-2.5.8.tar.gz  下载
# tar zxvf libmcrypt-2.5.8.tar.gz
# cd libmcrypt-2.5.8
# ./configure
# make
# make install
4) mhash-0.9.9.9.tar.gz   下载
# tar zxvf mhash-0.9.9.9.tar.gz
# cd mhash-0.9.9.9
# ./configure
# make
# make install
5) mcrypt-2.6.8.tar.gz   下载
# tar zxvf mcrypt-2.6.8.tar.gz
# cd mcrypt-2.6.8
# ./configure
# make
# make install
配置时如果报 configure: error: *** libmcrypt was not found 错误
可参考:configure: error: *** libmcrypt was not found 错误解决

安装php-5.4.3

# tar zvxf php-5.4.3.tar.gz
# cd php-5.4.3
# ./configure -prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –with-mysql=/usr –with-mysqli=/usr/bin/mysql_config –with-iconv-dir=/usr/local/lib –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir=/usr –enable-xml –disable-rpath –enable-safe-mode –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-curl –with-curlwrappers –enable-mbregex –enable-fpm –enable-mbstring –with-mcrypt –with-gd –enable-gd-native-ttf –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-ldap –with-ldap-sasl –with-xmlrpc –enable-zip –enable-soap –without-pear –with-fpm-user=www –with-fpm-group=www
# make
# make install

编译中的错误解决

1、如果配置当中报 configure: error: Cannot find ldap libraries in /usr/lib. 错误
具体的解决办法请参考:解决php configure: error: Cannot find ldap libraries in /usr/lib.错误
2、如果配置当中报 configure: error: Cannot find MySQL header files under /usr/share/mysql. 错误
说明指定的安装目录不对
解决办法:将–with-mysql=/usr/share/mysql 改成–with-mysql=/usr
3、如果配置当中报
configure: error: Cannot find libmysqlclient under /usr.
Note that the MySQL client library is not bundled anymore! 错误
具体的解决办法请参考:configure: error: Cannot find libmysqlclient under /usr.错误解决
4、如果配置当中报 make: *** [sapi/cli/php] Error 1 错误
具体的解决办法请参考:make: *** [sapi/cli/php] Error 1错误解决

复制php配置文件

# cp php.ini-production /usr/local/php/lib/php.ini 或是 /usr/local/lib/php.ini
# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
# /usr/local/php/bin/php –ini //测试ini文件是否加载

编辑php-fpm.conf

[global]
pid = run/php-fpm.pid
error_log = log/php-fpm.log
log_level = notice
[www]
listen = 127.0.0.1:9000
user = www
group = www
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 5000

测试php-fpm配置

/usr/local/php/sbin/php-fpm -t
如果显示以下信息,则说明安装成功
NOTICE: configuration file /usr/local/php/etc/php-fpm.conf test is successful

启动9000端口号

防火墙中开启php默认的端口号9000,如果服务器没有开启防火墙,则不需要

启动php-fpm

/usr/local/php/sbin/php-fpm
如果启动报错:ERROR: [pool www] cannot get uid for user ‘www’
增加用户即可,具体的代码:useradd www -M -s /sbin/nologin
到此为止,整个php安装完成

文章作者: iitshare
本文地址:http://www.iitshare.com/centeros-6-3-64-bit-install-php-5-4-3.html
版权所有 © 转载时必须以链接形式注明作者和原始出处!

更多

3 Responses to “CentOS 6.3 64位中安装及配置php-5.4.3”

  1. #1 郭文鑫 回复 | 引用 Post:2013-05-17 15:30

    安装php-5.4.3中符号不正确,故改为

    ./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –with-mysql=/usr –with-mysqli=/usr/bin/mysql_config –with-iconv-dir=/usr/local/lib –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir=/usr –enable-xml –disable-rpath –enable-safe-mode –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-curl –with-curlwrappers –enable-mbregex –enable-fpm –enable-mbstring –with-mcrypt –with-gd –enable-gd-native-ttf –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-ldap –with-ldap-sasl –with-xmlrpc –enable-zip –enable-soap –without-pear –with-fpm-user=www –with-fpm-group=www

  2. #2 郭文鑫 回复 | 引用 Post:2013-05-17 15:33

    楼主,你的网站程序自动会将– 替换为–这个符号哦。解决一下这个问题哈

发表评论