Archive for the ‘Linux’ Category

How To Install mssql extension for PHP in cPanel CentOS / RHEL

By compiling PHP with mssql extension support one can have capability to connect to MS SQL server from a PHPLinux environment.

For enabling mssql support in PHP we need FreeTDS installed and configured which is a set of Unix/Linux libraries that implement the TDS protocol.

This post explains the steps for doing this, lets get started.

First we will need to download and install FreeTDS, you can find more information and download link at http://www.freetds.org URL. Note the exact installation steps below :

cd /usr/local/src
wget http://ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz
tar -xzvf freetds-stable.tgz
cd freetds-*/
./configure –prefix=/usr/local/freetds –with-tdsver=8.0 –enable-msdblib –enable-dbmfix –with-gnu-ld
make
make install

Once the installation is complete we will add the related FreeTDS libraries and binaries installation path to the dynamic linker binding config files at /etc/ld.so.conf , we will add below two paths :

/usr/local/freetds/lib
/usr/local/freetds/bin

Edit the config file using vi or editor of your choice to add above paths and then use ldconfig command to build dynamic links for the shared libraries :

vi /etc/ld.so.conf
ldconfig -v

You can check connectivity to external MS SQL server using below command :

tsql -S [servername] -p [port]  -U [username] -P [password]

Standard MS SQL port is 1443 which you can use above. Also if you want to have VPS/Server level connectivity configuration for MS SQL you can configure the/usr/local/freetds/etc/freetds.conf file for that.

Once done , we will proceed with rebuilding PHP using the /scripts/easyapache script on the cPanel servesr/vps. For a none-cpanel installation same config parameter can be used during configure step for compiling PHP.

We need to add the configure parameter –with-mssql=/usr/local/freetds in file /var/cpanel/easy/apache/rawopts/all_php5 . Once done, save the file and proceed with easyapache script to rebuild PHP.

/scripts/easyapache

If you are on a 64bit platform , you may recieve this error :

configure: error: Could not find /usr/local/freetds/lib64/libsybdb.a|so

You will need to create a symlink from the original location of the libaray, the path can vary depending on the platform. In my case I noticed the file was located at normal lib directory under freetds i.e. it was located at /usr/local/freetds/lib , so I simply created a symlink named lib64 to the oringal directory lib as follows :

cd /usr/local/freetds
ln -s lib lib64
ldconfig -v

Also added the path /usr/local/freetds/lib64 to the ld.so.conf file and build the dynamic linking as done above.

Once easyapache script completes successfully, you will find mssql support enabled in PHP. You can verify that using below command :

php -i | grep mssql

Now we will create/install a copy of mssql.so libaray which we can then enable in the php.ini file. On cPanel system this can be achieved by following below steps :

 

cd /home/cpeasyapache/src/php-5.2.17/ext/mssql/
phpize
./configure
make
make install

This will install a the mssql.so library at the extension_dir path mentioned in php.ini file located at /usr/local/lib/. To enable the extension add below link in php.ini file :

extension=mssql.so

Save the file and restart Apache.

Install and Configure DNS on Linux Server

You would need to configure DNS server on the server, like bind:
yum install bind bind-utils

backup your bind config
mv /etc/named.conf /etc/named.conf_backup

create and edit new config

pico /etc/named.conf

and paste this config to the file:

###begin
options {
recursion no;
allow-query { any; };
allow-query-cache { any; }
;
};
zone “yourdomain.com” {
type master;
file “/var/named/yourdomain.com”;
};
###end

than you should create your domain zone file:

pico /var/named/yourdomain.com

#dns zone begin
$TTL 3600
yourdomain.com. IN SOA SKRS969.local. root.SKRS969.local. (2015021702 10800 3600 604800 86400)
yourdomain.com. IN NS ns1.yourdomain.com.
yourdomain.com. IN NS ns2.yourdomain.com.
yourdomain.com. IN MX 10 mail.yourdomain.com.
yourdomain.com. IN A 12.34.56.78
ns1 IN A 1.2.3.4
ns2 IN A 1.2.3.4
www IN CNAME yourdomain.com.
mail IN A 5.6.7.8
#dns zone end

where 1.2.3.4 – this server IP (dns server with bind)
5.6.7.8 – your MX mail server IP
12.34.56.78 – your webserver IP

or if dns, web and mail server are located on the same server – put one IP

restart DNS bind service:

/etc/init.d/named restart

Than you should registered nameservers for your domain in your domain registration site (ns1.yourdomain.com 1.2.3.4 , ns2.yourdomain.com 1.2.3.4) and than change NS for your domain to ns1.yourdomain.com and ns2.yourdomain.com.

Before changing NS on registrator site you can check is your bind work properly:

#dig @localhost yourdomain.com

you should get something like:

;; ANSWER SECTION:
yourdomain.com. 3600 IN A 1.2.3.4

;; AUTHORITY SECTION:
yourdomain.com. 3600 IN NS ns1.yourdomain.com.
yourdomain.com. 3600 IN NS ns2.yourdomain.com.

Network Interface keeps going down on CentOS

You will usually find issue with CentOS with the NIC going down after a reboot in order to fix the issue

add these lines to the kernel line in grub:

pci_aspm=off pcie_aspm=off

(adsbygoogle = window.adsbygoogle || []).push({}); //--> Feedjit Flag Counter