LoginSignup
57
65

More than 5 years have passed since last update.

phpに後から拡張モジュールを追加する

Posted at

環境
OS:Ubuntu14.04
PHP:5.6.0
thinkpad T440p

phpに後からモジュールを追加して有効したいときにはsourceファイルの下にextというディレクトリがあるのでそこにあるものをビルドして設定を有効にする
php5.6のsourceは~/work/php-5.6.0にあるとする

追加例

mcrypt

インストール手順
http://php.net/manual/ja/mcrypt.installation.php

cd ~/work/php-5.6.0/ext/mcrypt
phpize
./configure --with-mcrypt  #php5.6のsourceコンパイル時につけてもいい

configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
configure: error: mcrypt.h not found. Please reinstall libmcrypt.

何か怒られた。必要なものをインストールしておく

cd ~/work
wget http://jaist.dl.sourceforge.net/project/re2c/re2c/0.13.7.5/re2c-0.13.7.5.tar.gz
tar zxvf 
cd re2c-0.13.7.5
./configure
make 
sudo make install

sudo apt-get install libmcrypt-dev

モジュール追加作業再開(phpizeは先ほどやったので省略)

cd ~/work/php-5.6.0/ext/mcrypt
./configure --with-mcrypt
make
make test
sudo make install

Installing shared extensions:     /usr/local/lib/php/extensions/no-debug-zts-20131226/

これで.soファイルがインストールされる
次にphp.iniファイルを編集して認識させる
php.iniがないならsourceディレクトリにあるphp.ini-productionなどのスケルトンをphp -iで見れるconfigurationの位置にコピーしておく(例えば、/usr/local/lib/php.ini)
extension_dirの位置と.soファイル名を追記する

php.ini
extension_dir = "/usr/local/lib/php/extensions/no-debug-zts-20131226/"
extension=mcrypt.so

php -mで確認

openssl

cd source_dir/ext/openssl
phpize
./configure --with-openssl
make
make test
sudo make install

Installing shared extensions:     /usr/local/lib/php/extensions/no-debug-zts-20131226/

php.iniにextension追記

php.ini
・・・
extension=openssl.so
・・・

php -mで確認

zip

cd source_dir/ext/zip
phpize
./configure --enable-zip
make
make test
sudo make install

Installing shared extensions:     /usr/local/lib/php/extensions/no-debug-zts-20131226/

php.iniに追記

php.ini
・・・
extension=zip.so
・・・

php -mで確認
57
65
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
57
65