Monday, March 24, 2008

XAMPP+XDEBUG+UBUNTU

ok, my ubuntu seem to work as expected(after 3 day struggling with the network !^^). so now i'll just take a break and writing down some small, common, boring, newbie tutorial :)

hmm.. the first thing that i want to do with this box, is to do some PHP coding, and debugging. To accomplish this one could just do

$ sudo apt-get install apache2 php5-mysql libapache2-mod-php5 mysql-server
to install LAMP(Linux, Apache, MySql, PHP), and there you have it, simple huh? i remember doing this in slackware few years back ^^. next just start the apache, and mysql services by doing
$ sudo /etc/init.d/apache2 start
$ sudo /etc/init.d/mysql start

you might want to change default root password for mysql database by
$ mysqladmin -u root password newpasswd

now debugging part, I've been using xdebug for the last year, before that I used DBG, my personal opinion, xDebug felt better, cause its free and opensource. but before we can debug our code, we have to install it first by downloading the source for linux(in windows box, I've use the precompiled binary one) from hereTo install and configure xdebug for our local server is straight forward, I'll try to brief it here(you could see the README file in the tgz file for complete how-to)
  1. unpack the tarball, and cd to it
  2. run phpize ( if you have install php with apt-get this shouldn't be a problem) to generate configure script
  3. run ./configure, next run make, and there you have it, xdebug.so on modules directory
  4. then open /etc/php5/apache2/php.ini, using your fav editor
  5. add the line
    zend_extension="/wherever/you/put/it/xdebug.so"
  6. restart apache with
    $ sudo /etc/init.d/apache2 restart
  7. xdebug, should be loaded, you can check using phpinfo()on your page script, and search the XDebug section on that page
fyuhh.. now thats a brief ^^

the problem is, i didnt use ubuntu's LAMP :), I'm using XAMPP for Linux, formerly known as LAMPP, why ? because they have it all here, PHP4, PHP5, LAMP, ProFTPD, and PHPMyAdmin, sweet! just install it and you'll have the whole family with you.

Then why is it, using XAMPP for linux than Ubuntu's LAMP would be slight a problem? because if you only download the xampp default package, you cant compile xdebug o.O !!. To compile xdebug you need the XAMPP source (development package), so here's another brief way to install XAMPP and xDebug on ubuntu
  1. Download XAMPP for linux, and XAMPP development package from here
  2. Untar both tarball into /opt/ directory with (this is a must)
    $ tar -xzvf xampp-linux-1.6.6.tar.gz -C /opt
    $ tar -xzvf xampp-linux-devel-1.6.6.tar.gz -C /opt
    and you'll have /opt/lampp/ directory
  3. at this point you already have local server setup, you can check whether its working or not by
    $ /opt/lampp/lampp start
  4. unpack xDebug tarball, and cd to it(wherever you unpack it doesnt matter)
  5. run XAMPP's phpize to generate configure script(there's a slight different here)
    #pick one
    $ /opt/lampp/bin/phpize-5.2.5 #if you use php 5
    $ /opt/lampp/bin/phpize-4.4.8 #if you use php 4
  6. run
    $ ./configure --with-php-config=/opt/lampp/bin/php-config
    $ make
    and there you have it xdebug.so on /opt/lampp/modules directory, remember!, if you try to build xdebug package without aqquiring XAMPP development package, you'll stumble with some error that said missing this, missing that, etc..
  7. then open /opt/lampp/etc/php.ini, using your fav editor
  8. add the line
    zend_extension="/wherever/you/put/it/xdebug.so"
  9. next start your server, just like step #3
  10. done :)

ok, i might be missing some detail back there, (just typing what's in my head ^^), anyway the idea is, if you want to compile xdebug, you'll need PHP's sources (my case it was XAMPP development package)

have a nice day.. :)

6 comments:

IpuNk said...

which is better ?? xampp package or pure sources of apache ??


in my experience, pure sources provide more flexibility, you can choose only the module that you need, and compile it, which make the server run faster

but more flexibility is more confusing

heeehehehehhehee

like lovin someone,


wew

Zeft said...

hmm...
yes, in most of production server, optimize native server(self compiled and configured) is preferred,

but in development environment, for me XAMPP still the most convinient way. You can switch php engine to use, administer database, etc effortless, while concentrate on application development..

and bout lovin someone, hihihi not much to say is it :p

Unknown said...

If it is any help to anyone. I had to add a "make" step after the configure as described at http://xdebug.org/docs/install

Zeft said...

hi, eric
maybe I didnt make myself clear enough, anyway thx for pointing it out

Anonymous said...

Thanks for the post. It helpful.

Anyway I must use

./configure --with-php-config=/opt/lampp/bin/php-config

not just

./configure

Zeft said...

hi william, yep think I've also use that option too and forgot to wrote it argh... thx for remind me though :D