Setting up OCI8 (PHP Oracle module) on Webfaction
Webfaction, my favorite web host, allows you to compile PHP modules in your home directory for use on your websites. Here’s the process for configuring OCI8 to talk to Oracle databases:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# Make directories mkdir -p ~/lib/php71_exts/ mkdir -p ~/lib/php71_exts/instantclient cd ~/lib/php71_exts # Get the php module wget https://pecl.php.net/get/oci8-2.1.8.tgz tar xvf oci8-2.1.8.tgz cd oci8-2.1.8 phpize71 # Get Oracle Instant Client (use your local computer) # http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html # SSH the files to the server scp instantclient*.zip web553:~/lib/php71_exts/ # Extract files and symlink a few modules mv instantclient*.zip instantclient/ cd instantclient/ unzip instantclient-basic-linux.x64-12.2.0.1.0.zip unzip instantclient-sqlplus-linux.x64-12.2.0.1.0.zip unzip instantclient-sdk-linux.x64-12.2.0.1.0.zip cd instantclient_12_2/ ln -s libclntsh.so.12.1 libclntsh.so ln -s libocci.so.12.1 libocci.so # Configure the php module cd ~/lib/php71_exts/oci8-2.1.8/ ./configure --with-oci8=shared,instantclient,/home/yourname/lib/php71_exts/instantclient/instantclient_12_2 -with-php-config=/usr/local/bin/php71-config make mv modules/oci8.so ~/lib/php71_exts/ # Enable the module cd ~/webapps/mysite ls /home/yourname/lib/php71_exts/oci8.so ls -alh /home/yourname/lib/php71_exts/oci8.so vim php.ini extension_dir=/home/yourname/lib/php71_exts extension=/home/yourname/lib/php71_exts/oci8.so # Test # Create a file (e.g., index.php) to call phpinfo(). # Load the page and check if the OCI module is loaded. # Cleanup cd ~/lib/php71_exts/ rm package.xml oci8-2.1.8.tgz |