As I am looking into Apex (again), here you can find a movie app built with Apex 20.2
just for fun, it contains information about approximately 85000 movies (from IMDb /
Kaggle).
The app pretends nothing. Just a study.
You can enter it with credentials demo / Verw1tabc
Release history
Upcoming challenges:
- changes are recorded regarding adding, modifying records. But are lost as with deletion.
mail
Bit more about PHP>
Also fond of PHP?
It was quit a challenge to get this going. Below the steps taken are written down.
But first, some information about numbers in the MovieApp database, queried from the Oracle database, with PHP :-)
As for now, 24/03/2023 07:20, we have these numbers in the database:
Movies | 85820 |
Actors | 417257 |
Writers | 61682 |
Directors | 34700 |
|
Technical background of the installation.
The infrastructure configuration is as follows, hosted at
cloud.oracle.com:
- Oracle database Version 19c
- Linux Ubuntu 20.04
- PHP 8.0
- Apache 2
- Oracle Instant Client 21.1
- OCI8
Let's not pretend it was easy. But finally we found a way to get it on.
Looking at the list and image above, you got the feeling, it was a long walk.
The bottomline was: get Oracle client software in a place the webserver can reach it,
and get PHP ready with the OCI8 module to communicate with the Oracle Client software.
So, what all happened (sudo where necessary):
- PHP 8.0
Add the repository with PHP8, it is not default in Ubuntu 20.04
$ sudo apt install software-properties-common
$ sudo add-apt-repository ppa:ondrej/php
We install php8.0 together with Apache webserver.
$ sudo apt update
$ sudo apt install php8.0 libapache2-mod-php8.0
We choose for FPM, the Fast CGI Process Manager for PHP:
$ sudo apt update
$ udo apt install php8.0-fpm libapache2-mod-fcgid
Restart Apache:
$ systemctl restart apache2
- Oracle Instantclient
url: https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html (for linux)
Download the basic and the tools, f.e.:
instantclient-basic-linux.x64-21.1.0.0.0.zip
instantclient-tools-linux.x64-21.1.0.0.0.zip
Upload these zip-files to the Ubuntu server.
Create a directory for the files:
$ mkdir /opt/oracle
Put the zip files in /opt/oracle and unzip them.
$ unzip instantclient-basic-linux.x64-21.1.0.0.0.zip
$ unzip instantclient-tools-linux.x64-21.1.0.0.0.zip
For ease of reading we moved instantclient_21_1 to instantclient.
Check that symlinks are present for libclntsh.so and libocci.so. Otherwise create them, like:
$ ln -s /opt/oracle/instantclient/libclntsh.so.12.1 /opt/oracle/instantclient/libclntsh.so
$ ln -s /opt/oracle/instantclient/libocci.so.12.1 /opt/oracle/instantclient/libocci.so
Add the Oracle Instantclient folder to ldconfig:
$ echo /opt/oracle/instantclient > /etc/ld.so.conf.d/oracle-instantclient
And load it:
$ ldconfig
Give the Apache webserver access to it:
$ sudo chown -R root:www-data /opt/oracle
- OCI
We need more PHP files to proceed with OCI8:
$ apt-get install php-dev php-pear build-essential libaio1
Update the pecl channel:
$ pecl channel-update pecl.php.net
Here it comes, finally:
$ pecl install oci8
Once asked, enter:
instantclient,/opt/oracle/instantclient
Then, glueing it all together, tell PHP to load the OCI8 extension and Apache where to look.
Find the php.ini files, like
$ find / -name php.ini
Edit them, add the OCI8 extension: extension=oci8.so
$ sudo vi /etc/php/8.0/fpm/php.ini
$ sudo vi /etc/php/8.0/apache2/php.ini
$ sudo vi /etc/php/8.0/cli/php.ini
We need to set environment variables, like TNS_ADMIN, ORACLE_HOME, and PATH.
$ export ORACLE_HOME=/opt/oracle/instantclient
$ export PATH=$PATH:/opt/oracle/instantclient
$ export TNS_ADMIN=/opt/oracle/instantclient/network/admin
You would probably look for that in /etc/environment and/or in .bashrc or .bash_profile.
Apache: edit the following with vi, vim or nano directly, or try with the following echo's:
$ echo "export LD_LIBRARY_PATH=/opt/oracle/instantclient" >> /etc/apache2/envvars
$ echo "export ORACLE_HOME=/opt/oracle/instantclient" >> /etc/apache2/envvars
$ echo "LD_LIBRARY_PATH=/opt/oracle/instantclient:$LD_LIBRARY_PATH" >> /etc/environment
-
Don't forget to edit sqlnet.ora and tns_names in /opt/oracle/instantclient/network/admin
-
Restarting the server now is not such a bad idea.
$ reboot
Then, after the server is up again, check and go!
The following should give a reply.
$ php -m | grep 'oci8'
(in case of problems, you could check /etc/php/8.0/fpm/conf.d and mods_available.)
Restart the PHP Fast Process Manager
$ service php8.0-fpm restart
- Check with info.php page, like
<?php
phpinfo();
Part of info.php:
... and relax, you can breath again