Ubuntu/Apache/PHP5.2.1 - cannot use dynamic extensions

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
feenster
Forum Newbie
Posts: 5
Joined: Tue Mar 06, 2007 9:52 am

Ubuntu/Apache/PHP5.2.1 - cannot use dynamic extensions

Post by feenster »

Hi all,
I'm trying to compile PHP 5.2.1 on my Ubuntu 6.10 server. I've downloaded the source code from php.net and am running the following configure command on it:

Code: Select all

./configure --with-apxs2=/usr/bin/apxs2 --with-mysql --with-informix=/opt/informix --enable-shared --enable-pdo=shared --without-sqlite --without-pdo-sqlite --with-pdo-mysql=shared --with-zlib --with-xml --with-pdo-informix=shared,/opt/informix
After doing this, then make, I copy over the generated libphp5.so file into my Apache extensions directory, add extension=pdo.so (and lines for the PDO-MySQL/Informix extensions) into my php.ini and restart Apache. I would expect to see PDO, PDO-MySQL and PDO-Informix listed in my phpinfo() - but they don't appear.

So, I tried recompiling PHP but without any of the PDO extensions being shared. This worked, and I could see PDO and PDO-MySQL in phpinfo(), but not PDO-Informix.

So, can anyone hazard a guess as to why none of the PDO extensions load when compiled shared? I don't get any related error messages in the Apache or System logs by the way....

Cheers,
Matt
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Re: Ubuntu/Apache/PHP5.2.1 - cannot use dynamic extensions

Post by volka »

feenster wrote:So, can anyone hazard a guess as to why none of the PDO extensions load when compiled shared?
Did you only copy libphp5.so and not the pdo .so files? (.so shared object)
feenster
Forum Newbie
Posts: 5
Joined: Tue Mar 06, 2007 9:52 am

Post by feenster »

Hi Volka,

Initially, yes I just copied libphp5.so. However, I tried re-configure-ing and make-ing, then did a make install to make sure I copied the whole lot across.

Alas, still no joy :(

Matt
feenster
Forum Newbie
Posts: 5
Joined: Tue Mar 06, 2007 9:52 am

Post by feenster »

Sorted! The process was this:

1) Download the PHP 5.2.1 source into a fresh folder
2) Run the following:

Code: Select all

./configure --with-apxs2=/usr/bin/apxs2 --with-mysql --with-informix=/opt/informix --enable-shared --enable-pdo=shared --without-sqlite --without-pdo-sqlite --with-zlib --with-xml --with-pecl --with-pdo-mysql=shared --with-pdo-informix=shared,/opt/informix --with-config-file-path=/etc/php5/apache2
3) Ran "make" and "make install"
4) Altered /etc/php5/apache2/php.ini to this:

Code: Select all

extension_dir=/usr/local/lib/php/extensions/no-debug-zts-20060613
5) Added the following to php.ini:

Code: Select all

extension=pdo.so
extension=pdo_mysql.so
extension=pdo_informix.so
6) Restarted Apache2

And they appear in PHPInfo();!!! This leaves me with another problem unfortunately. *.php files are just displaying as source code in the browser, except for:

Code: Select all

<?php phpinfo(); ?>
Any ideas what could be causing this? I've enabled the PHP5 mod using "a2enmod php5", but to no joy. Any thoughts?

Cheers,
Matt
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

are short tags turned on?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

You need to tell apache what to do with .php files. This is usually done in the php.conf module for apache, when apache is configured with PHP as a module.
feenster
Forum Newbie
Posts: 5
Joined: Tue Mar 06, 2007 9:52 am

Post by feenster »

Kieran Huggins wrote:are short tags turned on?
Ah! No, they weren't, but I wasn't using short tags anyway. However, i've turned it on and it works a treat now. Do you know why this would be?

Thanks for the help guys.

Cheers,
Matt
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

http://de2.php.net/manual/en/ini.core.php#ini.short-open-tag wrote: short_open_tag boolean

Tells whether the short form (<? ?>) of PHP's open tag should be allowed. If you want to use PHP in combination with XML, you can disable this option in order to use <?xml ?> inline. Otherwise, you can print it with PHP, for example: <?php echo '<?xml version="1.0"'; ?>. Also if disabled, you must use the long form of the PHP open tag (<?php ?>).

Note: This directive also affects the shorthand <?=, which is identical to <? echo. Use of this shortcut requires short_open_tag to be on.
better use <?php
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Turn short tags off and rewrite the short tags in the code to be long tags.
feenster
Forum Newbie
Posts: 5
Joined: Tue Mar 06, 2007 9:52 am

Post by feenster »

Hi,
Thanks for the replies. That was my point - I already use the "long" version of the <?php tags. Not to worry though, if it is working fine now, that is good enough for me :)

Matt
Post Reply