Setup PHP-OCI8 on Centos 7 / Ubuntu14.04
Install Apache and PHP55
You can use apt-get on ubuntu or yum on centos. Default version of php on centos repository is php5.4, but you can add epel repository to install php55. You have to install these packages before installing PHP-OCI8:
- Apache
- PHP with php-devel and php-pear
- libaio on centos or libaio1 on ubuntu
- gcc
Centos 7
sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-2.noarch.rp
sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
sudo yum —enablerepo=remi,remi-php55 install httpd php php-devel libaio gcc
Ubuntu 14.04
sudo apt-get update
sudo apt-get install apache2 php5 php5-dev php5-pecl libaio1 gcc
Install PHP-OCI8
You will need oracle instant client, you can download it here. Get the basic and sdk packages and extract it to somewhere, ex: /opt/instantclient.
Use pecl to install oci8:
sudo pecl install oci8
You will prompted for ORACLE_HOME directory, type “instantclient,/your/instantclient/location”. Ex:
instantclient,/opt/instantclient
Enable oci8 extension on your php.ini. Add this line to the end of your php.ini file:
extension=oci8.so
Add Oracle Environment Variables to Apache
You have to add environment variables to your apache. You can use apache SetEnv module to add environment variables. Add this lines to your httpd.conf:
SetEnv LD_LIBRARY_PATH /opt/instantclient
Restart your apache and then check phpinfo on your browser.
If you are using centos, you need to configure SELinux to allows httpd to execute programs that require memory addresses that are both executable and writeable.
setsebool -P httpd_execmem 1