気付けばPHPとMySQLのコンパイルオプションが変わっていたでござるの巻
こんにちは!僕です!
MySQL5.5がGAになってから5ヶ月近くが経ち、テスト環境構築を兼ねて現時点の最新版をインストールすることにしました。
まず現時点で最新のMySQLをダウンロード
$ wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.11.tar.gz/from/http://ftp.iij.ad.jp/pub/db/mysql/
$ tar zfx mysql-5.5.11.tar.gz
$ ./configure
- bash: ./configure: そのようなファイルやディレクトリはありません
ってあれ?configureが通らないの???
とりあえずconfigファイルの中身を確認しようとディレクトリの中身を調べると
CMAKE?-rw-r--r-- 1 7161 wheel 8479 3月 31 22:36 BUILD-CMAKE
BUILD-CMAKEの中を読むとわかるが、MySQL5.5からビルドがconfigureからcmakeになったんですね。
しかもさらに調べるとコンパイルオプションも全然変わってるようで、比較的よく使うオプションはこうなる
その他のオプションについてはマニュアルをご参考ください。--prefix=/usr/local/mysql/ → -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
ということで、cmakeが無い場合はコンパイルしてcmakeするとうまくいきます。
$ cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
$ make
$ sudo make install
mysql_install_dbはパスが通ってないのか、ファイルがあるディレクトリに行かないとうまく動いてくれない。
うまくいったら起動しましょう。
/usr/local/mysql/support-files/mysql.server start
mysql> show engines;
- --------------------+---------+------------------------------------------------------------+--------------+------+------------+
Engine Support Comment Transactions XA Savepoints
- --------------------+---------+------------------------------------------------------------+--------------+------+------------+
MRG_MYISAM YES Collection of identical MyISAM tables NO NO NO PERFORMANCE_SCHEMA YES Performance Schema NO NO NO MyISAM YES MyISAM storage engine NO NO NO InnoDB DEFAULT Supports transactions, row-level locking, and foreign keys YES YES YES CSV YES CSV storage engine NO NO NO MEMORY YES Hash based, stored in memory, useful for temporary tables NO NO NO
- --------------------+---------+------------------------------------------------------------+--------------+------+------------+
InnoDBがデフォルトストレージエンジンに変更されてます。
mysql> select @@innodb_version;
- ------------------+
@@innodb_version
- ------------------+
1.1.5
- ------------------+
どうにかMySQLが入ったので、次にPHP5.3.6をインストール
こちらはさすがにcmakeってことはないよね。
$ ./configure --prefix=/usr/local/php \
--with-apxs2=/usr/bin/apxs \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-pdo-mysql=/usr/local/mysql/bin/mysql_config
・・・あら?エラー?
mysqlライブラリがないだとぅ?checking for mysql_set_server_option in -lmysqlclient... no
configure: error: wrong mysql library version or lib not found. Check config.log for more information.
調べてみると
ちゃんと存在してるわ!
心が病みつつhelpを読む
ほうほう。$ ./configure --help | grep mysql
--with-mysql[=DIR] Include MySQL support. DIR is the MySQL base
directory. If mysqlnd is passed as DIR,
--with-mysql-sock[=DIR] MySQL/MySQLi/PDO_MYSQL: Location of the MySQL unix socket pointer.
--with-mysqli[=FILE] Include MySQLi support. FILE is the path
to mysql_config. If mysqlnd is passed as FILE,
the MySQL native driver will be used [mysql_config]
--enable-embedded-mysqli MYSQLi: Enable embedded support
--with-pdo-mysql[=DIR] PDO: MySQL support. DIR is the MySQL base directory
If mysqlnd is passed as DIR, the MySQL native
--disable-mysqlnd-compression-support
Enable support for the MySQL compressed protocol in mysqlnd
--with-zlib-dir[=DIR] mysqlnd: Set the path to libz install prefix
どうやらphp5.3系からはmysqlndというネイティブmysqlドライバが搭載されたようで、mysqlを使う場合は
--with-mysqli=[MySQLのベースディレクトリ]
- with-mysqli=mysqlnd
どちらかでいけるらしい。
mysql_configを指定してるのに入れてくれないのは何故かわからないが、とりあえずネイティブドライバを使うことにする。
$ ./configure --prefix=/usr/local/php \
--with-apxs2=/usr/bin/apxs \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd
今度はちゃんと通った。+--------------------------------------------------------------------+
License: This software is subject to the PHP License, available in this distribution in the file LICENSE. By continuing this installation process, you are bound by the terms of this license agreement. If you do not agree with the terms of this license, you must abort the installation process at this point.
- --------------------------------------------------------------------+
あとは普通にmakeしてインストール
# make
# make install
いちおうこれでコンパイルは通ったわけだけど、mysqliやmysqlpdoと全く同等にmysqlndが使えるのかどうかはこれから検証します。
とりあえず今回の作業で、毎日同じことだけ繰り返してると、いつの間にか周りに取り残されることだけは判りました(汗