How to use FreeTDS with MAMP on Mac OS?

11

I need to use the PHP mssql methods and I always did this using FreeTDS in the native Apache MAC OS >.

What happens is that shortly after upgrading to OS X 10.9 (Mavericks) I started to use the MAMP package and not the native Apache because of personal issues and the ease of customizing Apache / PHP.

I know I need to enable the extension in php.ini (in my case it is in /Applications/MAMP/bin/php/php5.5.3/conf/php.ini ) but I'm not sure if I need to compile PHP again.

Would anyone have any idea how best to proceed?

    
asked by anonymous 17.12.2013 / 14:17

1 answer

4

Installing Free TDS

  • Create the directory / usr / local / freetds
  • Download freetds: ftp://ftp.freetds.org/pub/freetds/ current / freetds-current.tgz
  • Open a terminal window and unzip the file you just downloaded
  • In the terminal go to the folder created after unpacking

    cd ~ / Downloads / freetds-current

  • Run the following command

  • After completing, type "make" and press enter

  • Type "sudo make install" and enter again
  • Type your password and wait for it to complete.

Compiling PHP to get mssql.so

  • Download the version you are using ( link )
  • In the terminal enter the decompressed directory of php that you just downloaded.
  • Type "./configure" and press enter.
  • Then "make" and enter
  • Go to the mssql extension folder

    cd ~ / Downloads / php- / ext / mssql

  • Type "phpize" and enter

  • Type the command below after this

    ./configure --with-mssql = / usr / local / freetds

  • Open a Text Editor and edit the file:

    ~ / Downloads / php- / ext / mssql / php_mssql.c

Change line 181 by changing PHP_FE_END to {NULL, NULL, NULL}

// Antes
PHP_FE(mssql_guid_string, arginfo_mssql_guid_string)
    PHP_FE_END
};

// Depois
PHP_FE(mssql_guid_string, arginfo_mssql_guid_string)
    {NULL, NULL, NULL}
};
  • Go back to the terminal - check if it is still in the ~ / Downloads / php- / ext / mssql
  • Enter "make" and enter
  • Open the finder and go to the mssql module folder (~ / Downloads / php- / ext / mssql / modules /)
  • Copy mssql.so to the MAMP extension folder. It should be something like "Applications / MAMP / bin / php / lib / php / extensions / no-debug-non-zts-20090626 /"
  • Edit your php.ini /Applications/MAMP/bin/php/php-/conf/php.ini
  • Search for "extension="
  • Paste "extension = mssql.so" just below the other extension lines and restart MAMP

Ready;)

    
01.02.2014 / 15:26