Search code examples
phplinuxoracle-databaseapachechef-solo

Enabling php_oci8_11g extension in php.ini via Chef recipe for Linux


We have a website which is written with PHP and Oracle as backend database. We are trying to automate the deployment process via Chef-Solo. This runs on AWS EC2 instance.

Our cookbooks include

  1. apache2
  2. ourwebsite
  3. aws
  4. yum

I have enabled PHP module in apache2, and I can see php pages running on the instance. We need to install oracle extension for PHP. In windows, enabling php_oci8_11g extension in the php.ini file is required. I am not sure what is the procedure for linux.

Also, there is no PHP5-oracle cookbook available. Do we need to write our own cookbook for that? I so can someone please share any resources available on enabling php extensions via Chef?

Thanks.


Solution

  • I followed the steps given here in oracle website for installing oracle instant client for linux (See section: Enabling the PHP OCI8 Extension on Linux)

    I have installed the following cookbooks:

    • aws
    • yum
    • build-essential
    • apache2
    • oracle-instantclient
    • oracle-instantclient::sdk
    • php
    • ourwebsite

    Inside ourwebsite default recipe I added the following code

    include_recipe 'php'
    
    service 'httpd' do
      action :stop
    end
    
    php_pear "oci8" do
      action :install
    end
    
    service 'httpd' do
      action :start
    end
    

    Explanation: oracle-instantclient and oracle-instantclient::sdk will download the rpms from the url you have given, and installs the client. You need build-essentials for C compiler which is needed while installing oci8. php_pear resource will install oci8.