Last active
July 2, 2024 14:35
-
-
Save UbuntuEvangelist/724c6fc423faa3445d75415dfed1b9c6 to your computer and use it in GitHub Desktop.
PHP OCI8 Extension and Oracle Instant Client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Things to do after install Ubuntu: | |
sudo -i | |
apt update -y && apt upgrade -y | |
apt install build-essential checkinstall | |
apt install ubuntu-restricted-extras | |
apt install software-properties-common | |
apt install apt-show-versions | |
apt upgrade -o APT::Get::Show-Upgraded=true | |
apt-show-versions | grep upgradeable | |
apt install git | |
git config --global user.name "name" | |
git config --global user.email [email protected] | |
ssh-keygen -t rsa -b 4096 -C "[email protected]" | |
eval "$(ssh-agent -s)" | |
ssh-add ~/.ssh/id_rsa | |
# Add SSH Key the GitHub | |
cat /root/.ssh/id_rsa.pub | |
apt upgrade -y && apt update | |
apt -f install && apt autoremove | |
apt -y autoclean && apt -y clean | |
apt upgrade -y && apt update | |
reboot | |
Update Package List and Install Prerequisites: | |
sudo apt update | |
sudo apt install -y build-essential libaio1 unzip | |
Download Oracle Instant Client: | |
Go to the Oracle Instant Client Downloads page and download the Basic and SDK packages for Linux x86-64. | |
https://www.oracle.com/database/technologies/instant-client/downloads.html | |
Install Oracle Instant Client: | |
sudo mkdir -p /opt/oracle | |
sudo unzip -d /opt/oracle /path/to/instantclient-basic-linux.x64-*.zip | |
sudo unzip -d /opt/oracle /path/to/instantclient-sdk-linux.x64-*.zip | |
sudo ln -s /opt/oracle/instantclient_19_8 /opt/oracle/instantclient | |
sudo sh -c "echo /opt/oracle/instantclient > /etc/ld.so.conf.d/oracle-instantclient.conf" | |
sudo ldconfig | |
Install PHP OCI8 Extension: | |
sudo apt install -y php-pear php-dev | |
sudo pecl install oci8-2.2.0 | |
During the installation, you'll be prompted to provide the Oracle Instant Client directory. Enter: | |
instantclient,/opt/oracle/instantclient | |
Enable OCI8 Extension: | |
echo "extension=oci8.so" | sudo tee /etc/php/7.4/cli/conf.d/20-oci8.ini | |
echo "extension=oci8.so" | sudo tee /etc/php/7.4/apache2/conf.d/20-oci8.ini | |
sudo systemctl restart apache2 | |
Import Microsoft Keys and Repository: | |
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - | |
sudo curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list > /etc/apt/sources.list.d/mssql-release.list | |
sudo apt update | |
Install ODBC Driver: | |
sudo ACCEPT_EULA=Y apt-get install -y msodbcsql17 | |
sudo apt-get install -y unixodbc-dev | |
Install PHP SQLSRV Extension: | |
sudo apt install -y php-pear php-dev | |
sudo pecl install sqlsrv | |
sudo pecl install pdo_sqlsrv | |
Enable SQLSRV Extension: | |
echo "extension=sqlsrv.so" | sudo tee /etc/php/7.4/cli/conf.d/20-sqlsrv.ini | |
echo "extension=sqlsrv.so" | sudo tee /etc/php/7.4/apache2/conf.d/20-sqlsrv.ini | |
echo "extension=pdo_sqlsrv.so" | sudo tee /etc/php/7.4/cli/conf.d/20-pdo_sqlsrv.ini | |
echo "extension=pdo_sqlsrv.so" | sudo tee /etc/php/7.4/apache2/conf.d/20-pdo_sqlsrv.ini | |
sudo systemctl restart apache2 | |
Troubleshooting Common Errors | |
Check PHP and Apache Logs: Look for errors in /var/log/apache2/error.log or using journalctl -xe. | |
Verify Extensions Loaded: Use php -m to list loaded extensions. | |
Check Dependencies: Ensure all required libraries are installed. | |
Reinstall Extensions: If issues persist, try reinstalling the extensions. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment