This solution is for those facing problems connecting the Oracle database with PHP. It is tested on Fedora 41(a Linux distribution) and the Oracle 23c database.
First, you need to install Oracle Instant Client. You can download it from here. After downloading, extract the zip file and move it to the /opt/oracle directory. You also need to download the SDK package and move it to the same directory.