10. PHP擴展模塊安裝
阿新 • • 發佈:2018-03-12
php擴展模塊[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/phpize
Configuring for:
PHP Api Version: 20160303
Zend Module Api No: 20160303
Zend Extension Api No: 320160303
3. 編譯配置:
[root@xavi phpredis-develop]# ./configure --with-php-config=/usr/local/php7/bin/php-config
4. 安裝測試:
make
make install
ls /usr/local/php7/lib/php/extensions/no-debug-zts-20160303/
opcache.so redis.so
然後就會有redis.so這個插件!這就是我們需要的擴展模塊
[root@xavi phpredis-develop]# make install Installing 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]
bz2
Core
ctype
date
dom
exif
fileinfo
filter
gd
hash
iconv
json
libxml
mbstring
mcrypt
mysqli
openssl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
Reflection
session
SimpleXML
soap
sockets
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zlib
[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-20160303
sqlite3.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 redis
redis
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]# ls
bcmath fileinfo libxml pdo_firebird session tidy
bz2 filter mbstring pdo_mysql shmop tokenizer
calendar ftp mcrypt pdo_oci simplexml wddx
com_dotnet gd mysqli pdo_odbc skeleton xml
ctype gettext mysqlnd pdo_pgsql snmp xmlreader
curl gmp oci8 pdo_sqlite soap xmlrpc
date hash odbc pgsql sockets xmlwriter
dba iconv opcache phar spl xsl
dom imap openssl posix sqlite3 zip
enchant interbase pcntl pspell standard zlib
exif intl pcre readline sysvmsg
ext_skel json pdo recode sysvsem
ext_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]# ls
config.m4 CREDITS lib php_zip.c tests zip_stream.c
config.w32 examples LICENSE_libzip php_zip.h TODO
2.假如我們需要編譯一個zip,首先進入zip目錄。 然後輸入:
[root@xavi zip]# /usr/local/php7/bin/phpize
Configuring for:
PHP Api Version: 20160303
Zend Module Api No: 20160303
Zend 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 install
Installing 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教程 http://coffeelet.blog.163.com/blog/static/13515745320115842755199/
http://www.cnblogs.com/top5/archive/2009/08/12/1544098.html
apache rewrite 出現死循環 http://ask.apelearn.com/question/1043
php錯誤日誌級別參考 http://ask.apelearn.com/question/6973
php開啟短標簽 http://ask.apelearn.com/question/120
php.ini詳解 http://legolas.blog.51cto.com/2682485/493917
10. PHP擴展模塊安裝