「PHP用Oracleのインストール」の版間の差分
Toshihiro KITA (トーク | 投稿記録) (ページの作成:「* http://www.oracle.com/technetwork/articles/technote-php-instant-084410.html * http://moodle.org/mod/forum/discuss.php?d=65488#p308002 (添付htmlドキュメント付…」) |
(相違点なし)
|
2022年2月21日 (月) 08:03時点における版
- http://www.oracle.com/technetwork/articles/technote-php-instant-084410.html
- http://moodle.org/mod/forum/discuss.php?d=65488#p308002 (添付htmlドキュメント付き)
- http://es.php.net/oci8
Oracle Express EditionでWindowsにMoodleをインストールする
はじめに
ここでは、WindowsにOracle Express Editionを搭載したMoodleをインストールする方法を説明します。私は、デバッグ 目的で使用しています。本番環境ではありません。目標は、簡単かつ迅速にMoodle/Windows/Oracle環境をセットアップすることです。
Oracleのインストール
- Oracle Express Editionは、Oracle社のWebサイトからダウンロードしてください。
- また、インスタントクライアントコチラが必要です。(無料アカウント登録が必要です)。解凍されたフォルダからすべてをapache/binにコピーします。
- 両方をインストールします。
- http://127.0.0.1:8080/apex の Oracle コンソールにアクセスします (Login=SYS Password=the_one_you_entered_during_the_installation)。
- 新しいユーザを作成し、すべての権利(DBAを含む)を与えます。
- SQL Commands ページに移動し、新しいユーザに dmbs_lock 権限を付与します...
.
grant execute on dbms_lock to XXXXX;
...ここで、XXXXXは新しいユーザのユーザ名です。
- ログアウトして、新しいユーザでログインします。
- Moodleコードベースの/lib/dml/oci_native_moodle_package.sqlにあるスクリプトを実行してください。このスクリプトを直接実行できない場合、SQLコマンドページで各パーツ(スラッシュで区切られた部分)を個別に実行することができます。
注: Oracle Express Edition 10gは、'XE' と呼ばれる1つのデータベースに限定されています。
Oracleの拡張機能を設定する
このドキュメントでは、Oracle用のapache/phpのセットアップ方法については説明しません。詳しくは、Oracle社のドキュメントをご覧ください。
phi.ini ファイルを編集し、php_oci8 拡張子のコメントを解除(先頭のセミコロンを削除)してください。WAMPセットアップでは、これは以下としてリストされています...
extension=php_oci8.dll
また、開発/テスト目的でインストールを使用する場合は、以下の行のコメントを解除し、値をゼロに設定してください。通常の運用では必要ありません(システムのBIGスローダウンを引き起こします!)。
oci8.statement_cache_size = 0
また、php_oracle, php_pdo_oci, php_pdo_oci8 のコメントアウトを解除する必要がある場合があります。
Moodleのインストール
データベースの設定ページ:
Driver: Oracle oci8 (1.9.x をインストールした場合は "oci8po" を、2.0.x をインストールした場合は "oci" を設定ファイルに記述する必要があります。)
Host: 空のフィールド
Database: //localhost:1521/XE
User: あなたが作成したユーザ
Password: ユーザに与えたパスワード
Apacheの設定
あなたがOracle上でMoodleをLinux上のApacheで動作させている場合、PHPがシステム環境変数を参照することができないという問題が発生する可能性があります。 これを解決するには、/etc/sysconfig/apache2を編集して、以下の行を一番下に追加してください:
LD_LIBRARY_PATH=/opt/oracle/instantclient_11_2# Set LANG Variables for UTF-8
NLS_LANG=AMERICAN_AMERICA.AL32UTF8
LANG=en_US.UTF-8
LC_ALL=en_US.UTF-8
LC_COLLATE=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
LC_MESSAGES=en_US.UTF-8
LC_MONETARY=en_US.UTF-8
LC_NUMERIC=en_US.UTF-8
LC_TIME=en_US.UTF-8
NLS_NUMERIC_CHARACTERS='.,'
export LANG LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIM NLS_LANG LD_LIBRARY_PATH NLS_NUMERIC_CHARACTERS
また、この2行を ~/.bashrc に追加して、PHP のコマンドラインクライアントにも表示できるようにする必要があります。
UbuntuへのOracle Expressのインストール
I needed to test an installation of Oracle with Moodle, here's what I did
- Ubuntu 14.04.1 LTS 64 bit
- Oracle 11g Release 2 Express Edition
- SQL Developer 4.0.3.16
Oracle Express and SQL Developer
Ignore all other sites and follow these instructions - http://blog.whitehorses.nl/2014/03/18/installing-java-oracle-11g-r2-express-edition-and-sql-developer-on-ubuntu-64-bit/
Log out of Chrome before doing this bit though because Chrome uses the same folder and it will instantly crash.
sudo rm -rf /dev/shm sudo mkdir /dev/shm sudo mount -t tmpfs shmfs -o size=4096m /dev/shm
Also, change 4096m to whatever half your memory is.
If you get a fatal error when running sqldeveloper then
gksudo gedit /opt/sqldeveloper/sqldeveloper/bin/sqldeveloper
and add these 2 lines at the top
unset GNOME_DESKTOP_SESSION_ID unset DBUS_SESSION_BUS_ADDRESS
Found the answer here http://linuxsagas.digitaleagle.net/2014/01/28/fixing-sql-developer-4-0/
After installing and when creating a connection, the default username is SYSTEM and use the password created in the step sudo /etc/init.d/oracle-xe configure
In gnome classic - The menus for Oracle are under Other, sqldeveloper is under Programming
Create a user
Probably easiest to use the application express:
- Go to "Get Started With Oracle Database 11g Express Edition" - either from the applications -> other menu (in gnome) or via the desktop icon that was created when installing.
- This will open a page in your browser.
- Login as SYSTEM
- Click on the application express tab
- Create a user and password
- Then go to SQL Developer (In Gnome classic - go to applications -> programming -> sqldeveloper) and create and open a connection using the newly created user
PHP
Follow these instructions - https://help.ubuntu.com/community/PHPOracle
Add extension=oci8.so to both /etc/php5/apache2/php.ini and /etc/php5/cli/php.ini otherwise the client php cron won't work
Restart apache2
Then test with this
<?php error_reporting( -1 ); ini_set( 'display_errors', 1 ); $conn = oci_connect('USERNAME', 'password', 'localhost/XE'); if (!$conn) { $e = oci_error(); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); } // Prepare the statement $sql = "SELECT * FROM atable"; // Change this. $stid = oci_parse($conn, $sql); if (!$stid) { $e = oci_error($conn); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); } // Perform the logic of the query $r = oci_execute($stid); if (!$r) { $e = oci_error($stid); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); } // Fetch the results of the query print "<table border='1'>\n"; while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) { print "<tr>\n"; foreach ($row as $item) { print " <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : " ") . "</td>\n"; } print "</tr>\n"; } print "</table>\n"; oci_free_statement($stid); oci_close($conn);
Related links
- Installing ORACLE drivers with PHP
- Installing MSSQL for PHP
- PHP
- Can i install Moodle with Oracle database
- Who uses Oracle
- Step by step Install Guide for Solaris 10 with Oracle 10
- Install Moodle on an Oracle Database (in 25 minutes or less). The related Using Moodle forum discussion is here.
- Moodle on Oracle Database discussion on Miguel Guhlin's blog