/etc/apt/sources.list.d/ mssql-release.list"; 3. Install "pdo_sqlsrv" through the install command."/> /etc/apt/sources.list.d/ mssql-release.list"; 3. Install "pdo_sqlsrv" through the install command.">

Home  >  Article  >  Backend Development  >  How to install php mssql on ubuntu

How to install php mssql on ubuntu

藏色散人
藏色散人Original
2023-01-28 09:25:431960browse

How to install php mssql on ubuntu: 1. Enter the terminal command window; 2. Execute "curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt /sources.list.d/mssql-release.list"; 3. Install "pdo_sqlsrv" through the install command.

How to install php mssql on ubuntu

The operating environment of this tutorial: ubuntu 16.04 system, sqlsrv version 5.6.1, DELL G3 computer

How to install php mssql on ubuntu ?

ubuntu installation php-mssql

#1

sudo su 
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -

#Download appropriate package for the OS version
#Choose only ONE of the following, corresponding to your OS version

#Ubuntu 14.04
curl https://packages.microsoft.com/config/ubuntu/14.04/prod.list > /etc/apt/sources.list.d/mssql-release.list

#Ubuntu 16.04
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list

#Ubuntu 18.04
curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list > /etc/apt/sources.list.d/mssql-release.list

#Ubuntu 18.10
curl https://packages.microsoft.com/config/ubuntu/18.10/prod.list > /etc/apt/sources.list.d/mssql-release.list

#Ubuntu 19.04
curl https://packages.microsoft.com/config/ubuntu/19.04/prod.list > /etc/apt/sources.list.d/mssql-release.list

exit
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install msodbcsql17
# optional: for bcp and sqlcmd
sudo ACCEPT_EULA=Y apt-get install mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
# optional: for unixODBC development headers
sudo apt-get install unixodbc-dev

#2

sudo pecl install sqlsrv pdo_sqlsrv
##如果网速慢,则下载下来
sudo pecl install sqlsrv-5.6.1.tgz
sudo pecl install pdo_sqlsrv-5.6.1.tgz
sudo echo "extension= pdo_sqlsrv.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
sudo echo "extension= sqlsrv.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`

Recommended study: "PHP video tutorial

The above is the detailed content of How to install php mssql on ubuntu. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn