Monday, September 30, 2013

Linux: Connecting Sybase with PHP.

When you come to Linux and configuration php with sybase, it is not as easy as windows. I struggled a lot while doing this for first time on Linux. There are many helps already available to do this task on Internet. I am narrating my step which may help you and me as well for future reference.

  1. Install Apache with PHP.
  2. Install php5-sybase.
  3. Download full Sybase installer and install Sybase Client in linux machine. If you are installing it as root then the installation path may be /opt/sybase in most of the cases.
  4. Create an "interface" file to connect with your Sybase database in /opt/sybase location. The interface file should look like following



    Servername
        query tcp ether Servername Port
        master tcp ether Servername Port

  5. check the permission of the "interface" file. It should be readable by all the Linux user. To set the permission you may use following command


    #chmod 644 /opt/sybase/interface


  6. You may check the Sybase connection by "isql" or "isql64" command.
  7. Now you may connect to sybase database with php. Following is simple example.
< ?php

putenv('SYBASE=/opt/sybase');

$con = sybase_connect(, , ;
$db = sybase_select_db(,$con) ;

 

?>
Following link also helped me a lot.


http://php.net/manual/en/ref.sybase.php