PHP5 & MySQL

apps

#1

Ok, I’ve got PHP5 compiled and working with everything I need… except MySQL. Using any MySQL commands results in a segfault with this backtrace:

#0 0x081f2d0d in add_property_string_ex (arg=0x848265c, key=0x82bfb93 "def", key_len=4, str=0xc223 <Address 0xc223 out of bounds>, duplicate=1) at /home/porges/src2/php-5.0.3/Zend/zend_API.c:1134 #1 0x080dfb3b in zif_mysql_fetch_field (ht=1, return_value=0x848265c, this_ptr=0x0, return_value_used=1) at /home/porges/src2/php-5.0.3/ext/mysql/php_mysql.c:2250 #2 0x0822479a in zend_do_fcall_common_helper (execute_data=0xbfff76d0, opline=0x846f294, op_array=0x845efdc) at /home/porges/src2/php-5.0.3/Zend/zend_execute.c:2713 #3 0x08224dd1 in zend_do_fcall_handler (execute_data=0xbfff76d0, opline=0x846f294, op_array=0x845efdc) at /home/porges/src2/php-5.0.3/Zend/zend_execute.c:2843 #4 0x0820d0b5 in execute (op_array=0x845efdc) at /home/porges/src2/php-5.0.3/Zend/zend_execute.c:1400 #5 0x08224882 in zend_do_fcall_common_helper (execute_data=0xbfff7c80, opline=0x8475bdc, op_array=0x8470b5c) at /home/porges/src2/php-5.0.3/Zend/zend_execute.c:2740 #6 0x08224bd9 in zend_do_fcall_by_name_handler (execute_data=0xbfff7c80, opline=0x8475bdc, op_array=0x8470b5c) at /home/porges/src2/php-5.0.3/Zend/zend_execute.c:2825 #7 0x0820d0b5 in execute (op_array=0x8470b5c) at /home/porges/src2/php-5.0.3/Zend/zend_execute.c:1400 #8 0x08224882 in zend_do_fcall_common_helper (execute_data=0xbfff80d0, opline=0x84f71d8, op_array=0x84f82d8) at /home/porges/src2/php-5.0.3/Zend/zend_execute.c:2740 #9 0x08224bd9 in zend_do_fcall_by_name_handler (execute_data=0xbfff80d0, opline=0x84f71d8, op_array=0x84f82d8) at /home/porges/src2/php-5.0.3/Zend/zend_execute.c:2825 #10 0x0820d0b5 in execute (op_array=0x84f82d8) at /home/porges/src2/php-5.0.3/Zend/zend_execute.c:1400 #11 0x08224882 in zend_do_fcall_common_helper (execute_data=0xbfff9ee0, opline=0x8455e24, op_array=0x8438c84) at /home/porges/src2/php-5.0.3/Zend/zend_execute.c:2740 #12 0x08224bd9 in zend_do_fcall_by_name_handler (execute_data=0xbfff9ee0, opline=0x8455e24, op_array=0x8438c84) at /home/porges/src2/php-5.0.3/Zend/zend_execute.c:2825 #13 0x0820d0b5 in execute (op_array=0x8438c84) at /home/porges/src2/php-5.0.3/Zend/zend_execute.c:1400 #14 0x08229a16 in zend_include_or_eval_handler (execute_data=0xbfffa230, opline=0x8438970, op_array=0x844c8bc) at /home/porges/src2/php-5.0.3/Zend/zend_execute.c:3565 #15 0x0820d0b5 in execute (op_array=0x844c8bc) at /home/porges/src2/php-5.0.3/Zend/zend_execute.c:1400 #16 0x08229a16 in zend_include_or_eval_handler (execute_data=0xbfffce10, opline=0x843d48c, op_array=0x8435a04) at /home/porges/src2/php-5.0.3/Zend/zend_execute.c:3565 #17 0x0820d0b5 in execute (op_array=0x8435a04) at /home/porges/src2/php-5.0.3/Zend/zend_execute.c:1400 #18 0x08229a16 in zend_include_or_eval_handler (execute_data=0xbfffcf50, opline=0x843590c, op_array=0x843162c) at /home/porges/src2/php-5.0.3/Zend/zend_execute.c:3565 #19 0x0820d0b5 in execute (op_array=0x843162c) at /home/porges/src2/php-5.0.3/Zend/zend_execute.c:1400 #20 0x081f05f8 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /home/porges/src2/php-5.0.3/Zend/zend.c:1069 #21 0x081c1d8a in php_execute_script (primary_file=0xbffff2ac) at /home/porges/src2/php-5.0.3/main/main.c:1628 #22 0x0822d843 in main (argc=2, argv=0xbffff334) at /home/porges/src2/php-5.0.3/sapi/cgi/cgi_main.c:1568I’ve had a Google around, but can’t find much to help. Any suggestions?


