On October 19, 2021, we have enabled single-sign-on for our Plesk Support Center to provide a seamless login/account experience. This implies that you’ll be able to use a single account across any of our web-facing properties.
If you had already registered your account at MyPlesk.com/Plesk360/Platform360 please use one for login. Otherwise please re-register it using the same email address as your existing Zendesk login (support account). It’s essential that you use the same email address on our support center to ensure that your tickets stay attached to the same account.

 How to install the sqlsrv extension for PHP 7.x in Plesk?

Follow

Comments

24 comments

  • Avatar
    Daniel

    Note in case someone stumbles across this article: I had to run the reread command for them to show up: https://www.danhendricks.com/2017/11/installing-microsoft-sql-server-php-extensions-plesk-onyx/

    1
    Comment actions Permalink
  • Avatar
    Bulat Tsydenov

    @Daniel, Thank you for your input! You are right, that command is necessary indeed. The article has been modified accordingly.

    1
    Comment actions Permalink
  • Avatar
    Noam Harel

    Hi,

    can you make the same proccess for CENTOS?

    i followed this:  https://www.danhendricks.com/2017/11/installing-microsoft-sql-server-php-extensions-plesk-onyx/

    and got some errors

     

    Noam

    0
    Comment actions Permalink
  • Avatar
    Bulat Tsydenov

    @Noam, Hi!

    The article was updated with the corresponding steps for CentOS 7.

    1
    Comment actions Permalink
  • Avatar
    Federica Della Monica (Edited )


    Good morning,

    I've installed sqlsrv extension for php 7.0 but I still have PDO Exception driver not found.

    0
    Comment actions Permalink
  • Avatar
    Ivan Postnikov

    @Federica Della Monica

    Hi!

    Make sure pdo_mysql is also installed and enabled.
    In case you will have difficulties, feel free to contact Plesk Support.

    0
    Comment actions Permalink
  • Avatar
    Federica Della Monica

    Hi!

    pdo_mysql is installed and enabled. 

    See image below

    0
    Comment actions Permalink
  • Avatar
    Ivan Postnikov

    @Federica Della Monica

    Hi!
    Due to issue complexity, I would suggest contacting Plesk Technical Support for deeper investigation.

    0
    Comment actions Permalink
  • Avatar
    Linus (Edited )

    Works also great with PHP 7.3 on Ubuntu / Debian:

    2. Install necessary packages:

    apt-get install apt-transport-https gcc g++ unixodbc unixodbc-dev plesk-php73-dev

     

    4. Add the pdo_sqlsrv and sqlsrv modules:

    # /opt/plesk/php/7.3/bin/pecl install pdo_sqlsrv
    # echo "extension=pdo_sqlsrv.so" > /opt/plesk/php/7.3/etc/php.d/pdo_sqlsrv.ini 
    # /opt/plesk/php/7.3/bin/pecl install sqlsrv 
    # echo "extension=sqlsrv.so" > /opt/plesk/php/7.3/etc/php.d/sqlsrv.ini

     

    6. Make sure that the required modules are enabled:

    # /opt/plesk/php/7.3/bin/php -m | grep sqlsrv

    pdo_sqlsrv 
    sqlsrv

     

     

    Hint for Debian 9:

    In Step 3 just adapt the repo url:

    # curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
    # curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list 
    # apt-get update 
    # ACCEPT_EULA=Y apt-get install msodbcsql

     

    0
    Comment actions Permalink
  • Avatar
    Alexandr Redikultsev

    Hi @Linus!

    Thanks so much for the input!

    1
    Comment actions Permalink
  • Avatar
    Peter Shaw (Edited )

    Trying this on Ubuntu18.04, Plesk Onyx, PHP7.2.

    Have modified the CURL URL in #3 to reflect Ubuntu18.04

    Struggling with the pecl install commands in #4 which fail with

    running: make
    sh: 1: make: not found
    ERROR: `make' failed

    After adding the Make package the install completed successfully. Is the expectation that Make is available in a default Plesk Onyx install?

    0
    Comment actions Permalink
  • Avatar
    Ivan Postnikov

    Hello @Peter,

    Plesk is not in charge of this package installation, this depends on the used OS.

    Thank you for sharing your user experience, it may be helpful for other Pleskians.

     

    0
    Comment actions Permalink
  • Avatar
    Naufal Fauzi

    Hello..
    how to install the sqlsrv extension for php 5.6 with ubuntu 16

    0
    Comment actions Permalink
  • Avatar
    Anton Maslov (Edited )

    Hello, sqlsrv no longer supports PHP 5.x. Microsoft support who provides sqlsrv decided to drop it, so it is not possible currently to install it for PHP 5.x

    0
    Comment actions Permalink
  • Avatar
    besi

    i do this answer on my plesk latest 

    but now when i want to create a database i got this error:

    Error: SQLSTATE[HY000]: General error: 1449 The user specified as a definer ('root'@'localhost') does not exist
     
    what can i do?
    0
    Comment actions Permalink
  • Avatar
    Anton Maslov

    You seems like specific incorrect username and password for the database in PHP code. Plesk don't user 'root' user for the database.

    0
    Comment actions Permalink
  • Avatar
    Sonny Spaan

    Can someone explain to me why CentOS6 is not supported (anymore) or if there is an option to install it on CentOS6 ? 

    0
    Comment actions Permalink
  • Avatar
    Ivan Postnikov

    Hello Sonny Spaan

    Only OS for which the solution was tested are listed in this article.

    For CentOS 6 CentOS 7 solution also has to work. However, the recommendation is to try a solution on the test clone on your production environment first to avoid downtimes.

    In case of issues, you may submit a support request.

    0
    Comment actions Permalink
  • Avatar
    Akatsouros

    this is not working

    can somebody please help???  Why i can't even pay for support to do it? can somebody help?

     

    those instructions don't work (debian).

     

    thank you

    0
    Comment actions Permalink
  • Avatar
    Iuri Carvalho

    Hi Peter Shaw, I don't know if you've already solve this.

    You need to install 'make' package at your server:

    apt install make

    0
    Comment actions Permalink
  • Avatar
    Anton Maslov

    Akatsouros you may create a request to our Professional Services Team to implement this for you on paid basis: https://www.plesk.com/professional-services/administrative-services

    0
    Comment actions Permalink
  • Avatar
    Mehmet Erdoğan

    #/opt/plesk/php/7.2/bin/pecl install pdo_sqlsrv

    when run 

    ERROR 

    PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_sqlsrv.so' (tried: /opt/plesk/php/7.2/lib64/php/modules/pdo_sqlsrv.so (/opt/plesk/php/7.2/lib64/php/modules/pdo_sqlsrv.so: cannot open shared object file: No such file or directory), /opt/plesk/php/7.2/lib64/php/modules/pdo_sqlsrv.so.so (/opt/plesk/php/7.2/lib64/php/modules/pdo_sqlsrv.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
    PHP Warning: PHP Startup: Unable to load dynamic library 'sqlsrv.so' (tried: /opt/plesk/php/7.2/lib64/php/modules/sqlsrv.so (/opt/plesk/php/7.2/lib64/php/modules/sqlsrv.so: cannot open shared object file: No such file or directory), /opt/plesk/php/7.2/lib64/php/modules/sqlsrv.so.so (/opt/plesk/php/7.2/lib64/php/modules/sqlsrv.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

    Notice: Undefined variable: errstr in PEAR/Proxy.php on line 185
    PHP Notice: Undefined variable: errstr in /opt/plesk/php/7.2/share/pear/PEAR/Proxy.php on line 185

    Notice: Undefined variable: errno in PEAR/Proxy.php on line 185
    PHP Notice: Undefined variable: errno in /opt/plesk/php/7.2/share/pear/PEAR/Proxy.php on line 185
    No releases available for package "pecl.php.net/pdo_sqlsrv"
    install failed
    [root@host-185-19-93-51 ~]# /opt/plesk/php/7.2/bin/pecl install pdo_sqlsrv
    PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_sqlsrv.so' (tried: /opt/plesk/php/7.2/lib64/php/modules/pdo_sqlsrv.so (/opt/plesk/php/7.2/lib64/php/modules/pdo_sqlsrv.so: cannot open shared object file: No such file or directory), /opt/plesk/php/7.2/lib64/php/modules/pdo_sqlsrv.so.so (/opt/plesk/php/7.2/lib64/php/modules/pdo_sqlsrv.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
    PHP Warning: PHP Startup: Unable to load dynamic library 'sqlsrv.so' (tried: /opt/plesk/php/7.2/lib64/php/modules/sqlsrv.so (/opt/plesk/php/7.2/lib64/php/modules/sqlsrv.so: cannot open shared object file: No such file or directory), /opt/plesk/php/7.2/lib64/php/modules/sqlsrv.so.so (/opt/plesk/php/7.2/lib64/php/modules/sqlsrv.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

    Notice: Undefined variable: errstr in PEAR/Proxy.php on line 185
    PHP Notice: Undefined variable: errstr in /opt/plesk/php/7.2/share/pear/PEAR/Proxy.php on line 185

    Notice: Undefined variable: errno in PEAR/Proxy.php on line 185
    PHP Notice: Undefined variable: errno in /opt/plesk/php/7.2/share/pear/PEAR/Proxy.php on line 185
    No releases available for package "pecl.php.net/pdo_sqlsrv"
    install failed




    0
    Comment actions Permalink
  • Avatar
    Ivan Postnikov

    Hello Mehmet Erdoğan

    It looks like the library was incorrectly installed or some step was missed.

    Try these commands to add the missing configuration:

    echo "extension = pdo_sqlsrv.so"> /opt/plesk/php/7.2/etc/php.d/pdo_sqlsrv.ini
    echo "extension = sqlsrv.so"> /opt/plesk/php/7.2/etc/php.d/sqlsrv.ini

    If this won't help rollback the proposed changes and submit support request.

    0
    Comment actions Permalink
  • Avatar
    Alex Gough (Edited )

    For those wanting to use this on PHP 7.4 on Centos 7, I ran the following:

    curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/mssql-release.repo
    yum remove unixODBC-utf16 unixODBC-utf16-devel
    ACCEPT_EULA=Y yum install msodbcsql
    yum install unixODBC-devel gcc-c++ gcc autoconf automake plesk-php74-devel
    /opt/plesk/php/7.4/bin/pecl install pdo_sqlsrv
    echo "extension=pdo_sqlsrv.so" > /opt/plesk/php/7.4/etc/php.d/pdo_sqlsrv.ini
    /opt/plesk/php/7.4/bin/pecl install sqlsrv
    echo "extension=sqlsrv.so" > /opt/plesk/php/7.4/etc/php.d/sqlsrv.ini

    and tested it with:

    /opt/plesk/php/7.4/bin/php -m | grep sqlsrv
    0
    Comment actions Permalink

Please sign in to leave a comment.

Have more questions? Submit a request