How do I use Freetds with MAMP on Mac OS?

Asked

Viewed 1,361 times

10

I need to use the methods mssql_ of PHP and have always done so using the Freetds in the native Apache of MAC OS.

What happens is that right after you upgrade to the OS X 10.9 (Mavericks) I started using the MAMP package and not native Apache for personal reasons and for the ease in customizing Apache/PHP.

I know I need to activate the extension on php.ini (in my case 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?

1 answer

4


Installing the Free TDS

  • Create the directory /usr/local/freetds

  • Download the freetds download: ftp://ftp.freetds.org/pub/freetds/current/freetds-current.tgz

  • Open a terminal window and unzip the file you just downloaded

  • In the terminal to the paste created after unpacking

    cd ~/Downloads/freetds-current
    
  • Execute the following command then

    ./configure --prefix=/usr/local/freetds --sysconfdir=/usr/local/freetds/conf/freetds --disable-libiconv --disable-odbc
    
  • After finishing type "make" and press enter

  • Typo sudo make install and enter again

  • Enter your password and wait to complete.

Compiling PHP to get mssql.so

  • Download the version you are using (http://php.net/downloads.php)

  • In the terminal enter the unzipped php directory you just downloaded.

  • Typo ./configure and press enter.

  • Then "make" and enter

  • Go to the mssql extension folder

    cd ~/Downloads/php-<versão>/ext/mssql
    
  • Typo phpize and enter

  • Enter the command below after this

    ./configure --with-mssql=/usr/local/freetds
    
  • Open a Text Editor and edit the file:

    ~/Downloads/php-<versão>/ext/mssql/php_mssql.c
    

Change line 181 by switching 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’s still in the folder ~/Downloads/php-<versao>/ext/mssql
  • Typo make and enter
  • Open the finder and go to the mssql module folder (~/Downloads/php-<versão>/ext/mssql/modules/)
  • Copy mssql.so to the MAMP extension folder. It must be something like Applications/MAMP/bin/php/php-<versão>/lib/php/extensions/no-debug-non-zts-20090626/
  • Edit php.ini /Applications/MAMP/bin/php/php-<versão>/conf/php.ini
  • Look for extension=
  • Cole extension=mssql.so just below the other extension lines and restart MAMP

Browser other questions tagged

You are not signed in. Login or sign up in order to post.