Php install pdo dblib

jschroed91 / README.md

Note that this was written Jan 9th, 2019, and I personally have not tested this since then. It’s possible it will still work for your machine, but I can’t guarantee it.

Based on some comments, it looks like someone may have had success with it Dec 22, 2020 too.

  • This was tested with MAMP 5, but probably works with other versions
  • This was tested with php 7.1.20 that was installed via MAMP interface
  • You will need to use Homebrew for part of this — no, you won’t need to use homebrew for your php or apache or anything. you’ll still use MAMP. It’s just used to install some things we’ll need to compile pdo_dblib

Someone says you should ensure you have the latest xcode (or install it) with the command line tools.

I didn’t check or run this, but I’ve had it installed somewhat recently. May as well run it

Install deps with homebrew

You’ll need to install these two things via homebrew:

$ brew install autoconf $ brew install freetds

I don’t think these 2 pecl commands are required probably. but I did run them during this process while messing around with things, and everything ended up working for me. so. let’s run them just to be safe.

First command tells pecl where your MAMP’s php.ini file is, and the second command installs PDO via pecl. because why not.

$ pecl config-set php_ini /Applications/MAMP/bin/php/php7.1.20/conf/php.ini $ pecl install pdo

Is the php-cli using your MAMP php version too?

Читайте также:  Python входные параметры скрипта

If not, alls you gotta do is add this towards the beginning of your $PATH:

I use fish shell, so for me I just ran:

$ echo 'set -g fish_user_paths "/Applications/MAMP/bin/php/php7.1.20/bin" $fish_user_paths' >> ~/.config/fish/config.fish

For bash, you’d add something similar to your ~/.profile or ~/.bash_profile file:

export PATH="/Applications/MAMP/bin/php/php7.1.20/bin:$PATH"

Build the pdo-dblib library from php source

Download php source for your MAMP’s php version (7.1.20 in this example)

Download php source from a mirror here (change the php version if yours is different):

$ cd ~/Downloads $ tar -zxf php-7.1.20.tar.gz

Compile the pdo_dblib and copy to MAMP

$ cd php-7.1.20/ext/pdo_dblib $ phpize ### compile using MAMP's php config/version $ ./configure --with-php-config=/Applications/MAMP/bin/php/php7.1.20/bin/php-config --with-pdo-dblib=/usr/local/ $ make ### hooray! if you got here without an error, it worked. Now, copy the compiled extension over to MAMP's extension dir. $ cp modules/pdo_dblib.so /Applications/MAMP/bin/php/php7.1.20/lib/php/extensions/no-debug-non-zts-20160303/

Add the extension to your MAMP php configuration files

Add this to your MAMP’s web php.ini file. You will add it within the «Dynamic Modules» section of the file. You can open the file and edit it right through MAMP’s GUI.

; add this line to MAMP's php.ini file extension=pdo_dblib.so

Save and close — it’ll ask you if you want to restart, say yes.

Here’s a gif that may or may not work:

Then, add it to your cli too:

$ nano /Applications/MAMP/bin/php/php7.1.20/conf/php.ini

I came across some note that told me I should it OUTSITE the «Dynamic Extensions» block otherwise it may get overwritten. I have no clue how accurate that is, but I heed their warning.

So I put mine literally right above the Dynamic Extensions block like:

extension=pdo_dblib.so ;;;;;;;;;;;;;;;;;;;;;; ; Dynamic Extensions ; ;;;;;;;;;;;;;;;;;;;;;;

Confirm the extension is loaded!

Confirm it’s loaded for your php cli on command line

You should see a line output with «pdo_dblib»! If you don’t see it, then you might not have the MAMP cli set up on your $PATH in your shell.

Confirm it’s loaded on your MAMP web server

Thanks for this, you forgot to include the ‘make’ command after you run configure.

### compile using MAMP's php config/version $ ./configure --with-php-config=/Applications/MAMP/bin/php/php7.1.20/bin/php-config --with-pdo-dblib=/usr/local/ $ make 

