WindowsでのPDO+SQLiteセットアップ
|
PHPはすでにインストールされているものとします。 PHP Snapshotsにあるver5.x以上のWin32 Packageをダウンロードします。 PHPのバージョンとdllのバージョンが一致しない場合にエラーが起こるようです。 該当するバージョンのCollection of PECL modulesをダウンロードして必要なdllを取得してください。 必要なDLLファイルはphp_pdo.dllとphp_pdo_sqlite.dllの2つのファイルです。 それを「ext」フォルダに保存します。 例)C:wwwphpext 次に「WINDOWS」フォルダにある「php.ini」ファイルを変更します。 (phpに付属している「php.ini-dist」を名前を変えて「WINDOWS」フォルダにコピー) 変更個所は二行で「extension_dir」に「php_pdo.dll」「php_pdo_sqlite.dll」を保存したパスを入力します。 更に、以下の行を追加します。 extension=php_pdo.dll extension=php_pdo_sqlite.dll
; Directory in which the loadable extensions (modules) reside.
extension_dir = "C:wwwphpext" extension=php_pdo.dll extension=php_pdo_sqlite.dll 修正後httpdプロセスを再起動させます。 |
LinuxでのPDOセットアップ
| パッケージのインストール |
|
LinuxへのインストールはDo You PHP?さんをご覧頂くのが良いかと思います。 -------------------------------- 今回インストールした環境 OS:VineLinux3.1 Apache2-2.0.5 php5-5.0.3 -------------------------------- PHPはコンパイルせずにrpmでインストールしました。 extension_dirはデフォルトの/usr/lib/php5/です。 上手く動くか?pdo.tgzこれを使うのは自己責任でお願いします。 PHPはすでにインストールされているものとします。 Do You PHP?さんのページを見ながらインストール作業をしてみました。 $ pear download pdo $ tar xzvf PDO-0.2.4.tgz $ cd PDO-0.2.4 $ phpize Configuring for: PHP Api Version: 20031224 Zend Module Api No: 20041030 Zend Extension Api No: 220040412Do You PHP?さんの所で、ご指摘されていた通りwarningが沢山でました。 私は、気にせず続けました。 $./configure 何か色々でる……ここでも特にオプションは指定していません。
$ make
----------------------------------------------------------------------
Libraries have been installed in:
/var/tmp/pear-build-root/PDO-0.2.4/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.
(It is safe to ignore warnings about tempnam and tmpnam).
# make install
Installing shared extensions: /usr/lib/php5/
Installing PDO headers: /usr/include/php/ext/pdo/
----------------------------------
まず、PDOが完成。 |
| php.iniの変更 |
extension = pdo.so php.iniをここで変更しました。 pdo_sqliteのインストール時にエラーがでました。 php.iniの設定が原因だったのか分からないのですが、設定したらエラーがなくなりました。 |
LinuxでのPDO_SQLiteセットアップ
| パッケージのインストール |
$ pear download pdo_sqlite
# pear install PDO_SQLITE-0.2.2tgz
----------------------------------------------------------------------
Libraries have been installed in:
/var/tmp/pear-build-root/PDO_SQLITE-0.2.2/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.
(It is safe to ignore warnings about tempnam and tmpnam).
pdo_sqlite.so copied to /tmp/tmpfXTRMX/PDO_SQLITE-0.2.2/pdo_sqlite.so
Build process completed successfully
Installing 'pdo_sqlite.so' at ext_dir (/usr/lib/php5/pdo_sqlite.so)
install ok: PDO_SQLITE 0.2.2
pdo_sqliteはpearコマンドからインストールできました。pdoのセットアップの所で書きましたが、pdoがインストールされていないと以下のエラーがでました。 'pdo' PHP extension is not installed PDO_SQLITE: Dependencies failed多分php.iniの設定でエラーが取れたと思います。 |
| php.iniの変更 |
extension = pdo.so extension = pdo_sqlite.sopdo_sqlite.soを追加します。 |
インストールの確認
|
phpinfo()を実行し、以下の情報が表示されればインストールは完了です。
<?php phpinfo(); ?> PDO
pdo_sqlite
|
