I'm using PHP Laravel 7.4 on Ubuntu 20.04.and trying to get data from SQL server located in windows server on another cloud.
this method was tested on my PC (Windows) and it successfully got the data from the windows server(mentioned above), But on my ubuntu server I follow the documents ubuntu 20.04 PHP 7.4 https://learn.microsoft.com/en-us/sql/connect/php/installation-tutorial-linux-mac?view=sql-server-ver15
I got this error:
SQLSTATE[08001]: [Microsoft][ODBC Driver 17 for SQL Server]TCP Provider: Error code 0x2746 (SQL: myquery) {"userId":94,"exception":"[object] (Illuminate\Database\QueryException(code: 08001): SQLSTATE[08001]: [Microsoft][ODBC Driver 17 for SQL Server]TCP Provider: Error code 0x2746 (SQL: myquery) at /var/www/web-api/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669)
I checked the logs in Microsoft SQL Server Management Studio and I notice this message appears every time I make a request from Ubuntu
"An TLS 1.2 connection request was received from a remote client application, but none of the cipher suites supported by the client application are supported by the server. The SSL connection request has failed."
Try these steps:
Install sqsrv & pdo_sqlsrv extension & restart apache
Update & comment the mentioned line bellow in config/database.php sqlsrv array
'port' => env('DB_PORT', '1433'),
Final value of sqlsrv driver will be like this:
'sqlsrv' => [
'driver' => 'sqlsrv',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', 'localhost'),
// 'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
],
Hit these 2 command in command line of the project directory
composer dump-autoload
php artisan config:clear
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With