[HOWTO] Get PDO and PDO_MYSQL working in PHP 5.2.5

Still got my phpize error

Hello,

I still got my phpize error and did change the peclconfig as stated in step 1.

Here's my pecl config :

Code:
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 :

Code:
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:
Code:
apt-get install autoconf

or on Fedora/CentOS something like this should work:
Code:
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)

Code:
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
Code:
/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.

:)
 
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. :)
 
And when rebuilding php (./build php d) I get:
Code:
*** 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.
 
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
 
Last edited:
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
 
Just do:
Code:
cd /usr/local/directadmin/custombuild
./build update
./build php n
 
Im running into this error when i run pecl install pdo_mysql:

Code:
# 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:

Code:
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:

Code:
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
 
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?
 
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?

Code:
php -info | grep configure

From what I've seen, that error comes when PDO/PDO_mysql is not compiled correctly in PHP.
 
Back
Top