What are the best practices for ensuring that OCI is properly activated for PHP when using httpd on CentOS?

To ensure that OCI is properly activated for PHP when using httpd on CentOS, you need to make sure that the OCI8 extension is installed and enabled in your PHP configuration. You also need to configure the Oracle Instant Client on your server and set the necessary environment variables. Finally, restart the httpd service to apply the changes.

// Check if OCI8 extension is enabled
if (!extension_loaded('oci8')) {
    die('OCI8 extension is not enabled. Please enable it in your PHP configuration.');
}

// Set Oracle Instant Client environment variables
putenv('ORACLE_HOME=/path/to/oracle/instantclient');
putenv('LD_LIBRARY_PATH=/path/to/oracle/instantclient');

// Restart httpd service
exec('sudo systemctl restart httpd');