[toc]
PHP扩展模块安装
下载安装redis
redis 在LAMP下,被当作缓存来使用!
1. 下载并切换到指定目录:
cd /usr/local/src/wget https://codeload.github.com/phpredis/phpredis/zip/develop mv develop phpredis-develop.zip //改名unzip phpredis-develop.zip //解压缩cd phpredis-develop
2. 生成configure:
/usr/local/php7/bin/phpize //生成configure文件
有时候安装会出错,缺少一个包autoconf
[root@xavi phpredis-develop]# yum install -y autoconf
重新生成configure
[root@xavi phpredis-develop]# /usr/local/php7/bin/phpizeConfiguring for:PHP Api Version: 20160303Zend Module Api No: 20160303Zend Extension Api No: 320160303
3. 编译配置:
[root@xavi phpredis-develop]# ./configure --with-php-config=/usr/local/php7/bin/php-config
4. 安装测试:
makemake installls /usr/local/php7/lib/php/extensions/no-debug-zts-20160303/opcache.so redis.so
然后就会有redis.so这个插件!这就是我们需要的扩展模块
[root@xavi phpredis-develop]# make installInstalling shared extensions: /usr/local/php7/lib/php/extensions/no-debug-zts-20160303/[root@xavi phpredis-develop]# ls /usr/local/php7/lib/php/extensions/no-debug-zts-20160303/opcache.so redis.so
5. 查看php是否支持redis:/usr/local/php7/bin/php -m |grep redis
[root@xavi phpredis-develop]# /usr/local/php7/bin/php -m[PHP Modules]bz2CorectypedatedomexiffileinfofiltergdhashiconvjsonlibxmlmbstringmcryptmysqliopensslpcrePDOpdo_mysqlpdo_sqlitePharposixReflectionsessionSimpleXMLsoapsocketsSPLsqlite3standardtokenizerxmlxmlreaderxmlwriterzlib[Zend Modules]
不支持,找到模块路径
[root@xavi phpredis-develop]# /usr/local/php7/bin/php -m |grep redis
6.查找extension_dir,查看扩展模块存放目录,我们可以在php.ini中去自定义该路径
[root@xavi phpredis-develop]# /usr/local/php7/bin/php -i |grep extension_dir extension_dir => /usr/local/php7/lib/php/extensions/no-debug-zts-20160303 => /usr/local/php7/lib/php/extensions/no-debug-zts-20160303sqlite3.extension_dir => no value => no value
7.手动添加模块
[root@xavi phpredis-develop]# vim /usr/local/php7/etc/php.ini
搜索 /extension extension = redis.so
[root@xavi phpredis-develop]# vim /usr/local/php7/etc/php.ini [root@xavi phpredis-develop]# /usr/local/php7/bin/php -m |grep redisredis
2.编译自带的PHP源码包
实际上在php7的源码包中,有很多自带的源码包。我们不需要再次下载,直接编译即可!
[root@xavi phpredis-develop]# cd /usr/local/src/php-7.1.6/[root@xavi php-7.1.6]# cd ext/[root@xavi ext]# lsbcmath fileinfo libxml pdo_firebird session tidybz2 filter mbstring pdo_mysql shmop tokenizercalendar ftp mcrypt pdo_oci simplexml wddxcom_dotnet gd mysqli pdo_odbc skeleton xmlctype gettext mysqlnd pdo_pgsql snmp xmlreadercurl gmp oci8 pdo_sqlite soap xmlrpcdate hash odbc pgsql sockets xmlwriterdba iconv opcache phar spl xsldom imap openssl posix sqlite3 zipenchant interbase pcntl pspell standard zlibexif intl pcre readline sysvmsgext_skel json pdo recode sysvsemext_skel_win32.php ldap pdo_dblib reflection sysvshm
然后我们会发现有很多自带的源码包,
1. 首先我们先确认一个zip包,
[root@xavi ext]# /usr/local/php7/bin/php -m |grep zip[root@xavi ext]# cd zip/[root@xavi zip]# lsconfig.m4 CREDITS lib php_zip.c tests zip_stream.cconfig.w32 examples LICENSE_libzip php_zip.h TODO
2.假如我们需要编译一个zip,首先进入zip目录。 然后输入:
[root@xavi zip]# /usr/local/php7/bin/phpize Configuring for:PHP Api Version: 20160303Zend Module Api No: 20160303Zend Extension Api No: 320160303[root@xavi zip]# ./configure --with-php-config=/usr/local/php7/bin/php-config
3.make;make install
[root@xavi zip]# make installInstalling shared extensions: /usr/local/php7/lib/php/extensions/no-debug-zts-20160303/[root@xavi zip]# ls /usr/local/php7/lib/php/extensions/no-debug-zts-20160303/opcache.so redis.so zip.so
部分转载来源:PHP扩展模块安装 - Laoqi's Blog
实用扩展:
apache rewrite教程
apache rewrite 出现死循环
php错误日志级别参考
php开启短标签
php.ini详解