I recently had to work on a project that was written in PHP and was getting data from an Oracle database. Installing
php on Ubuntu is pretty straightforward but connecting to the database unfortunately required quite a few gymnastics!
In this article we will look at how to compile PHP extensions on Ubuntu 18.04 and above, specifically the
pdo_oci extension. Note that in order for this extension to work, the oracle drivers must be already installed. See this article for instructions on how to setup Oracle drivers on Ubuntu.
The general procedure to install extensions is as follows:
sudo make install
sudo service php7.2-fpm restart
This above method installs a
pdo_oci.so in the PHP extensions folder, without the need for recompiling
all of PHP. Note that in my case, the project in question was using the
PDO OCI driver which is actually experimental and not
recommended. The officially approved Oracle driver is OCI and can be installed via
pecl install oci8 (provide the instant client path when prompted
instantclient,/opt/oracle/instantclient_18_3). Note that if this does not work further instructions can be
phpinfo() should now show all the extensions that have been enabled and you can always check your webserver error logs for any issues. Happy coding!
Back to the article list.
Subscribe to get articles as they are published direct to your inbox!