LoginSignup
0
0

More than 1 year has passed since last update.

[OCI]Oracle Autonomous Linux 7.9にOracle Instant Client 21c+SQL*Plus+Apache+PHP+php-oci8をセットアップしたときのメモ

Last updated at Posted at 2022-04-13

rootユーザにスイッチ

sudo su -

Oracle Instant Client 21cとSQL*Plusをインストール

yum install -y oracle-instantclient-release-el7
yum install -y oracle-instantclient-sqlplus

環境変数の設定

cat <<'EOL' >> /etc/profile
export ORACLE_HOME=/usr/lib/oracle/21/client64/lib
export NLS_LANG=Japanese_Japan.AL32UTF8
export LD_LIBRARY_PATH=$ORACLE_HOME:$LD_LIBRARY_PATH
EOL

Apache + PHP + php-oci8のインストール

yum install -y oracle-php-release-el7
yum install -y php php-oci8-21c

Apacheの.phpファイルのハンドラーをapplication/x-httpd-phpに設定

cat <<'EOL' >>/etc/httpd/conf/httpd.conf
<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>
EOL

Apacheの起動

systemctl start httpd.service

Apacheの自動起動設定

systemctl enable httpd.service

firewalldの設定:HTTP(TCP 80),HTTPS(TCP 443)のアクセスを許可

firewall-cmd --list-all --zone=public
firewall-cmd --add-service=http  --zone=public --permanent
firewall-cmd --add-service=https --zone=public --permanent
firewall-cmd --reload
firewall-cmd --list-all --zone=public

SELinuxの設定変更

setsebool -P httpd_can_network_connect=1

Apacheの動作テスト用HTMLファイルを作成

cat <<'EOL' >>/var/www/html/index.html
<!DOCTYPE html>
<html lang="ja">
  <head>
    <meta charset="UTF-8">
    <title>test</title>
  </head>
  <body>
    <h1>やったぜ!</h1>
  </body>
</html>
EOL

Apache+PHPの動作テスト用PHPファイルの作成

cat <<'EOL' >>/var/www/html/info.php
<?php
echo phpinfo();
?>
EOL

ブラウザからアクセスして動作確認

http://<ComputeインスタンスのグローバルIP>/index.html
http://<ComputeインスタンスのグローバルIP>/info.php

info.phpの表示で以下を確認する

・PDOドライバにociが表示されていて、PDO_OCIが有効化されているか
スクリーンショット 2022-04-13 10.01.03.png

・oci8が有効化されているか
スクリーンショット 2022-04-13 9.58.54.png

0
0
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
0
0