CentOS5.8编译安装PHP5.4.12 2013
因最新稳定版的php5.4.12不能兼容zend loader,故以下php5.4.12版本均改为了 old stable 版本5.3.22。安装方式基本都相同。如果想装zend的同学切忌不可直接复制下面的安装!
#PHP5.4.12
点击(此处)折叠或打开
- wget http://www.php.net/get/php-5.4.12.tar.gz/from/hk1.php.net/mirror //官方下载网址,这里选择的香港镜像1,可以自己登陆官网选择当地网速最快的镜像
点击(此处)折叠或打开
- wget http://museum.php.net/php5/php-5.3.22.tar.gz
#PHP库文件
点击(此处)折叠或打开
-
yum install libmcrypt
-
yum install mhash
- #yum install libiconv因找不到源无法执行,故直接下载,自己安装。
- 在tmp目录下:
-
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
- tar -xvf libiconv-1.14.tar.gz
- cd libiconv-1.14
- ./configure --prefix=/usr/local
- make && make install
点击(此处)折叠或打开
-
cd /tmp
-
-
tar -zxvf php5.3.22.tar.gz
-
-
./configure --prefix=/usr/local/php
\
-
--with-config-file-path=/usr/local/php/etc
\
-
--with-iconv-dir=/usr/local \
-
--with-freetype-dir
\
-
--with-mysql=/usr/local/mysql
\
-
--with-mysqli=/usr/local/mysql/bin/mysql_config
\
-
--with-jpeg-dir
\
-
--with-png-dir
\
-
--with-zlib \
-
--with-mhash \
-
--enable-sockets \
-
--enable-ftp \
-
--with-libxml-dir
\
-
--enable-xml \
-
--disable-rpath \
-
--enable-safe-mode
\
-
--enable-bcmath \
-
--enable-shmop \
-
--enable-sysvsem \
-
--enable-inline-optimization --with-curl
\
-
--with-curlwrappers \
-
--enable-mbregex \
-
--enable-mbstring \
-
--with-mcrypt \
-
--with-gd \
-
--enable-gd-native-ttf
\
-
--with-openssl \
-
--with-mhash \
-
--enable-pcntl \
-
--enable-sockets \
-
--with-ldap \
-
--with-ldap-sasl
\
-
--enable-fpm \
-
--with-xmlrpc \
-
--enable-zip \
-
--enable-soap \
-
--enable-fastcgi \
- --without-pear
-
- 若提示:configure: error: mcrypt.h not found. Please reinstall libmcrypt
- 则需yum remove libmcrypt删除安装后,重新手工安装libmcrypt
-
点击(此处)折叠或打开
-
wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz
-
-
tar -zxvf libmcrypt-2.5.7.tar.gz
-
cd libmcrypt-2.5.7
-
./configure prefix=/usr/local/libmcrypt/
#默认也可以
-
70 make
- make install
- 然后执行php的 configure时,加入--with-mcrypt=/usr/local/libmcrypt
-
wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz
-
-
编译完后,没问题再继续执行以下脚本
- make ZEND_EXTRA_LIBS=‘-liconv‘
-
-
#执行完后后出现 make: *** [ext/phar/phar.php] 错误 127
解决办法--标蓝色的部分,这一步需针对资金的error进行处理,并非所有的错误都是找不到libmysqlclient.so.18导致:
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/(32位系统)
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/(64位系统)
- 最后执行:
-
make install
3.以上仅完成了php的安装,下面进行具体的配置:
点击(此处)折叠或打开
-
#选择PHP.ini配置文件
-
cp php.ini-production /usr/local/php/etc/php.ini
-
-
#添加WWW用户
-
/usr/sbin/groupadd www && /usr/sbin/useradd -g www www
-
mkdir -p /var/log/nginx && chmod +w /var/log/nginx &&chown -R www:www
/var/log/nginx
-
mkdir -p /data/www && chmod +w /data/www && chown -R www:www
/data/www
-
-
cp /usr/local/php/etc/php-fpm.conf.default
/usr/local/php/etc/php-fpm.conf
-
vi /usr/local/php/etc/php-fpm.conf
-
-
#去掉/更改 配置文件中的;
-
pm.max_children = 64
-
pm.start_servers = 20
-
pm.min_spare_servers = 5
-
pm.max_spare_servers = 35
-
pm.max_requests = 1024
-
user = www
-
group = www
-
-
#检查语法是否正确
-
/usr/local/php/sbin/php-fpm -t
-
#出现NOTICE: configuration file /usr/local/php/etc/php-fpm.conf test is
successful 测试成功
-
/usr/local/php/sbin/php-fpm &
-
#设置开机启动
-
vi /etc/rc.d/rc.local
-
#在行末加入
- /usr/local/php/sbin/php-fpm &
补充下:
安装phpwind9以上版本,需要pdo_mysql支持,故单独安装,步骤如下:
解压php 5.3.22源码包,进入目录
$ cd php5.3.22/ext/pdo_mysql
$ /usr/local/php/bin/phpize
$ ./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql/
$ make && make install
安装完毕后,会生成pdo_mysql.so的路径,
---------------------------------------------------------------------------------------------------------------------------------------
Build complete.
Don‘t forget to run ‘make test‘.
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/
---------------------------------------------------------------------------------------------------------------------------------------
//将shared extensions路径加入php.ini,并设置扩展支持pdo_mysql.so
$ vi /usr/local/php/etc/php.ini
修改如下位置:
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/"
extension = "pdo_mysql.so"
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。