Compiling Dbase extension for PHP in Ubuntu

Hi friends,

Are you getting an undefined function when you use dbase_create? Are you getting nothing at all? Well, probably you don’t have the dbase extension enable.

First, check for dbase.so. Try to search in your system and may be you have some luck and you have it, but it’s not enabled. Check the last part of this post to find out how to enable it.

So, two possible solutions exist for this problem: Either you compile PHP from scratch, or you compile just the dbase extension.

For compiling the complete php5 package, refer to this excellent post:  http://linuxhints.blogspot.com/2006/06/i-needed-to-have-php-compiled-with.html

In my case, I just wanted to compile the extension. However, I found out I couldn’t do that because the extension is not included in my php installation. I’m extending Mark Sanborn’s post, adding a solution for the non existing dbase extension.

I found out that since php 5.3.x the dbase extension was removed because it now not actively developed.
Because of that php team’s decision, now you have to download directly from reporsitory. So, I update the instructions:

For the popular packages Ubuntu has handy little packages that will install/add extentions to PHP, but not for dbase. Dbase is old as dirt and most people don’t use it for much anymore. I was recently working on a legacy app that works with dbase files and this was the extension i needed to allow php to work with the old dbase system.

After searching online for awhile I couldn’t really find a good answer for how to add the extension without completely reinstalling PHP5 from source.

What i ended up doing was just compiling that extenstion from source and pointing to it from my php.ini leaving my existing php5 intact.

Steps

Become root

1) root@zenware:/# sudo su

and type  your password

Get the Source code, Subversion, and Tools

2) apt-get install shtool dpkg-dev subversion

3) cd /opt

4) mkdir php

5) cd /opt/php

6) apt-get source php5

Get the source for dbase extension

As I told you, also DBase extension is no longer included, so:

7) cd /opt/php/php5-5.3.2/ext/

8) mkdir dbase

9) svn co http://svn.php.net/repository/pecl/dbase/trunk dbase

Compile the Extension

10) cd /opt/php/php5-5.3.2/ext/dbase

11) phpize

12) ./configure

13) make

Copy the extension

14) cp cp /opt/php/php5-5.3.2/ext/dbase/modules/dbase.so /usr/lib/php5/20090626+lfs/.

Restart Apache

15) /etc/init.d/apache2 restart

Done! Have a nice day.

Share

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark
tabs-top


11 Comments »

  1. [...] A base desse artigo foi tirada do zenware [3] [...]

    comment-bottom
  2. Madhura Jayaratne Says:

    Thank you so much for the tutorial. It was a great help :)

    comment-bottom
  3. Yaroslav Says:

    Thank you for this turtorial!

    comment-bottom
  4. Siranjeevi Says:

    Thank you so much, you helped me

    comment-bottom
  5. Duncan Says:

    Following these instructions, I am getting an error message when doing a “make test” for dbase:
    FAIL dbase_create() tests [tests/001.phpt]

    I then proceed anyway with the installation, which appears to go fine, but when I run a script that calls dbase, I get the error:
    PHP Fatal error: Call to undefined function dbase_open() in /var/www/test/ShapeFile.inc.php on line 296

    Do you have any idea how I might fix this? I’m running Ubuntu PHP 5.3.10

    Thank you!

    comment-bottom
  6. zen Says:

    Hi Duncan,

    Please provide complete log file. If you can, run the following command:

    # make > log.txt

    You don’t need to do “make test”, just “make”.

    And paste the content of log.txt file or send it to my email.

    A single error line is not enough to diagnose a problem with an extension.
    Also, if you actually manage to compile the extension, don’t forget to check the modules loaded using phpinfo() function.

    comment-bottom
  7. [...] dBase and Extension Compiling by Nick on 2012/06/13 at 13:27Posted In: PHPCredit to Zenware for this solutionIn the later PHP versions (in this example, 5.3.8), the dBase extension is not [...]

    comment-bottom
  8. zenacose Says:

    ӏ feel this is one of the such a lot іmpоrtаnt info for me.
    And i’m satisfied studying your article. But should statement on few normal things, The website style is great, the articles is truly great : D. Just right activity, cheers

    comment-bottom
  9. Friedel Hosenfeld Says:

    Excellent description, works fine!
    Thank you very much.

    friedel

    comment-bottom
  10. kriegu Says:

    do i have to modify php.ini and include the line extension=php_dbase.so?

    comment-bottom

RSS feed for comments on this post. TrackBack URL

Leave a comment