#编译安装php-7.1.16
#wget http://cn2.php.net/distributions/php-7.1.16.tar.gz
#tar -zxvf php-7.1.16.tar.gz
#cd php-7.1.16
#./configure --prefix=/usr/local/php-7.1.16 --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-iconv --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pdo-odbc=unixODBC,/usr/ --with-pdo-dblib=/usr/local/freetds --with-pear --with-png-dir --with-xmlrpc --with-xsl --with-zlib --with-jpeg-dir=/usr --with-png-dir=/usr --with-mcrypt --with-mssql=/usr/local/freetds --enable-ftp --enable-exif --enable-calendar --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-zip
#make && make install
php7 安装memcached扩展
1. 首先安装memcache的客户端库 libmemcached。
php版本不高于5.6可以安装
wget https://launchpad.net/libmemcached/1.0/1.0.17/+download/libmemcached-1.0.17.tar.gz
php7版本的1.0.17版本的libmemcache库安转不了会报错 只能装下面的1.0.18版本的
wget https://launchpadlibrarian.net/165454254/libmemcached-1.0.18.tar.gz tar -zxvf libmemcached-1.0.18.tar.gz cd libmemcached-1.0.18 ./configure make && make install
2.安装 php7 memcache扩展
git clone https://github.com/php-memcached-dev/php-memcached git checkout -b php7 cd php_memcache /usr/local/php/bin/phpize ./configure --with-php-config=/usr/local/php/bin/php-config make && make install
修改php.ini的配置
/usr/local/php7.1/lib/php.ini 加上:extension_dir="/usr/local/php7.1/lib/php/extensions/no-debug-non-zts-20160303/"(每个人的路径可能不一样) extension = "memcached.so
重启php-fpm
php7安装redis拓展
phpredis下载地址https://github.com/phpredis/phpredis 解压并进入源码包 unzip phpredis-develop.zip cd phpredis-develop 生成configure配置文件:/usr/local/php-7.1/bin/phpize 编译安装: ./configure --with-php-config=/usr/local/php-7.1/bin/php-config make && make install 修改php.ini配置 /usr/local/php7.1/lib/php.ini 加上:extension_dir="/usr/local/php7.1/lib/php/extensions/no-debug-non-zts-20160303/"(每个人的路径可能不一样) extension=redis.so 重启php
检查:
[root@test etc]# /usr/local/php-7.1/bin/php -m|grep redis redis
测试链接mssql
<?php try { $hostname='111.111.111.111';//注意,这里和上面不同,要直接用IP地址或主机名 $port=1433;//端口 $dbname="db_1";//库名 $username="dbname";//用户 $pw="dbpass";//密码 $dbh= new PDO("dblib:host=$hostname:$port;dbname=$dbname;charset=UTF-8","$username","$pw"); } catch (PDOException $e) { echo"Failed to get DB handle: ".$e->getMessage() ."n"; exit; } echo'connent MSSQL succeed'; $stmt=$dbh->prepare("select firstname,lastname from table"); $stmt->execute(); while ($row=$stmt->fetch()) { print_r($row); } unset($dbh); unset($stmt); ?>
测试连接memcached
<?php $memcache = new Memcached; $memcache->addServer('192.168.1.20',11211) or dir ("Could not connect"); $memcache->set('key','Hello world!'); $get_value = $memcache->get('key'); echo $get_value; ?>