ソースインストールしたPHP、いざ使おうとしたらsocketsがないって怒られた・・・
そんな時今まではPHPのconfigureからやり直してましたが追加だけなら違う方法で出来るようです。
環境
PHP5.2.9
ソースの場所に移動します。
~~~
$ cd /usr/local/src/php-5.2.9/ext/sockets
~~~
※インストールされてないモジュールにはconfigureがありません
~~~
$ ls -la
-rw-r–r– 1 1002 1002 76 12月 14 2001 CREDITS
-rw-r–r– 1 1002 1002 951 7月 23 2007 config.m4
-rw-r–r– 1 1002 1002 380 12月 20 2003 config.w32
-rw-r–r– 1 1002 1002 1867 7月 24 2007 package.xml
-rw-r–r– 1 1002 1002 3670 12月 31 2008 php_sockets.h
-rw-r–r– 1 1002 1002 2658 12月 31 2008 php_sockets_win.c
-rw-r–r– 1 1002 1002 1920 12月 31 2008 php_sockets_win.h
-rw-r–r– 1 1002 1002 49992 2月 4 2009 sockets.c
-rw-r–r– 1 1002 1002 4830 1月 17 2004 sockets.dsp
drwxr-xr-x 2 1002 1002 4096 2月 26 2009 tests
-rw-r–r– 1 1002 1002 14871 12月 31 2008 unix_socket_constants.h
-rw-r–r– 1 1002 1002 5839 12月 31 2008 win32_socket_constants.h
~~~
phpizeする
これの存在初めて知りました・・・
拡張モジュールをビルドする低レベルなビルドツール。autoconfやautomake m4等のビルドツールが別途必要になる。これを使用することにより、PHPをソースから再コンパイルすることなく拡張モジュールをビルドすることができる。
実行します。パスが通ってない時はwhichで探してください
~~~
$ phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
~~~
失敗した時はこんなログ
~~~
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF
environment variable is set correctly and then rerun this script.
~~~
autoconfを入れればいいらしい
~~~
yum install autoconf
~~~
するとconfigureが作成されます
~~~
-rw-r–r– 1 1002 1002 76 12月 14 2001 CREDITS
-rw-r–r– 1 root root 5694 8月 10 12:13 Makefile.global
-rw-r–r– 1 root root 74808 8月 10 12:13 acinclude.m4
-rw-r–r– 1 root root 296550 8月 10 12:13 aclocal.m4
drwxr-xr-x 2 root root 4096 8月 10 12:13 autom4te.cache/
drwxr-xr-x 2 root root 4096 8月 10 12:08 build/
-rwxr-xr-x 1 root root 43499 8月 10 12:13 config.guess*
-rw-r–r– 1 root root 2146 8月 10 12:08 config.h.in
-rw-r–r– 1 1002 1002 951 7月 23 2007 config.m4
-rwxr-xr-x 1 root root 31743 8月 10 12:13 config.sub*
-rw-r–r– 1 1002 1002 380 12月 20 2003 config.w32
-rwxr-xr-x 1 root root 442169 8月 10 12:13 configure*
-rw-r–r– 1 root root 4646 8月 10 12:13 configure.in
-rw-r–r– 1 root root 0 8月 10 12:13 install-sh
-rw-r–r– 1 root root 186760 8月 10 12:13 ltmain.sh
-rw-r–r– 1 root root 0 8月 10 12:13 missing
-rw-r–r– 1 root root 0 8月 10 12:13 mkinstalldirs
-rw-r–r– 1 1002 1002 1867 7月 24 2007 package.xml
-rw-r–r– 1 1002 1002 3670 12月 31 2008 php_sockets.h
-rw-r–r– 1 1002 1002 2658 12月 31 2008 php_sockets_win.c
-rw-r–r– 1 1002 1002 1920 12月 31 2008 php_sockets_win.h
-rw-r–r– 1 root root 66348 8月 10 12:13 run-tests.php
-rw-r–r– 1 1002 1002 49992 2月 4 2009 sockets.c
-rw-r–r– 1 1002 1002 4830 1月 17 2004 sockets.dsp
drwxr-xr-x 2 1002 1002 4096 2月 26 2009 tests/
-rw-r–r– 1 1002 1002 14871 12月 31 2008 unix_socket_constants.h
-rw-r–r– 1 1002 1002 5839 12月 31 2008 win32_socket_constants.h
~~~
./configure
~~~
$ ./configure
creating libtool
appending configuration tag “CXX” to libtool
configure: creating ./config.status
config.status: creating config.h
~~~
make
~~~
$ make
Libraries have been installed in:
/usr/local/src/php-5.2.9/ext/sockets/modules
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR’
flag during linking and do at least one of the following:
– add LIBDIR to the `LD_LIBRARY_PATH’ environment variable
during execution
– add LIBDIR to the `LD_RUN_PATH’ environment variable
during linking
– use the `-Wl,–rpath -Wl,LIBDIR’ linker flag
– have your system administrator add LIBDIR to `/etc/ld.so.conf’
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
———————————————————————-
Build complete.
Don’t forget to run ‘make test’.
~~~
make install
~~~
$ make install
Installing shared extensions: /usr/local/php-5.2.9/lib/php/extensions/no-debug-non-zts-20060613/
~~~
php.iniに追記する
PECLでインストールした場合と同じく追記する必要があります
~~~
$ vim /usr/local/php/lib/php.ini
extension=sockets.so
~~~
確認
~~~
$ php -m
[PHP Modules]
ctype
date
dom
filter
gd
hash
iconv
json
libxml
mbstring
mcrypt
mongo
mysql
openssl
pcre
PDO
pdo_mysql
posix
Reflection
session
SimpleXML
sockets ←足されました
SPL
standard
tokenizer
xml
xmlreader
xmlwriter
zip
zlib
~~~
以上の手順でモジュールの追加が完了しました。
モジュール一個追加するのに全部configureしなおしかよーって思ってましたが知らない機能がまだまだあるものです。。。
このあと、最初にインストールしてあったopensslのパスが間違っていたのでPHPのconfigureからやり直したわけで・・・
コメント