#2

How did you compile PHP5? What are you doing in your PHP code when it segfaults?

I’ve got PHP5 compiled and working with MySQL. I’ve posted what I did to compile it on the knowledge base (see the comment on 2005-03-31 by psross):

https://panel.dreamhost.com/kbase/index.cgi?area=2538

Phil


#3

I cleared out everything and started again from scratch and this time it works :slight_smile:

I guess that’s a good thing :stuck_out_tongue:


#4

Phil,
That would be an excelent thing to add to the Dreamhost Wiki

-Jason

I40.com - Home Page
MP3Mystic - Personal Streaming Music server.
(Neither of these sites are still hosted at dreamhost)


#5

Just when you got PHP 5.0.3 working, 5.0.4 is released. ha! Change log for 5.0.x


#6

I added my install script at:

http://wiki.dreamhost.com/index.php/Installing_PHP5

Feel free to tweak it (e.g. minimise the install)


#7

I like, but couple suggestions:

Change /home/USERNAME to $HOME. This will prevent extensive editing by the end user.

Export $DOMAIN to equal the user’s domain directory. This way they can edit just one like (at top) and you can use $DOMAIN from then on: export DOMAIN=$HOME/EXAMPLE.COM

Reformat the configure options use to the \ command line seperators to prevent excessive scrolling (especially for PHP). I’d also go as far as suggest making an independing configure script for PHP itself. I’d also suggest some # comments so new users know what each command option is for; so they aren’t blindly compiling something they don’t understand.

OpenSSL works just find w/out having to compile you’re own version. Dreamhost is running 0.9.6c vs 0.9.7f you’re downloading in your script–I wouldn’t think they are that much different.

You forgot to export your PATH on this line, just before the PHP Configure:
PATH=/home/USERNAME/php/bin:$PATH

Other than that, looks very thorough. Good work.

*Edit; ha, just saw the Feel free to tweak it (e.g. minimise the install) part of your post. I can do it at a later time if it isn’t done already.


#8

Ok I changed /home/username to $HOME, added a $DOMAIN export at the top. Feel free to edit anything else.


#9

First of all, thank you very much for writing this up! :slight_smile:

Now, any idea why PHP 5 hates MySQL? lol

I get the following when running the configure script on PHP 5.0.4:

<lots of things snipped> 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. make: *** No targets specified and no makefile found. Stop. make: *** No rule to make target `install'. Stop. mkdir: cannot create directory `cgi-bin': File exists cp: cannot stat `/home/testx0r/php/bin/php': No such file or directory The bottom portion of config.log reads:

