connecting to windows sql server from linux server
1.install freetds
To manually install `freetds-0.63.tar.gz`, follow these steps:
1. Extract the Archive
Navigate to the directory containing `freetds-0.63.tar.gz` and extract it:
bash
cd /path/to/directory
tar -xzf freetds-0.63.tar.gz
cd freetds-0.63
2. Configure the Installation
Configure FreeTDS with a prefix specifying the installation directory (e.g., `/usr/local/freetds`). This directory is where PHP will expect FreeTDS to be installed:
bash
./configure --prefix=/usr/local/freetds
If there are specific options or database configurations you need, add them during this step (for example, to enable certain database support).
3. Compile and Install FreeTDS
Run the following commands to compile and install FreeTDS:
bash
make
make install
4. Verify the Installation
Ensure FreeTDS is installed in the specified directory:
bash
ls /usr/local/freetds
[root@server-157-173-195-211 freetds-0.63]# ls /usr/local/freetds
bin etc include lib man share
sudo yum install freetds-devel unixODBC unixODBC-devel
run above cmd else will encounter error
configure: error: Don't know how to define struct flock on this system, set --enable-opcache=no
5. Rebuild PHP with FreeTDS Support
Now that FreeTDS is installed, you can attempt to rebuild PHP.
cd /usr/local/directadmin/custombuild
./build used_configs | grep configure.php
PHP (default) configuration file: /usr/local/directadmin/custombuild/configure/php/configure.php56
phpMyAdmin configuration file: /usr/local/directadmin/custombuild/configure/phpmyadmin/config.inc.php
/usr/local/directadmin/custombuild/configure/php
check above location for custom PHP config with PHP versions
--enable-intl \
--with-mssql=/usr/local/freetds
Check if MS Sql is intalled.
php -m|grep mssql mssql
sudo apt-get install unixodbc unixodbc-dev
yum install unixODBC-devel
cd /usr/local/directadmin/scripts/custom
wget https://raw.githubusercontent.com/poralix/directadmin-utils/master/php/php-extension.sh -O php-extension.sh
chmod 750 php-extension.sh
./php-extension.sh install sqlsrv
./php-extension.sh install pdo_sqlsrv
root@server-192-227-112-104:/usr/local/directadmin/scripts/custom# php -m | grep sqlsrvpdo_sqlsrvsqlsrv
vi /usr/local/freetds/etc/freetds.conf
[myserver]
host = 115.112.240.105
# host = ntmachine.domain.com
port = 1433
tds version = 7.0
[myserver3]
host = 192.227.108.64
port = 1433
tds version = 7.0
[myserver2]
host = 192.227.65.65
port = 1433
tds version = 7.0
[myserver1]
host = 154.27.75.96
port = 1433
tds version = 7.0
'host' => 'localhost',
'user' => 'rcautomat_in',
'password' => 'automation',
'database' => 'rcautomat_in',
'port' => 3306,
Comments
Post a Comment