View Full Version : [HOWTO] Get PDO and PDO_MYSQL working in PHP 5.2.5
I just recently had to do this so I thought I might as well share. There are a few threads already with some info, but it's not entirely complete in my opinion.
Let's get started.
1) First off, issue this command to check your pear/pecl config:
pecl config-show
This will show you your config. Now if your /tmp is mounted noexec, skip the following and jump to step 2) now.
My /tmp is mounted noexec and instead of messing with it, I just changed the config to a local writable directory.
Your config-show should have:
PEAR Installer cache directory cache_dir /tmp/pear/cache
PEAR Installer download download_dir /tmp/pear/cache
PEAR Installer temp directory temp_dir /tmp/pear/temp
Take note of the /tmp paths.
Type and execute:
pear config-set cache_dir /root/tmp/pear/cache
pear config-set download_dir /root/tmp/pear/cache
pear config-set temp_dir /root/tmp/pear/temp
Feel free to change the path to your own liking.
2) Now we will install pdo and pdo_mysql extensions.
Type and execute:
pecl install pdo
pecl install pdo_mysql
Now check your extensions directory to make sure they were installed. For my purposes they were in /usr/local/lib/php/extensions/no-debug-non-zts-20060613.
You should see pdo.so and pdo_mysql.so there.
3) Next you will need to re-compile PHP5. Before doing so, edit the configure file and add the following:
--enable-pdo=shared \
--with-pdo-mysql=shared \
--with-sqlite=shared \
--with-pdo-sqlite=shared \
Next recompile PHP with your method of choice.
4) Last step is to edit your /usr/local/lib/php.ini file.
Change your extension_dir to:
extension_dir = /usr/local/lib/php/extensions/no-debug-non-zts-20060613
Change this path if yours is different.
Scroll down and add the following extensions:
extension=pdo.so
extension=pdo_mysql.so
Exit and save your php.ini.
5) Restart httpd and open up a phpinfo.php file. You should now see pdo/pdo_mysql entries.
TROUBLESHOOTING
A) If you are receiving the following warning/error:
PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) 'pdo_mysql.so' in Unknown on line 0
Try restarting mysqld first.
ekaja
03-06-2008, 04:53 PM
Big Thank :)
Should....
cp /usr/local/lib/php/extensions/no-debug-non-zts-20060613/* /usr/local/lib/
and edit php.ini (/usr/local/lib/php.ini) to (for future :D )
extension_dir = "/usr/local/lib/"
:cool:
That works too. That's why I said "Change this path if yours is different." :)
jazzy
03-14-2008, 07:07 AM
After painstakingly trying to follow this (I'm a newbie so it took some time to find configure.php and learn how to edit it in vi), it seems like I've just messed it up. :confused:
Apache error log gives me this:
/usr/sbin/httpd: symbol lookup error: /usr/local/lib/php/extensions/no-debug-non-zts-20060613/pdo_mysql.so: undefined symbol: php_pdo_declare_long_constant
And when rebuilding php (./build php d) I get:
*** There was an error while trying to configure php. Check the configure.php file
My configure.php says:
#!/bin/sh
./configure \
--with-apxs \
--with-curl \
--with-curl-dir=/usr/local/lib \
--with-gd \
--with-gd-dir=/usr/local \
--with-gettext \
--with-jpeg-dir=/usr/local/lib \
--with-kerberos \
--with-mcrypt \
--with-mhash \
--with-mysql=/usr \
--with-pear \
--with-png-dir=/usr/local/lib \
--with-xml \
--with-zlib \
--with-zlib-dir=/usr/local/lib \
--with-zip \
--with-openssl \
--enable-bcmath \
--enable-calendar \
--enable-ftp \
--enable-pdo=shared \
--with-pdo-mysql=shared \
--with-sqlite=shared \
--with-pdo-sqlite=shared \
--enable-magic-quotes \
--enable-sockets \
--enable-track-vars \
--enable-mbstring \
--enable-memory-limit \
Any help at all would be highly appreciated, I'd love to work with PDO/MySQL.
Erik
What version of PHP?
Are you using customapache or custombuild?
smtalk
03-14-2008, 03:15 PM
GXX, customapache, because configure.php is mentioned in error.
About the problem, check: http://bugs.php.net/bug.php?id=35432
Missed his mention of configure.php specifically, thanks for picking that up.
Jazzy - did pdo and pdo-mysql install correctly to begin with?
jazzy
03-16-2008, 07:24 AM
GXX - yes, pdo and pdo-mysql did install correctly the first time.
I must admit that the first time I tried to get things working with just adding this to php.ini (after installing pdo-mysql, but hadn't found configure.php by the time...):
extension_dir = /usr/local/lib/php/extensions/no-debug-non-zts-20060613
and
extension=pdo.so
extension=pdo_mysql.so
Then I had to acknowledge that the *nix world (I've only set up apache/mysql/php on win before) really demanded that you know what you're doing, so google and this forum is your best friend. I found configure.php, managed to put in
--enable-pdo=shared
--with-pdo-mysql=shared,/usr/local/mysql
--with-sqlite=shared
--with-pdo-sqlite=shared
then rebuilt php, got error messages mentioned before, removed the ,/usr/local/mysql from this sentence: --with-pdo-mysql=shared,/usr/local/mysql
tried again to rebuild php, but alas, to no avail.
I read the bug report mentioned by smtalk, but can't find anything there that I haven't tried. :(
Ideas, anyone?
Here's my configure.php_ap2:
#!/bin/sh
./configure \
--with-apxs2 \
--with-curl \
--with-curl-dir=/usr/local/lib \
--with-gd \
--with-gd-dir=/usr/local/lib \
--with-gettext \
--with-jpeg-dir=/usr/local/lib \
--with-kerberos \
--with-openssl \
--with-mcrypt \
--with-mhash \
--with-mysql=/usr \
--with-pear \
--with-png-dir=/usr/local/lib \
--with-xml \
--with-zlib \
--with-zlib-dir=/usr/local/lib \
--with-zip \
--enable-bcmath \
--enable-calendar \
--enable-ftp \
--enable-magic-quotes \
--enable-sockets \
--enable-track-vars \
--enable-mbstring \
--enable-memory-limit \
--enable-pdo=shared \
--with-pdo-mysql=shared \
--with-sqlite=shared \
--with-pdo-sqlite=shared
I'm running apache 2.0.63 with php 5.2.5 using customapache. I assume you are using apache 1.3.x? What version of PHP are you compiling as well?
jazzy
03-16-2008, 01:19 PM
Solution found!
But, for those of you finding yourself in the same situation:
I got completely lost, whatever I did. I got this message via DA's Service Monitor when I tried to restart apache:
/sbin/service httpd start 2>&1
Then I tried restarting via SSH, getting this error:
Starting httpd:
Syntax error on line 17 of /etc/httpd/conf/httpd.conf
Cannot load /usr/lib/apache/libphp5.so into server
Tried to rebuild everything, but finally gave up and followed this advice to get everything up and running again:
http://www.directadmin.com/forum/showpost.php?p=117790&postcount=2
So, I'm now using custombuild in stead of customapache. I found my php conf (configure.php5) file here:
/usr/local/directadmin/custombuild/configure/ap2 and in order to get pdo working I filled in with the necessary lines:
--enable-pdo=shared \
--with-pdo-mysql=shared \
--with-sqlite=shared \
--with-pdo-sqlite=shared \
Then changed my php.ini file according to the guidelines in this How-To, and Voilą! I'm happy, and so are my clients (mostly for getting their sites up and running again...). Dunno what initially went wrong, but if you go the same road as I did, don't take any shortcuts. Good luck! :)
BTW: thx for replying, GXX and smtalk!
bjfield
03-31-2008, 02:26 PM
All the .so libraries installed fine. I moved them to /usr/local/lib for testing and didn't move them back, so don't be thrown by the path in the error messages below. I also updated the extension_dir to match. PHP5 recompiled and runs fine as long as I comment out the extension=pdo.so and extension=pdo_mysql.so lines in PHP.ini.
Starting httpd: PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) 'pdo.so' in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/pdo_mysql.so' - /usr/local/lib/pdo_mysql.so: undefined symbol: php_pdo_get_dbh_ce in Unknown on line 0
Thanks for any help!
UPDATE: I had to restart mysqld.
klemens
04-02-2008, 01:33 AM
i have do everything that is in this howto, but i get this error when restarting/starting apache.
PHP Warning: Module 'PDO' already loaded in Unknown on line 0
PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) 'pdo_mysql.so' in Unknown on line 0
klemens - try bjfield's idea of restarting mysqld.
webguy
04-03-2008, 01:12 AM
When I do the first step, I get the following:
pecl install pdo
downloading PDO-1.0.3.tgz ...
Starting to download PDO-1.0.3.tgz (52,613 bytes)
.............done: 52,613 bytes
12 source files, building
running: phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
/usr/local/bin/phpize: /tmp/pear/cache/PDO-1.0.3/build/shtool: /bin/sh: bad interpreter: Permission denied
Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF
environment variable is set correctly and then rerun this script.
ERROR: `phpize' failed
Do you have any suggestion what to do now?
It sounds like your /tmp is mounted as noexec.
Use the commands in step 1) to change your /tmp path and then re-run the install.
Hi
I cannot load PDO_MYSQL.SO??
Running CentOS 4
Apache 1.3.34
DirectAdmin 1.31.5
MySQL 4.1.11
PHP 5.2.5
Installed like this:
- installed: PHP_PDO_SHARED=1 pecl install PDO
- installed: PHP_PDO_SHARED=1 pecl install PDO_MYSQL
- build php
-- had to install autoconf, freetype and iconv, then PHP5.2.5 compiled fine.
Changed extensions dir path in php.ini, added the extensions.
extension=pdo.so loads fine.
extension=pdo_mysql.so cannot load, actually crashes apache.
Tried to put the pdo extensions in /usr/local/lib that didn't change a thing.
Then I ran:
1. pecl uninstall PDO_MYSQL
2. PHP_PDO_SHARED=1 pecl install PDO_MYSQL
...and following result came up, at the end of the log:
-----------------------------------------------------------------------
running: make INSTALL_ROOT="/var/tmp/pear-build-root/install-PDO_MYSQL-1.0.2" install
Installing shared extensions: /var/tmp/pear-build-root/install-PDO_MYSQL-1.0.2/usr/local/lib/php/extensions/no-debug-non-zts-20060613/
running: find "/var/tmp/pear-build-root/install-PDO_MYSQL-1.0.2" -ls
573852 4 drwxr-xr-x 3 root root 4096 Apr 16 16:27 /var/tmp/pear-build-root/install-PDO_MYSQL-1.0.2
623789 4 drwxr-xr-x 3 root root 4096 Apr 16 16:27 /var/tmp/pear-build-root/install-PDO_MYSQL-1.0.2/usr
623818 4 drwxr-xr-x 3 root root 4096 Apr 16 16:27 /var/tmp/pear-build-root/install-PDO_MYSQL-1.0.2/usr/local
623819 4 drwxr-xr-x 3 root root 4096 Apr 16 16:27 /var/tmp/pear-build-root/install-PDO_MYSQL-1.0.2/usr/local/lib
623820 4 drwxr-xr-x 3 root root 4096 Apr 16 16:27 /var/tmp/pear-build-root/install-PDO_MYSQL-1.0.2/usr/local/lib/php
623821 4 drwxr-xr-x 3 root root 4096 Apr 16 16:27 /var/tmp/pear-build-root/install-PDO_MYSQL-1.0.2/usr/local/lib/php/extensions
623822 4 drwxr-xr-x 2 root root 4096 Apr 16 16:27 /var/tmp/pear-build-root/install-PDO_MYSQL-1.0.2/usr/local/lib/php/extensions/no-debug-non-zts-20060613
623823 1152 -rwxr-xr-x 1 root root 1175295 Apr 16 16:27 /var/tmp/pear-build-root/install-PDO_MYSQL-1.0.2/usr/local/lib/php/extensions/no-debug-non-zts-20060613/pdo_mysql.so
Build process completed successfully
Installing '/usr/local/lib/php/extensions/no-debug-non-zts-20060613/pdo_mysql.so'
install ok: channel://pecl.php.net/PDO_MYSQL-1.0.2
configuration option "php_ini" is not set to php.ini location
You should add "extension=pdo_mysql.so" to php.ini
-----------------------------------------------------------------------
I then activate the dam* extension=pdo_mysql.so again, hoping....
I restart MySQL.... and Apache, and you know what........ it actually works.
From phpinfo: PDO drivers: sqlite2, sqlite, mysql running.
So it was just, in my case, to reinstall PDO_MYSQL
Just took me 4 hours *grin*
/FAF
Hello
Thanks for this little HOWTO, works fine for me on a fedora core 6 with PHP 5.2.6 and MySQL 5
Sky
indirectadmin
05-06-2008, 07:26 AM
.......
Let's get started.
1) First off, issue this command to check your pear/pecl config:
pecl config-show
I'm a newby: where or how should I enter this code ????
And....
I host some sites with dvwebhost.nl. I wrote them that I get an PDO error message (with trying to install Magenta) but they answer that it is loaded. What should I write them to get them acknowledge the problem?
Hello
To check if PDO is loaded, create a php file and do a echo phpinfo(); and check if PDO is there.
Sky
I'm getting a few errors when I try to install pdo and pdo_mysql
dedi07# pecl install pdo
pecl/PDO requires PHP (version >= 5.0.3), installed version is 4.4.8
No valid packages found
install failed
dedi07# pecl install pdo_mysql
pecl/PDO_MYSQL requires PHP (version >= 5.0.3), installed version is 4.4.8
pecl/PDO requires PHP (version >= 5.0.3), installed version is 4.4.8
No valid packages found
install failed
System information:
FreeBSD 6
Apache 2.0.63
PHP4 and PHP5
When I look at my info.php5 I see that pdo_sqlite and pdo_sqlite2 are installed, but it seems that pecl only sees PHP4 installed and therefore I can't install the modules.
Does any of you know a solution for this?
Dytech
07-09-2008, 11:48 PM
Hello,
I still got my phpize error and did change the peclconfig as stated in step 1.
Here's my pecl config :
Configuration (channel pecl.php.net):
=====================================
Auto-discover new Channels auto_discover <not set>
Default Channel default_channel pecl.php.net
HTTP Proxy Server Address http_proxy <not set>
PEAR server [DEPRECATED] master_server pear.php.net
Default Channel Mirror preferred_mirror pecl.php.net
Remote Configuration File remote_config <not set>
PEAR executables directory bin_dir /usr/local/bin
PEAR documentation directory doc_dir /usr/local/lib/php/doc
PHP extension directory ext_dir ./
PEAR directory php_dir /usr/local/lib/php
PEAR Installer cache directory cache_dir /root/tmp/pear/cache
PEAR configuration file cfg_dir /usr/local/lib/php/cfg
directory
PEAR data directory data_dir /usr/local/lib/php/data
PEAR Installer download download_dir /root/tmp/pear/cache
directory
PHP CLI/CGI binary php_bin /usr/local/bin/php
php.ini location php_ini <not set>
PEAR Installer temp directory temp_dir /var/tmp/pear/temp
PEAR test directory test_dir /usr/local/lib/php/test
PEAR www files directory www_dir /usr/local/lib/php/www
Cache TimeToLive cache_ttl 3600
Preferred Package State preferred_state stable
Unix file mask umask 22
Debug Log Level verbose 1
PEAR password (for password <not set>
maintainers)
Signature Handling Program sig_bin /usr/bin/gpg
Signature Key Directory sig_keydir /usr/local/etc/pearkeys
Signature Key Id sig_keyid <not set>
Package Signature Type sig_type gpg
PEAR username (for username <not set>
maintainers)
User Configuration File Filename /root/.pearrc
System Configuration File Filename /usr/local/etc/pear.conf
and when i want to run the command pecl install pdo_mysql i get :
downloading PDO_MYSQL-1.0.2.tgz ...
Starting to download PDO_MYSQL-1.0.2.tgz (14,778 bytes)
.....done: 14,778 bytes
downloading PDO-1.0.3.tgz ...
Starting to download PDO-1.0.3.tgz (52,613 bytes)
...done: 52,613 bytes
12 source files, building
running: phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF
environment variable is set correctly and then rerun this script.
ERROR: `phpize' failed
7 source files, building
running: phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF
environment variable is set correctly and then rerun this script.
ERROR: `phpize' failed
Any ideas?
Thanks
You have to install autoconf. On Debian run:
apt-get install autoconf
or on Fedora/CentOS something like this should work:
yum install autoconf
Big Thanks for how to :)
I just success install pdo_mysql on FreeBSD 6.3 with PHP 5.2.6 (customapache)
First of all check phpinfo I already have sqlite, pdo, pdo_sqlite so I just need to add pdo_mysql and all think should be done.
Install pdo_mysql (I not use pecl because I mounted /tmp with noexec and do not want to reconfig path so I just down load the tar and compile)
wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz
tar xzf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2
phpize
./configure
make install clean
I add extension=pdo_mysql to php.ini then restart apache
oops, got the error
/usr/sbin/httpd: symbol lookup error: /usr/local/lib/php/extensions/no-debug-non-zts-20060613/pdo_mysql.so: undefined symbol: php_pdo_declare_long_constant
So, I don't think I need to do the above installation, just recompile php with pdo_mysql as static or shared and all should work because the source is come with php under ext folder :)
Note: configure.php_ap2 is for php4 and have a few deprecated options for php5
so just replace it with the one from custombuild
cd /usr/local/directadmin/customapache
mv configure.php_ap2 configure.php_ap2.bak
wget -O configure.php_ap2 http://files.directadmin.com/services/custombuild/1.1/custombuild/configure/ap2/configure.php5
edit configure.php_ap2 just add the line --with-pdo_mysql (take care \ on the line before )
Now build php
./build php_ap2 n
That's it, after restart apache, all work fine, no need to add extension=pdo_mysql in php.ini because I not compile it as shared library, if you need it as shared library then just use --with-pdo_mysql=shared instread.
:)
liteonit
07-31-2008, 01:59 AM
I'm having some problems with pdo_mysql too.
I have ran the first staps without any problems.
I've added the extensions to the php.ini file... looks good...
If I restart apache, it won't start.
service httpd status returns: httpd dead but subsys locked
I've tried to restart MySQL first, and then apache, but still the same problem.
After removing the two extension lines in the php.ini, apache starts without any problem.
I tried to reinstall pdo and pdo_mysql, but that won't help :(
The extension dir in php.ini is correct, so that isn't the problem. When I go to that directory, the two .so files are listed in that directory.
I'm using custumbuild, php 5.2.6, Centos 5. :)
lethal0r
08-06-2008, 02:44 AM
And when rebuilding php (./build php d) I get:
*** There was an error while trying to configure php. Check the configure.php file
I got the same error. Debian + PHP 5.2.5 + Apache 2.0.63. I just gave and up and reinstalled apache and php without pdo support.
Bullcat
08-16-2008, 02:56 AM
i also get this error when rebuilding php ./build php d
this are the last row's when i'am building
checking for MySQL support... yes
checking for specified location of the MySQL UNIX socket... no
checking for MySQL UNIX socket location... no
checking for mysql_close in -lmysqlclient... no
checking for mysql_error in -lmysqlclient... no
configure: error: mysql configure failed. Please check config.log for more information.
*** There was an error while trying to configure php. Check the configure/ap2/configure.php5 file
and this is my php configure script.
./configure \
--with-apxs2 \ --with-curl=/usr/local/lib \
--with-gd \
--enable-gd-native-ttf \
--with-ttf \
--with-gettext \
--with-jpeg-dir=/usr/local/lib \
--with-freetype-dir=/usr/local/lib \
--with-kerberos \
--with-openssl \
--with-mcrypt \
--with-mhash \
--with-mysql=/usr \
--with-mysqli=/usr/bin/mysql_config \
--with-pear \
--with-png-dir=/usr/local/lib \
--with-zlib \
--with-zlib-dir=/usr/local/lib \
--enable-zip \
--with-iconv=/usr/local \
--enable-bcmath \
--enable-calendar \
--enable-ftp \
--enable-magic-quotes \
--enable-sockets \
--enable-mbstring \
--enable-pdo=shared \
--with-pdo-mysql=shared \
--with-sqlite=shared \
--with-pdo-sqlite=shared
So what is wrong, i take all the steps from the howto . ?
Hans
Ps.
The problem is fixed for me, when using
--with-mysql-dir=/usr/local/mysql
instead of
--with-mysql=/usr/local/mysql
http://bugs.php.net/bug.php?id=35848&edit=3
mutualad
09-28-2008, 07:46 PM
Being another noob in the original post it says
Next recompile PHP with your method of choice.
What are the available options?
Thanks
Bunker Spreckel
10-30-2008, 11:48 AM
I think you can skip the pecl part with php 5.2.6.
morfargekko
10-31-2008, 04:24 AM
Hello, when I issue the command pecl config-show I get an error saying that : -bash: pecl: command not found
I am running CentOS 5 and PHP 5.2.6
smtalk
11-18-2008, 01:09 PM
Just do:
cd /usr/local/directadmin/custombuild
./build update
./build php n
vilifone
11-21-2008, 08:53 PM
相当棒啊。。very good
Just for sure. This works with Debian right?
smtalk
12-20-2008, 12:52 PM
Yes, it works.
Im running into this error when i run pecl install pdo_mysql:
# pecl install pdo_mysql
downloading PDO_MYSQL-1.0.2.tgz ...
Starting to download PDO_MYSQL-1.0.2.tgz (14,778 bytes)
.....done: 14,778 bytes
7 source files, building
running: phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
building in /var/tmp/pear-build-root/PDO_MYSQL-1.0.2
running: /root/tmp/pear/cache/PDO_MYSQL-1.0.2/configure
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc and cc understand -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for PHP prefix... /usr/local
checking for PHP includes... -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/lib/php/extensions/no-debug-non-zts-20060613
checking for PHP installed headers prefix... /usr/local/include/php
checking for re2c... no
configure: WARNING: You will need re2c 0.12.0 or later if you want to regenerate PHP parsers.
checking for gawk... no
checking for nawk... nawk
checking if nawk is broken... no
checking for MySQL support for PDO... yes, shared
checking for mysql_config... not found
configure: error: Cannot find MySQL header files under
ERROR: `/root/tmp/pear/cache/PDO_MYSQL-1.0.2/configure' failed
Fixed it with a symbolic link:
ln -s /usr/local/mysql-5.0.51a-linux-i686/bin/mysql_config /usr/bin/mysql_config
I followed all the steps but I run into this error after compiling:
Starting httpd: httpd: Syntax error on line 18 of /etc/httpd/conf/httpd.conf: Cannot load /usr/lib/apache/libphp5.so into server: /usr/lib/apache/libphp5.so: undefined symbol: EVP_CIPHER_CTX_block_size
midas
03-06-2009, 04:11 PM
This wont work with mysql4.1 and php5? im getting the following error:
checking for MySQL support for PDO... yes, shared
checking for mysql_config... /usr/bin/mysql_config
checking for mysql_query in -lmysqlclient... no
configure: error: mysql_query missing!?
ERROR: `/root/tmp/pear/temp/PDO_MYSQL/configure' failed
I've never tried with MySQL 4.1 so I can't say that it'll work or not. Why not upgrade MySQL?
astra
03-09-2009, 09:38 AM
i have do everything that is in this howto, but i get this error when restarting/starting apache.
PHP Warning: Module 'PDO' already loaded in Unknown on line 0
PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) 'pdo_mysql.so' in Unknown on line 0
same error here:
PHP Warning:Module 'PDO' already loaded in Unknown on line 0
same error here:
PHP Warning:Module 'PDO' already loaded in Unknown on line 0
Did you ever get a chance to recompile PHP? What is the output of this grep?
php -info | grep configure
From what I've seen, that error comes when PDO/PDO_mysql is not compiled correctly in PHP.
midas
03-14-2009, 04:41 PM
I've never tried with MySQL 4.1 so I can't say that it'll work or not. Why not upgrade MySQL?
Due to websites only build on mysql 4 im not able to upgrade to 5 on this particular server. Yes, i hate it :)
nobaloney
03-16-2009, 01:23 PM
Someone told me there's a compability mode. No?
Jeff
nealdxmhost
05-17-2009, 08:10 AM
This is what I am getting after following your instructions;
/usr/local/bin/pecl install pdo
downloading PDO-1.0.3.tgz ...
Starting to download PDO-1.0.3.tgz (52,613 bytes)
.............done: 52,613 bytes
12 source files, building
running: phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
building in /var/tmp/pear-build-root/PDO-1.0.3
running: /root/tmp/pear/temp/PDO/configure
checking for egrep... grep -E
checking for a sed that does not truncate output... /bin/sed
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details.
ERROR: `/root/tmp/pear/temp/PDO/configure' failed
============================================
What am I missing or doing wrong?
I just recently had to do this so I thought I might as well share. There are a few threads already with some info, but it's not entirely complete in my opinion.
Let's get started.
1) First off, issue this command to check your pear/pecl config:
pecl config-show
This will show you your config. Now if your /tmp is mounted noexec, skip the following and jump to step 2) now.
My /tmp is mounted noexec and instead of messing with it, I just changed the config to a local writable directory.
Your config-show should have:
PEAR Installer cache directory cache_dir /tmp/pear/cache
PEAR Installer download download_dir /tmp/pear/cache
PEAR Installer temp directory temp_dir /tmp/pear/temp
Take note of the /tmp paths.
Type and execute:
pear config-set cache_dir /root/tmp/pear/cache
pear config-set download_dir /root/tmp/pear/cache
pear config-set temp_dir /root/tmp/pear/temp
Feel free to change the path to your own liking.
2) Now we will install pdo and pdo_mysql extensions.
Type and execute:
pecl install pdo
pecl install pdo_mysql
Now check your extensions directory to make sure they were installed. For my purposes they were in /usr/local/lib/php/extensions/no-debug-non-zts-20060613.
You should see pdo.so and pdo_mysql.so there.
3) Next you will need to re-compile PHP5. Before doing so, edit the configure file and add the following:
--enable-pdo=shared \
--with-pdo-mysql=shared \
--with-sqlite=shared \
--with-pdo-sqlite=shared \
Next recompile PHP with your method of choice.
4) Last step is to edit your /usr/local/lib/php.ini file.
Change your extension_dir to:
extension_dir = /usr/local/lib/php/extensions/no-debug-non-zts-20060613
Change this path if yours is different.
Scroll down and add the following extensions:
extension=pdo.so
extension=pdo_mysql.so
Exit and save your php.ini.
5) Restart httpd and open up a phpinfo.php file. You should now see pdo/pdo_mysql entries.
TROUBLESHOOTING
A) If you are receiving the following warning/error:
PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) 'pdo_mysql.so' in Unknown on line 0
Try restarting mysqld first.
nealdxmhost
05-17-2009, 09:14 AM
After some more poking around I found this and it worked like a charm!
http://www.directadmin.com/forum/showthread.php?t=28190&highlight=PDO
mkniskanen
05-02-2010, 10:52 AM
EDIT: Just found out that the problem probably only applies to the PHP executable /usr/local/bin/php whereas the Apache module _might_ work ok. This is weird, anyhow and the problem remains because some of my cron scripts will make use of PDO functions.
Any input from anybody who has succeeded in compiling and installing PDO?
I have successfully upgraded to PHP 5.3 but none of the tricks seems to work. The build script seems to finish, the end of the script outputs this:
Installing PDO headers: /usr/local/include/php/ext/pdo/
Increasing memory limit to 32M...
PHP 5.3.2 Installed.
Rewriting all users httpd.conf files, please wait...
In debug mode
Debug set to level 10
root priv set: uid:0 gid:0 euid:0 egid:0
pidfile written
staring queue
done queue
Restarting apache.
Stopping httpd: [ OK ]
Starting httpd:
Then, we test the result:
bash-3.2# /usr/local/bin/php
PHP Warning: PHP Startup: PDO: Unable to initialize module
Module compiled with module API=20060613
PHP compiled with module API=20090626
These options need to match
in Unknown on line 0
PHP Warning: PHP Startup: pdo_mysql: Unable to initialize module
Module compiled with module API=20060613
PHP compiled with module API=20090626
These options need to match
in Unknown on line 0
PHP Warning: PHP Startup: apc: Unable to initialize module
Module compiled with module API=20060613
PHP compiled with module API=20090626
What is even more alarming is that manual compilation will not work, either. The PECL installation system assumes that one can run scripts from the /tmp directory. This kind of setup is a pretty unsafe and should be avoided (I have been attacked once from there and I learned my lesson). So If you have done your security homework normal pecl installation will fail. So you will have to compile the whole thing manually. And here we go!
/home/tmp/PDO-1.0.3/pdo_dbh.c: In function 'pdo_stmt_instantiate':
/home/tmp/PDO-1.0.3/pdo_dbh.c:410: error: 'zval' has no member named 'refcount'
/home/tmp/PDO-1.0.3/pdo_dbh.c:411: error: 'zval' has no member named 'is_ref'
/home/tmp/PDO-1.0.3/pdo_dbh.c: In function 'pdo_stmt_construct':
/home/tmp/PDO-1.0.3/pdo_dbh.c:435: error: 'zend_fcall_info' has no member named 'object_pp'
/home/tmp/PDO-1.0.3/pdo_dbh.c:458: error: 'zend_fcall_info_cache' has no member named 'object_pp'
/home/tmp/PDO-1.0.3/pdo_dbh.c: In function 'zim_PDO_setAttribute':
/home/tmp/PDO-1.0.3/pdo_dbh.c:752: error: 'zval' has no member named 'refcount'
/home/tmp/PDO-1.0.3/pdo_dbh.c: In function 'zim_PDO_getAttribute':
/home/tmp/PDO-1.0.3/pdo_dbh.c:818: error: 'zval' has no member named 'refcount'
/home/tmp/PDO-1.0.3/pdo_dbh.c: In function 'pdo_hash_methods':
/home/tmp/PDO-1.0.3/pdo_dbh.c:1122: warning: assignment discards qualifiers from pointer target type
/home/tmp/PDO-1.0.3/pdo_dbh.c:1126: warning: assignment discards qualifiers from pointer target type
make: *** [pdo_dbh.lo] Error 1
I am pretty puzzled at the moment. Anybody with a hint. And: NO, I will not mount /tmp with an executable flag.
Markku
gman88
02-03-2011, 11:47 AM
You saved my butt with this - it worked, for me, precisely as described. I simply followed the directions and it worked! I was installing Drupal 7, for a client, and it couldn't detect MySQL. Thanks a million.
:)
Powered by vBulletin™ Version 4.0.4 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.