[code]configure:56352: checking for MySQL support
configure:56398: checking for specified location of the MySQL UNIX socket
configure:56455: checking for MySQL UNIX socket location
configure:56611: checking for mysql_close in -lmysqlclient
configure:56630: gcc -o conftest -g -O2 -Wl,-rpath,/home/testx0r/php/lib -L/home/testx0r/php/lib conftest.c -lmysqlclient -lmhash -lmcrypt -liconv -lpng -lz -ljpeg -lcurl -lz -lssl -lcrypto -lresolv -lm -ldl -lnsl -lxml2 -lz -liconv -lm -lcurl -lidn -lssl -lcrypto -ldl -lz -lxml2 -lz -liconv -lm 1>&5
/usr/lib/libmysqlclient.a(viosslfactories.o): In function new_VioSSLConnectorFd': viosslfactories.o(.text+0x51): undefined reference toOpenSSL_add_all_algorithms’
/usr/lib/libmysqlclient.a(viosslfactories.o): In function new_VioSSLAcceptorFd': viosslfactories.o(.text+0x306): undefined reference toOpenSSL_add_all_algorithms’
collect2: ld returned 1 exit status
configure: failed program was:
#line 56619 “configure”
#include “confdefs.h”
/* Override any gcc2 internal prototype to avoid an error. /
/
We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char mysql_close();

int main() {
mysql_close()
; return 0; }
configure:56835: checking for mysql_error in -lmysqlclient
configure:56854: gcc -o conftest -g -O2 -Wl,-rpath,/home/testx0r/php/lib -L/home/testx0r/php/lib -Wl,-rpath,/home/testx0r/php/lib -L/home/testx0r/php/lib -Wl,-rpath,/home/testx0r/php -L/home/testx0r/php conftest.c -lmysqlclient -lz -lmhash -lmcrypt -liconv -lpng -lz -ljpeg -lcurl -lz -lssl -lcrypto -lresolv -lm -ldl -lnsl -lxml2 -lz -liconv -lm -lcurl -lidn -lssl -lcrypto -ldl -lz -lxml2 -lz -liconv -lm 1>&5
/usr/lib/libmysqlclient.a(viosslfactories.o): In function new_VioSSLConnectorFd': viosslfactories.o(.text+0x51): undefined reference toOpenSSL_add_all_algorithms’
/usr/lib/libmysqlclient.a(viosslfactories.o): In function new_VioSSLAcceptorFd': viosslfactories.o(.text+0x306): undefined reference toOpenSSL_add_all_algorithms’
collect2: ld returned 1 exit status
configure: failed program was:
#line 56843 “configure”
#include “confdefs.h”
/* Override any gcc2 internal prototype to avoid an error. /
/
We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char mysql_error();

int main() {
mysql_error()
; return 0; }
[/code]I’ve not done this before so have no idea where to even begin reading that output. :\

Any help would be appreciated. :slight_smile:


#10

What options did you pass to configure?

The errors seem to indicate that the OpenSSL library cannot be found. Try including --with-openssl=/usr in the configure options.


#11

Sorry, I should’ve specified. I’m following the instructions listed in the wiki: http://wiki.dreamhost.com/index.php/Installing_PHP5

So the options passed to configure are:

–prefix=$HOME/php
–with-config-file-path=$HOME/etc/php5
–enable-force-cgi-redirect --with-xml
–with-libxml-dir=$HOME/php
–enable-soap
–with-xsl=$HOME/php
–with-openssl=$HOME/php
–with-mhash=$HOME/php
–with-mcrypt=$HOME/php
–with-zlib-dir=$HOME/php
–with-jpeg-dir=/usr
–with-png-dir=/usr
–with-gd
–enable-gd-native-ttf
–enable-ftp
–enable-sockets
–enable-wddx
–with-iconv=$HOME/php
–enable-sqlite-utf8
–enable-calendar
–with-curl=$HOME/php
–enable-mbstring
–enable-mbregex
–with-mysql=/usr

I tried changing --with-openssl=$HOME/php to --with-openssl=/usr but received the same result. :frowning:

I’m on dozer… not sure if that makes a difference.

Thanks again for any assistance.


#12

Does it fail w/out the openSSL? That’s only needed if you’re wanting to use SSL, and if you’re new to this, most likely this isn’t your intent.

Compiling you’re own PHP can open up additional security holes; thus using SSL on your compiled PHP will probably be a bad idea.


#13

I got rid of the --with-openssl option but same error.

I got rid of the --with-mysql option and it configured fine. But that’s a little useless. :\ I know I can use SQLite, but all of my development is done with MySQL due to its market share.

I tried it with the openssl option and not with the mysql option and it worked fine too. So the problem’s definitely with compiling MySQL support.

Any other ideas?


#14

The MySQL libraries installed at DreamHost were built with SSL support. As far as I understand it, this means PHP also has to be built with SSL support.

Try removing all the libssl* stuff from your $HOME/php directory and configure again with --with-openssl=/usr (or delete $HOME/php and start again without building your own OpenSSL). The PHP configure script may be picking up the 0.9.7 OpenSSL libraries from $HOME/php instead of the 0.9.6 libraries from /usr.


#15

Success! :smiley:

I rm -rf’ed everythig, re-ran the script without any of the OpenSSL stuff and changed config’s OpenSSL path to /usr and it worked like a charm!

I updated the wiki page to reflect this… hope that’s ok.

Thanks very much both of you for all of your help!


#16

I got it compiled following the install script; perhaps the different servers are slightly different?

I’m on Lira, and I see that you aren’t …

(cd … && ls | grep test)


#17

I tried to install this morning using http://wiki.dreamhost.com/index.php/Installing_PHP5. Thank you very much for all your work. However I can’t get it running.
There was no cgi-bin directory built in the domain and the php cgi file wasn’t copied. So I did that and I still get the following error message.
“The requested URL /cgi-bin/php.cgi/cgi-bin/php.cgi/php_info.php was not found on this server”.
Any suggestions or help would be greatly appreciated.


#18

Odd, the script should have created the cgi-bin directory…

What are you doing to get the error “The requested URL /cgi-bin/php.cgi/cgi-bin/php.cgi/php_info.php was not found on this server”? Seems a bit strange to me.

You should have copied “php” from “~/php/bin/php” into “~/EXAMPLE.COM/cgi-bin/php.cgi”


#19

I don’t know what I did wrong.

The script ran and showed no errors and it created the /etc, the /src and the /php directories in the root but nothing in the domain.com/ directory.

I created domain.com/cgi-bin and copied the php directory from the root into it using ws_ftp.