Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Forum Archive > Main Support Categories > General Help
Register Reset Password Forum Help Forum Council Search Today's Posts Mark Forums Read

Hello, Unregistered You are browsing a READ only archive of the main support categories pre 4/21/2008. You will not be able to post or reply any threads in this section.

General Help
All your general support questions for Ubuntu, Kubuntu, Edubuntu and Xubuntu.

 
Thread Tools Display Modes
Old February 18th, 2007   #1
SirBob1701
5 Cups of Ubuntu
 
Join Date: Jan 2007
Beans: 20
PHP5 from apt-get and PDO

I was wondering if anyone knows how to get the PDO classes installed for PHP5 because it seems that they were not installed when I did an apt-get for php5. Will I have to manually compile it or is their a repository for this?
SirBob1701 is offline   Reply With Quote
Old February 18th, 2007   #2
Gibbs
Just Give Me the Beans!
 
Gibbs's Avatar
 
Join Date: Feb 2007
Location: North Devon
Beans: 79
Ubuntu 8.10 Intrepid Ibex
Re: PHP5 from apt-get and PDO

System > Administration > Synaptic Package Manager

Use the search feature and search for "php-db". It should be the first result.
Gibbs is offline   Reply With Quote
Old February 20th, 2007   #3
SirBob1701
5 Cups of Ubuntu
 
Join Date: Jan 2007
Beans: 20
Re: PHP5 from apt-get and PDO

what i see for php-db is PHP PEAR Database Abstraction Layer which I was told in freenode is not the pdo package.
SirBob1701 is offline   Reply With Quote
Old February 21st, 2007   #4
theh0g
Gee! These Aren't Roasted!
 
theh0g's Avatar
 
Join Date: Dec 2004
Location: Slovenia
Beans: 68
Send a message via MSN to theh0g
Re: PHP5 from apt-get and PDO

I had this problem just yesterday (and yes, php-db installation is...useless). I dunno EXACTLY what I did, but I've installed php5-dev, mysqlclient15-dev (or something) and then ran PECL INSTALL PDO and PECL INSTALL PDO_MYSQL. Seems to work, but it wont parse queries on execute (replacing ? with data from array) yet. Hope that helps.

EDIT: oh yeah, don't forget to add both extensions to php.ini (pdo.so and pdo_mysql.so)

Last edited by theh0g; February 21st, 2007 at 04:56 PM..
theh0g is offline   Reply With Quote
Old March 5th, 2007   #5
Roland Bouman
5 Cups of Ubuntu
 
Roland Bouman's Avatar
 
Join Date: Dec 2005
Beans: 18
Kubuntu 7.10 Gutsy Gibbon
Re: PHP5 from apt-get and PDO

Here's a more exact description to install pdo on top of the php5 packages provided by ubuntu (so this procedure assumes you already installed php and a webserver):

1) make sure you install the ubuntu package php-pear. I used synaptic for that but the command line should work too of course:

Code:
sudo apt-get install php-pear
Now you have to extra executables to work with php's own packaging system, pear and pecl

2) install pdo:

Code:
sudo pecl install pdo
This will check your build environment and actually install plain pdo. If everything goes well, it ends in something like:

Code:
Build process completed successfully
Installing '/var/tmp/pear-build-root/install-PDO-1.0.3//usr/lib/php5/20051025/pdo.so'
Installing '/var/tmp/pear-build-root/install-PDO-1.0.3//usr/include/php/ext/pdo/php_pdo.h'
Installing '/var/tmp/pear-build-root/install-PDO-1.0.3//usr/include/php/ext/pdo/php_pdo_driver.h'
install ok: channel://pecl.php.net/PDO-1.0.3
You should add "extension=pdo.so" to php.ini
3) install any pdo drivers.

Check the php documentation to find out your prerequisites. For example, to install pdo_mysql, I first installed the mysql php extension:

Code:
sudo apt-get install php5-mysql
(For some reason, this seemed to pull php5-mysqli along too)
After that, install the pdo_mysql package again using the php packaging system rather than the ubuntu packages:

Code:
sudo pecl install pdo_mysql
Again, you get an enormous listing which is output of the installation process:

Code:
Build process completed successfully
Installing '/var/tmp/pear-build-root/install-PDO_MYSQL-1.0.2//usr/lib/php5/20051025/pdo_mysql.so'
install ok: channel://pecl.php.net/PDO_MYSQL-1.0.2
You should add "extension=pdo_mysql.so" to php.ini
4) find and edit your php.ini to add the extensions in the configuration. I found my php.ini using the phpinfo() function (which outputs a webpage with the php environment). I used kedit but of course, any text editor will do:

Code:
sudo kedit /etc/php5/apache2/php.ini
5) add the line for the pdo extension and the specific drivers to the php.ini file, and save the file:

Code:
extension=pdo.so
extension=pdo_mysql.so
(I first searched php.ini for 'extension' and put those lines right beneath the example lines for adding an extension

6) Restart apache to let the changes take effect:

Code:
cd /etc/init.d
sudo apache2 -k restart
This worked for me.

Good luck, and kind regards

Roland
Roland Bouman is offline   Reply With Quote
Old March 25th, 2007   #6
relix
5 Cups of Ubuntu
 
Join Date: Mar 2006
Beans: 22
Re: PHP5 from apt-get and PDO

I'd like to add to that:

if you get an error "phpize not found" after trying to install pdo through pecl (sudo pecl install pdo), you should install the php5-dev package.

Code:
sudo apt-get install php5-dev
if you get the following error while trying to install pdo_mysql:

Code:
checking for MySQL support for PDO... yes, shared
checking for mysql_config... not found
configure: error: Cannot find MySQL header files under
ERROR: `/tmp/tmpRiQ5ax/PDO_MYSQL-1.0.2/configure' failed
you should install the following package:
Code:
sudo apt-get install libmysqlclient15-dev
(I got them both)

Last edited by relix; March 25th, 2007 at 06:51 AM.. Reason: Added second error
relix is offline   Reply With Quote

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:14 AM.


vBulletin ©2000 - 2010, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. lingonberry