@jonojamesmac Saw your note just now for some reason, I updated the gist to include the make command. Thank you!

This doesn’t work with MAMP Pro v6.3.7 with PHP 5.6.40 installed on macOS Catalina (fresh install) because phpize uses the Mac’s /usr/bin/phpize and a bunch of other /usr files that are probably newer than yours. I just get a bunch of warnings and errors with the ./configure command while in the folder and the make command, and no .so file is generated.

I’m honestly scratching my head as how you got any of this to work, unless your non-MAMP non-PHP 5 files that were run within the commands (like the native pre-installed Mac PHP 7.x and related files) were close enough to PHP 7.1 requirements that it just worked, and that’s the only way it will work.

I’m not sure that I need to overwrite all of those /usr file references to older versions (which I don’t want to do), and brew just simply doesn’t support a lot of libraries that are deprecated. so I could be in a labyrinth of wild goose chases, which it already feels like I am, and I’m afraid I’ll screw up my system so bad with old software that I’ll just create new problems. Not sure what to do here.

@givihuda Bummer! Sorry to hear that it’s not working for you now. It looks like someone was able to use this Dec 22, 2020 but I can’t speak to their current system / how up to date they are.

This was originally written on Jan. 9th, 2019 — I have not tested it since then, and the only update I’ve made was to include the make command added in the comment above (I personally didn’t have to run the make command if I recall correctly, or I did but didn’t include it originally and forgot that I had to run it).

If you end up resolving this issue using another method it would be very appreciated if you circled back here and posted the solution so that I can leave a comment at the top of this gist with that information.

@jschroed91 Did you run the commands with native PHP 7.x installed? The difference in your and my outcomes seems to be what you had natively on the computer at the time, at least some of them. That’s a typical problem with people trying to get old software to work; one person’s dependencies end up having different results when run because of newer software at the time.

I haven’t found a solution to this other than running the PHP framework’s built-in php server command (bin/console server:start in my case, with Symfony), and I had to uninstall brew PHP 5.6 due to composer getting stuck on it no matter what I did with brew or .zshrc or PATH or aliases or anything. I’m still scratching my head at this, though I’m assuming compiling old PHP 5.6 library dependencies, and maybe even re-compiling PHP 5.6 right along with it, would solve it, but that seems like a bigger gamble.

My biggest concern with getting old software to work on newer computers is ending up downgrading software on the computer that other things use.

Источник

Installing PDO_DBLIB for PHP [closed]

Questions involving web hosting control panels are off-topic at Server Fault because they customize their systems such that normal administration tools and methods no longer apply, and thus require support from the vendor or the web hosting industry. See Where can I ask questions about web hosting control panels?

I’m trying to get PDO’s to work with SQL Server and I’m completely lost. I found this : http://www.php.net/manual/en/ref.pdo-dblib.php http://pecl.php.net/package/PDO_DBLIB and told to try this:

sudo apt-get install php5-mssql 

I downloaded the pecl, but I have no idea what it is or where it goes. The manual didn’t help and even if the sudo command did work, I have no clue where to type it. I will fully admit, I am completely ignorant of all of this and don’t even know where to start at this point. My server is hosted by some hosting company, it’s a LAMP, I can log into cPanel. That’s all I know.

2 Answers 2

If all you have is cPanel access to your server, then you will have to contact your hosting company’s technical support to help you set this up.
You can use the php5 mssql extension to talk to Sql Server via a linux machine, but you have to install http://www.freetds.org on the server first.

http://www.php.net/manual/en/mssql.setup.php gives a good detailed overview of what is required with installing the mssql extension once freetds is installed. But this requires shell access to the server and typically either sudo or root access.

I have successfully installed the PDO_DBLIB on my local and hosted servers.

The local server was easy as I had complete root access. To install PDO_DBLIB, all I did was run this command on the Ubuntu LAMP server I set up.

sudo apt-get install php5-sybase 

