LAMP架構-PHP動態擴展模塊
阿新 • • 發佈:2018-03-08
php lamp 動態擴展模塊 LAMP架構-PHP動態擴展模塊
生產環境中,為保障網站正常運行,不允許再次編譯php,那麽缺少或漏安裝了模塊,可以通過單獨安裝模塊的方法來增加到php下面;
查看php加載的模塊
/usr/local/php/bin/php -m
類似於apache的-M一樣
舉例:增加redis.so模塊
下載模塊
cd /usr/local/src/
wget https://codeload.github.com/phpredis/phpredis/zip/develop
改名和解壓
mv develop phpredis-develop.zip
unzip phpredis-develop.zip
生成configure配置文件
/usr/local/php/bin/phpize
註意:必須提前安裝autoconf包,不然會告錯;
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.安裝autoconf包
yum install -y autoconf
指定配置
cd /usr/local/src/phpredis-develop/ ./configure --with-php-config=/usr/local/php/bin/php-config
編譯安裝
make && make install
安裝後提示模塊安放路徑
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20131226/
查詢模塊的路徑
/usr/local/php/bin/php -i |grep extension_dir extension_dir => /usr/local/php/lib/php/extensions/no-debug-zts-20131226 => /usr/local/php/lib/php/extensions/no-debug-zts-20131226 sqlite3.extension_dir => no value => no value
修改php.ini加載擴展模塊
vim /usr/local/php/etc/php.ini
搜索extension= 在後面增加一行
extension=redis.so
檢查是否加載redis
/usr/local/php/bin/php -m |grep redis
註意:要想生效,重啟apache服務;
LAMP架構-PHP動態擴展模塊