yum install -y freetype freetype-devel libxml2 libxml2-devel curl-devel libjpeg libjpeg-devel libpng libpng-devel
tar xf php-7.1.16.tar.bz2
cd php-7.1.16
vim /usr/local/apache/bin/apxs
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-maintainer-zts --enable-opcache --enable-sockets --enable-xml --enable-mbstring --enable-soap --enable-zip --enable-bcmath --with-gettext --with-openssl --with-zlib --with-curl --with-gd --enable-gd-native-ttf --with-freetype-dir=/usr/include/freetype2/ --with-zlib-dir=/usr/lib --with-png-dir=/usr/lib --with-jpeg-dir=/usr/lib --with-mhash --with-apxs2=/usr/local/apache/bin/apxs
make
make install
cp php.ini-development /usr/local/php/etc/php.ini
vim /etc/profile.d/php.sh
export PATH=/usr/local/php/bin:$PATH
. /etc/profile.d/php.sh

httpd与php合作
vim /usr/local/apache/conf/httpd.conf

DirectoryIndex index.php index.html

AddType application/x-httpd-php .php .html

Include conf//extra/httpd-vhosts.conf

httpd -t
service httpd restart

php安装memcache扩展
yum install unzip
unzip php7.zip
cd pecl-memcache-php7/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
vim /usr/local/php/etc/php.ini
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20160303/"
extension = "memcache.so"

php安装memcached扩展
wget https://launchpadlibrarian.net/165454254/libmemcached-1.0.18.tar.gz
tar xf libmemcached-1.0.18.tar.gz
cd libmemcached-1.0.18
./configure -prefix=/usr/local/libmemcached -with-memcached
make或make clean all LDFLAGS="-L/usr/lib64 -L/lib64"
make install

git clone https://github.com/php-memcached-dev/php-memcached
cd php-memcached/
/usr/local/php/bin/phpize
git checkout -b php7
./configure --with-php-config=/usr/local/php/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached --disable-memcached-sasl
make
make install
vim /usr/local/php/etc/php.ini
extension = "memcached.so"

tar zxf mongo-1.6.16.tgz
cd mongo-1.6.16
phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install

vim /usr/local/php/etc/php.ini
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20131226/"
extension = mongo.so
httpd -t
service httpd restart

// connect to mongodb
$m = new Mongoclient("mongodb://47.101.99.1:27017");
echo "Connection to database successfully
";
// select a database
$db = $m->xwgl;

echo "Database xwgl selected";