To install this on my hosted server was a slightly different matter. I had to call them and tell them what I wanted. After confusing a Level 1, I was escalated and they informed me that it would be a billable custom service. The server was running Cent OS (which I don’t really know that well) so I’m not sure what exactly was done, but they were able to complete my request without any major issues. The host was HostGator and it cost me around $35.

Side note/warning, PDO_DBLIB has a relatively serious but simple issue as of 5.4.9 that hasn’t been fixed quite yet, so I’d hold back to an older version for a little while.

Источник

How to install PDO_DBLIB module in Cpanel server

In this version, PHP 5 is the focus hence that specific file.

#echo “–with-mssql=/usr/local/freetds” >> /var/cpanel/easy/apache/rawopts/all_php5

*If you are using other Builds of Apache or PHP you may refer to the following for the correct file to edit instead of /var/cpanel/easy/apache/rawopts/all_php5 such as the case here.

* Apache 1.3.x – /var/cpanel/easy/apache/rawopts/Apache1
* Apache 2.0.x – /var/cpanel/easy/apache/rawopts/Apache2
* Apache 2.2.x – /var/cpanel/easy/apache/rawopts/Apache2_2
* All PHP 4.x versions – /var/cpanel/easy/apache/rawopts/all_php4
* All PHP 5.x versions – /var/cpanel/easy/apache/rawopts/all_php5
* Mod_suPHP – /var/cpanel/easy/apache/rawopts/all_suphp
* Specific PHP Version – /var/cpanel/easy/apache/rawopts/PHP-X.X.X

Step5: Touch the following files as these are what are checked for by PHP. The following error will result if they are not in place.

configure: error: Directory /usr/local/freetds is not a FreeTDS installation directory

Here are the files to create for PHP’s conditional check:

#touch /usr/local/freetds/lib/libtds.a
#touch /usr/local/freetds/include/tds.hp

Step6: Now run Easy Apache and make sure that Mysql, Mysql of the system, amd Mysqli are all selected.

#/scripts/easyapache

If running a 64bit OS and get an error about

configure: error: Could not find /usr/local/freetds/lib64/libsybdb.a|so
you’ll need to link a directory.

In this example it was an easy fix.

#cd /usr/local/freetds/
#ln -s /usr/local/freetds/lib lib64
#ll /usr/local/freetds/lib64/libsybdb.a
#ll /usr/local/freetds/lib64/libsybdb.so
#/scripts/easyapache

Steps to enable PDO_DBLIB module

If you are using PHP 5.2 or earlier then you can go to the PECL module installer and search for PDO (don’t just have it list all modules, they won’t all show up).

That will give you a list of PECL PDO modules, including PDO_DBLIB to install.

In that case run the command,

#pecl install PDO_DBLIB

Other wise you will get the error

pear/PDO_DBLIB requires PHP extension ‘pdo’ version >=1.0

If so, we need to install PDO_DBLIB manually. Please follow the below steps for manual installation.

#pecl download pdo_dblib

This will download a tar ball of the extension. Extract the tar ball.

#tar -xzvf PDO_DBLIB-*.tgz

That will uncompress the package in to a standalone file, package.xml and a folder containing the extension, in my case it was, PDO_DBLIB-X.X. Where X was the version number. # Open package.xml using your favourite command line editor. Find and remove the line,

Save the package.xml file, and move it in to the PDO_DBLIB directory.

#mv package.xml ./PDO_DBLIB-X.X

Navigate to the PDO_DBLIB directory, then install the package from the directory. You may need root access for this step.

#cd ./PDO_DBLIB-XX

#./configure —with-pdo-dblib=/usr/local/freetds

#make install

Then ‘pdo_dblib.so’ will be installed in the location /usr/local/lib/php/extensions/no-debug-non-zts-20090626/

Open php.ini file and add the line following line

extension=pdo_dblib.so

#/etc/init.d/httpd restart

Check the php info page to ensure the module

Leave a Reply Cancel reply

You must be logged in to post a comment.

Источник

Оцените статью