Skip to content

PHP 5.4.x 安装

Xiaoshi Xu edited this page Jul 6, 2018 · 4 revisions

安装步骤

yum install libicu*
wget http://downloads.php.net/stas/php-5.4.19.tar.gz
tar xzf php-5.4.19.tar.gz 
cd php-5.4.19
./configure --prefix=/usr/local/php-5.4.19 --enable-exif --enable-fpm --enable-mbstring --with-config-file-path=/etc/php --with-freetype-dir --with-gd --with-jpeg-dir --with-png-dir --with-iconv-dir --with-mysql --with-mysqli --with-pdo-mysql --with-zlib --with-curl --with-curlwrappers --enable-intl  --with-icu-dir=/usr --with-fpm-user=www --with-fpm-group=www --with-libxml-dir --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --with-mcrypt --enable-mbregex --with-openssl --enable-soap --enable-gd-native-ttf --enable-ftp --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --with-mhash --enable-calendar --with-bz2 --with-gettext --enable-wddx --with-apxs2=/usr/local/apache-2.4.6/bin/apxs
make
make install
ln -s /usr/local/php-5.4.19 /usr/local/php
# 创建初始php.ini配置文件
mkdir -p /etc/php
cp php.ini-production /etc/php/php-5.4.x.ini
ln -s /etc/php/php-5.4.x.ini /etc/php/php.ini
# 创建初始php-fpm配置文件
mkdir -p /etc/php-fpm
cp /usr/local/php-5.4.19/etc/php-fpm.conf.default /etc/php-fpm/test-eefocus-com.conf
mkdir -p /var/log/php/

# 安装apc模块
# 最新稳定版3.1.9会报错,故安装最新beta版
wget http://pecl.php.net/get/APC-3.1.13.tgz
tar xzf APC-3.1.13.tgz
cd APC-3.1.13
/usr/local/php-5.4.19/bin/phpize
./configure --with-php-config=/usr/local/php-5.4.19/bin/php-config
make
make install
或者通过pecl安装,参加“错误排查”

# 安装memcached模块
wget http://pecl.php.net/get/memcached-2.1.0.tgz
tar xzf memcached-2.1.0.tgz
cd memcached-2.1.0
/usr/local/php-5.4.19/bin/phpize
./configure --with-php-config=/usr/local/php-5.4.19/bin/php-config
如果报错 确保libmemcached已经安装,并用这个命令
./configure --with-php-config=/usr/local/php-5.4.19/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached
make
make install
或者通过pecl安装,参加“错误排查”

# 安装memcache模块
wget http://pecl.php.net/get/memcache-2.2.7.tgz
tar xzf memcache-2.2.7.tgz
cd memcache-2.2.7
/usr/local/php-5.4.19/bin/phpize
./configure --with-php-config=/usr/local/php-5.4.19/bin/php-config
make
make install
或者通过pecl安装,参加“错误排查”

# 按需安装其他模块

注意事项

  1. 安装过程中可能提示某些依赖包缺失,比如:
yum install libxml2 libxml2-devel -y
yum install bzip2 bzip2-devel
yum install curl curl-devel
yum -y install libjpeg-devel
yum install libjpeg libpng freetype libjpeg-devel libpng-devel freetype-devel -y
yum -y install libicu-devel
# 如果还有其他缺失,百度一下包名,然后安装。
  1. 方便起见, 可以使用 yum 安装,然后根据需要安装扩展。
  2. 可以用如下命令进行调试
/usr/local/php/bin/php -r 'print_r(phpinfo());'

如果有错误会在最上方显示。

错误排查

undefined symbol: zend_new_interned_string in Unknown on line 0 尝试重新用pecl安装模块

cd /usr/local/php/bin
./pecl uninstall apc
./pecl install apc
Clone this wiki locally