Skip to content

PHP 7.2.x 安装

Xiaoshi Xu edited this page Sep 26, 2018 · 10 revisions

php7.2安装

# Dependencies:
# configure: error: no acceptable C compiler found in $PATH
yum install gcc

# configure: error: libxml2 not found. Please check your libxml2 installation.
yum install libxml2-devel

# configure: error: Cannot find OpenSSL's <evp.h> 
yum install openssl openssl-devel

# configure: error: Please reinstall the BZip2 distribution
yum install bzip2 bzip2-devel

# checking for cURL 7.10.5 or greater... configure: error: cURL version 7.10.5 or later is required to compile php with cURL support
yum -y install curl-devel

# configure: error: jpeglib.h not found.
yum -y install libjpeg-devel

# configure: error: png.h not found.
yum install libpng libpng-devel

# configure: error: freetype-config not found.
yum install freetype-devel

# configure: error: Unable to detect ICU prefix or /usr/bin/icu-config failed. Please verify ICU install prefix and make sure icu-config works.
yum -y install libicu-devel

# configure: error: C++ preprocessor "/lib/cpp" fails sanity check
yum install glibc-headers gcc-c++

# configure: error: mcrypt.h not found. Please reinstall libmcrypt.
yum install -y epel-release
yum install -y libmcrypt-devel

# 其他
# memcached扩展相关
yum install libmemcached-devel
yum install cyrus-sasl-devel

yum install libicu*

wget http://cn2.php.net/get/php-7.2.4.tar.bz2/from/this/mirror
tar xvf php-7.2.4.tar.bz2

cd php-7.2.4
./configure --prefix=/usr/local/php-7.2.4 --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-mysqli --with-pdo-mysql --with-zlib --with-curl  --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  --enable-mbregex --with-openssl --enable-soap  --enable-ftp --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --with-mhash --enable-calendar --with-bz2 --with-gettext --enable-wddx --enable-opcache

make
make install

ln -s /usr/local/php-7.2.4 /usr/local/php
# 创建初始php.ini配置文件
mkdir -p /etc/php
cp php.ini-production /etc/php/php-7.2.x.ini
ln -s /etc/php/php-7.2.x.ini /etc/php/php.ini

# 创建初始php-fpm配置文件
mkdir -p /etc/php-fpm
cp /usr/local/php-7.2.4/etc/php-fpm.conf.default /etc/php-fpm/test-eefocus-com.conf

mkdir -p /var/log/php/

扩展安装

# apcu
./pecl install apcu

# redis
./pecl install redis

# mcrypt
./pecl install mcrypt-1.0.1

#sphinx
wget http://pecl.php.net/get/sphinx-9a3d08c.zip
unzip sphinx-9a3d08c.zip
cd sphinx-9a3d08c
/usr/local/php-7.2.4/bin/phpize
./configure --with-php-config=/usr/local/php-7.2.4/bin/php-config
make
make install

# libmemcached 用于安装memcached
yum install libmemcached-devel
yum install libevent-devel
tar -zxf libmemcached-1.0.18.tar.gz
cd libmemcached-1.0.18
./configure --prefix=/usr/local/libmemcached --with-memcached
make
make install

# 安装memcached
git clone git@github.com:php-memcached-dev/php-memcached memcached
cd memcached/
git checkout php7
/usr/local/php-7.2.4/bin/phpize
./configure --with-php-config=/usr/local/php-7.2.4/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached --disable-memcached-sasl
make
make install

# memcache
git clone git@github.com:websupport-sk/pecl-memcache memcache
cd memcache
/usr/local/php-7.2.4/bin/phpize
./configure --with-php-config=/usr/local/php-7.2.4/bin/php-config
make
make install
Clone this wiki locally