Ubuntu / SQL Server - PHP脚本适用于终端,但不适用于Web应用程序

I have an Ubuntu VM / Azure SQL DB combo where I have two sets of PHP files.

1) Some scripts that run from CRON jobs

2) A Yii2 Framework website

Both environments connect to an SQL Server database.

I have done all the steps to compile sqlsrv and added it to PHP's list of extensions. My scripts work great from the terminal, but on the website, I get an error:

could not find driver

My webserver is nginx, and it runs the website properly, but PDO does not connect to SQL Server.

I only have one PHP installation, but nevertheless used code to determine which is the right php.ini file in use and it has the right extensions directive.

A phpinfo() output also shows sqlsrv in the 'Registered PHP Streams' section.

My UFW firewall is inactive and I don't have SUSELinux. Nevertheless ports 22 and 80 are open. Even tried enabling it.

I am not sure what else to try. Help!

EDIT

I created a simple test file. When I run that through the terminal, it works, but when I do so via a browser, it doesn't.

EDIT 2

I installed Apache2 instead of nginx, and everything works now.

I think you need to try with just some "Hello world". If this not help type in terminal:

sudo apt-get install php-mysql

And restart your nginx server with:

sudo killall nginx && /usr/local/nginx/sbin/nginx