I'm trying to enable the sqlsrv driver for php8.1 on Ubuntu 20.0. It doesn't show the extension in phpinfo()
.
When trying to check the sqlsrv module using the command php -m
, the output is as follows:
I followed the following official documentation:
extension=pdo_sqlsrv.so
, extension=sqlsrv.so
)I'm not sure what's going wrong, any suggestions would be appreciated.
The output of phpinfo() for php7.4:
The output of phpinfo() for php8.1:
The thing is like this:
What am I missing here?
P粉8232680062023-11-02 00:55:33
I was able to solve this problem by adding the following commands.
pecl install sqlsrv pdo_sqlsrv printf "; priority=20\nextension=sqlsrv.so\n" > /etc/php/8.1/mods-available/sqlsrv.ini printf "; priority=30\nextension=pdo_sqlsrv.so\n" > /etc/php/8.1/mods-available/pdo_sqlsrv.ini phpenmod -v 8.1 sqlsrv pdo_sqlsrv
You need to restart apache2 afterward
P粉1933074652023-11-02 00:34:32
You can try this:
1. switch to php8.1 2. sudo pecl uninstall -r sqlsrv 3. sudo pecl uninstall -r pdo_sqlsrv 4. sudo pecl -d php_suffix=7.2 install sqlsrv 5. sudo pecl -d php_suffix=7.2 install pdo_sqlsrv 6. sudo service apache2 restart
Please note that -r, --register-only
will not delete the file, but will only register the package as not installed.
Check out this resource for more information. https://github.com/microsoft/msphpsql/issues/1145#issuecomment- 649682231