Installing PHP SQLSRV Extension - RunCloud Nginx
Introduction
The PHP SQLSRV extension provides a way to access data stored in Microsoft SQL Server databases from a PHP application. It supports all of the latest features of SQL Server, including the latest versions of SQL Server, and provides a fast, reliable, and easy-to-use API for accessing your data.
In this blog post, we'll go over the steps required to install the PHP SQLSRV extension on a RunCloud Nginx server. We'll be covering everything from downloading the extension to configuring it in your PHP environment. Whether you're a beginner or an experienced PHP developer, this guide will help you get up and running with the PHP SQLSRV extension quickly and easily.
Step1: Installing dependencies.
For this example, we are assuming our PHP version that require SQLSRV extension is PHP80, you can replace commands with your own version according to your requirement. Before jump into installation steps, first make sure below packages are installed on your server, you can just run the following commands.
apt-get install autoconf libpcre3-dev
apt install unixodbc-dev
"autoconf" is a tool for generating configure scripts for building, installing, and deploying software packages on various operating systems. It creates scripts that can automatically determine the installation environment and configure the software to run on that environment.
"libpcre3-dev" is the development library for PCRE (Perl Compatible Regular Expressions), a library for working with regular expressions. The "dev" suffix indicates that this package provides the headers and libraries necessary for development, allowing other software to be built against it.
"unixodbc-dev" is a development package for UnixODBC, which is a software library that provides a standard API for accessing databases on Unix-based systems. The "unixodbc-dev" package contains the headers and libraries necessary for developing applications that use UnixODBC. By using UnixODBC, developers can write database-independent applications that can work with different database management systems, making it easier to develop, deploy, and maintain database applications on Unix-based systems.
Step 2: Downloading extension.
Once the dependencies are installed, we can download the extension.
MODULE_NAME="sqlsrv"
MODULE_VERSION="5.10.1"
tar -zxvf $MODULE_NAME-$MODULE_VERSION.tgz
Step3: Install the extension.
We can now install the extension by running below commands. Make sure to replace PHP version with your required one.cd $MODULE_NAME-$MODULE_VERSION
make clean
/RunCloud/Packages/php80rc/bin/phpize --clean
/RunCloud/Packages/php80rc/bin/phpize
./configure
--with-php-config=/RunCloud/Packages/php80rc/bin/php-config
--with-libdir=lib64 CFLAGS='-O2 -fPIE -fstack-protector-strong -Wformat
-Werror=format-security -Wall -pedantic -fsigned-char
-fno-strict-aliasing'
make install
echo "extension=$MODULE_NAME.so" > /etc/php80rc/conf.d/$MODULE_NAME.ini
Step 4: Restart the service.
systemctl restart php80rc-fpm
Step 5: Verify the extension is installed correctly.
/RunCloud/Packages/php80rc/bin/php -m | grep sqlsrv
Comments
Post a Comment