/usr/local/php/bin/php -m
好比:zip 這個模塊php
[root@linux-129 ext]# cd zip [root@linux-129 zip]# ls config.m4 CREDITS lib php_zip.c tests zip_stream.c config.w32 examples LICENSE_libzip php_zip.h TODO
[root@linux-129 zip]# /usr/local/php/bin/phpize Configuring for: PHP Api Version: 20131106 Zend Module Api No: 20131226 Zend Extension Api No: 220131226 Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script. 這裏出現一個錯誤,沒有發現autoconf包
安裝 autoconflinux
[root@linux-129 zip]# yum install -y autoconf
從新生成.configure文件git
[root@linux-129 zip]# /usr/local/php/bin/phpize Configuring for: PHP Api Version: 20131106 Zend Module Api No: 20131226 Zend Extension Api No: 220131226
[root@linux-129 zip]# ./configure --with-php-config=/usr/local/php/bin/php-config [root@linux-129 zip]# make [root@linux-129 zip]# make install Installing shared extensions: /usr/local/php7/lib/php/extensions/no-debug-zts-20160303/ 這個就是擴展模塊存放的目錄: /usr/local/php7/lib/php/extensions/no-debug-zts-20160303/ [root@linux-129 zip]# ls /usr/local/php7/lib/php/extensions/no-debug-zts-20160303/ opcache.so zip.so
[root@linux-129 zip]# vim /usr/local/php7/etc/php.ini 內容最下面一行或者找到extension字段下一行添加內容:extension=zip.so
[root@linux-129 zip]# /usr/local/php7/bin/php -m|grep zip zip
若是php源碼包安裝目錄/ext目錄下面沒有想要的模塊安裝包,咱們就要去網上去下載 這種擴展模塊該在什麼地方去下載下來呢?github
php有個專門提供擴展的地方
http://pecl.php.net/
下面安裝一個redis的模塊 \在lamp架構中,redis被當作一個緩存來使用,redis
• cd /usr/local/src/
[root@linux-129 src]# wget https://codeload.github.com/phpredis/phpredis/zip/develop • mv develop phpredis-develop.zip • unzip phpredis-develop.zip • cd phpredis-develop
[root@linux-129 phpredis-develop]# /usr/local/php7/bin/phpize //爲了生成configure文件 Configuring for: PHP Api Version: 20160303 Zend Module Api No: 20160303 Zend Extension Api No: 320160303
[root@linux-129 phpredis-develop]# ./configure --with-php-config=/usr/local/php7/bin/php-config [root@linux-129 phpredis-develop]# make [root@linux-129 phpredis-develop]# make install Installing shared extensions: /usr/local/php7/lib/php/extensions/no-debug-zts-20160303/ 存放擴展模塊的目錄 /usr/local/php7/lib/php/extensions/no-debug-zts-20160303/ /usr/local/php/bin/php -i |grep extension_dir //查看擴展模塊存放目錄,咱們能夠在php.ini中去自定義該路徑 [root@linux-129 phpredis-develop]# ls /usr/local/php7/lib/php/extensions/no-debug-zts-20160303/ opcache.so redis.so zip.so
[root@linux-129 phpredis-develop]# vim /usr/local/php7/etc/php.ini //增長一行配置(能夠放到文件最後一行) extension = redis.so