6098 comments
2357 subscribers
6259 on Twitter
Subscribe! Feed reader E-mail

VMWare, Samba, Eclipse, and XDebug: Mixing a virtual Linux environment with a Microsoft Windows development environment

I’m starting the second phase of a Drupal development project, which means I get to write about all sorts of geeky things again. Hooray! So I’m investing some time into improving my environment set-up, and taking notes along the way.

This time, I’m going to try developing code in Eclipse instead of Emacs, although I’ll dip into Emacs occasionally if I need to do anything involving keyboard macros or custom automation. Setting up a good Eclipse environment will help me use XDebug for line-by-line debugging. var_dump> can only take me so far, and I still haven’t figured out how to properly use XDebug under Emacs. Configuring Eclipse will also help me help my coworkers, who tend to not be big Emacs fans. (Sigh.)

So here’s my current setup:

  • A Linux server environment in VMWare, so that I can use all the Unix tools I like and so that I don’t have to fuss about with a WAMP stack
  • Samba for sharing the source code between the Linux VM image and my Microsoft Windows laptop
  • XDebug for debugging
  • Eclipse and PDT for development

I like this because it allows me to edit files in Microsoft Windows or in Linux, and I can use step-by-step debugging instead of relying on var_dump.

Setting up Samba

Samba allows you to share folders on the network. Edit your smb.conf (mine’s in /etc/samba/) and uncomment/edit the following lines:

security = user

[homes]
   comment = Home Directories
   browseable = no
   read only = no
   valid users = %S

You may also need to use smbpasswd to set the user’s password.

Xdebug

Install php5-xdebug or whatever the Xdebug package is for PHP on your system. Edit xdebug.ini (mine’s in /etc/php5/conf.d) and add the following lines to the end:

[Xdebug]
xdebug.remote_enable=on
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_autostart=1
xdebug.remote_connect_back=1

Warning: this allows debugging access from any computer that connects to it. Use this only on your development image. If you want to limit debugging access to a specific computer, remove the line that refers to remote_connect_back and replace it with this:

xdebug.remote_host=YOUR.IP.ADDRESS.HERE

Eclipse and PDT

I downloaded the all-in-one PHP Development Toolkit (PDT) from http://www.eclipse.org/pdt/, unpacked it, and imported my project. After struggling with Javascript and HTML validation, I ended up disabling most of those warnings. Then I set up a debug configuration that used Xdebug and the server in the VM image, and voila! Line by line debugging with the ability to look in variables. Hooray!

2011-05-31 Tue 17:37

Short URL: http://sachachua.com/blog/p/22270
  • Chris Calip

    All done without much unix foo skills needed:
    http://drupal.org/project/quickstart

  • http://sachachua.com Sacha Chua

    Oooh, even cooler. Thanks for sharing! =)

  • Droplet

    The only down side is transfer small files via samba is critically slow. (Using long time to index a new project in Eclipse/Netbeans)

  • http://wunderkraut.com Florian Loretan

    We use a similar setup, with the main difference being that the files are stored on the host system and shared with the guest system using VMware’s shared folders. We use OS X but it should work on Windows too. This has the advantage of having no noticeable slow down (even when using Eclipse!).

  • Droplet

    @Florian Loretan,
    Thanks for the sharing. I’m using Virtualbox and will do a test with VMware. Using shared folders in Virtualbox (root directory of Apache) will make LAMP slowly down.

  • mikeytown2

    I use andlinux. Here is a guide on how to do it.
    http://drupal.org/node/505974

  • Drupal Theme Garden

    Very interestin setup and approach.

    Why not a simple dual boot host (win/lin)?

    • http://sachachua.com Sacha Chua

      I like Microsoft OneNote and Autodesk Sketchbook Pro too much, and dual-booting can be a hassle. =)

  • mikeytown2

    One thing I forgot to mention is if you have multiple boxes Synergy is the way to go
    http://synergy-foss.org/

  • http://www.myplanetdigital.com/blog Patrick Connolly

    Dude, you should definitely ditch VMWare and Samba and check out Vagrant ;)
    http://www.vagrantup.com

    It’s multiplatform, and abstracts away all the complicated stuff (port forwarding, ssh, shared folders, etc.) and makes it so it’s literally one command to boot up and provision on the spot. Oh hey, and it gets around the shared folder slowness issue by running on an NFS host-only network if you prefer, and again, that’s as simple as editing one line in the config file. Guaranteed you won’t go back!

  • http://sachachua.com Sacha Chua

    Ooooh, that looks awesome indeed. I may try it for my next project. Bookmarked!

    Have I mentioned how much I like writing about ways I’ve solved something, particularly when people point out better and better ways to do things? =D Really, I don’t know why people think blogging is a time-waster…

  • http://www.bugsbane.net ramon

    Yehey! I’m not unique in calling you dude..

    Bookmarked Vagrant. I definitely will try that out. BTW: Doesn’t Eclipse come with keyboard mappings for Emacs? that way you won’t have to forgo your ‘muscle memory’. Forgive the comment if it’s littered with :wq’s.

    OK. Quick question – not about this post (since I my setup is pretty much the same, with the exception of VMWare Tools instead of SMB)…

    I was sent an RFP for an auction-site type project with some CMS mixed in. Rather than built it out using CakePHP or some other framework – I thought I’d go with Drupal 7 + DRUSH and build out the auction components in a module. (Views, I guess).

    What do you think? It may shave a week in development since I won’t have to bother with the CMS portion. But… I don’t know Drupal that well. Let me know please. I need to respond by Monday. Thanks.

  • http://sachachua.com Sacha Chua

    There are auction modules for Drupal, too. =) Tell you what – spend a weekend trying out Drupal, and you’ll have a better idea of how easy you’ll find it to implement. You might be surprised at how much you can cobble together from existing modules.

  • http://www.bugsbane.net ramon

    ok. Sounds like a challenge. I hope you’re able to get dry after that bike-ride.

    … but… an auction module for drupal??? hmmm… ok. baby steps. let’s crank…

    OH WAIT. quick question: when you got your vmware image, did you build it out yourself or get a public-domain one? if it’s the latter, can you let me know which? I do have a couple of ubuntu (8.x and 10.x) images for I want to use CentOS 5.6 for this project.

On This Day...

  • 2012: The Shy Connector: Thinking about the difficulties people encounter — I want to revise and expand on The Shy Connector, which seems to have become a perennial resource. I was [...]
  • 2011: Hungry hungry compost and other garden updates — The compost bin chomps through all the organic material we give it. It’s nowhere near the smooth dark brown of [...]
  • 2010: Weekly review: week ending May 30, 2010 — From last week’s plans: Work [X] Talk to people about expertise location and other new tools [X] Talk to [...]
  • 2009: Drupal in the trenches: MySQL and DELETE joins; multiple tests — Today was the first time I used a DELETE statement that joined multiple tables. I didn’t even know you could [...]
  • 2008: Drupal: Lather, rinse, repeat – Cleaner development with installation profiles and Makefiles — I’m beginning to really like Drupal, a PHP-based content management system. Working with Drupal feels almost like working with Emacs [...]
  • 2008: Weekly review: Week ending June 1, 2008 — Last week: Gave two presentations in person: I.B.Millennials at the Regional Technical Exchange at Sheraton Parkway, and Top 10 [IBM] Web [...]
  • 2007: Global opportunities in software development: talk by Winston Damarillo: 21:37 — I attended Winston Damarillo’s lecture on global opportunities in software development today. The audience included faculty from UP, Ateneo, and DLSU, three [...]
  • 2007: Party — We made it back to Manila in time for the party for IT geeks at the Museum Cafe in Greenbelt. The [...]
  • 2006: Wow, what a blogger! — Greet this blogger happy 83rd birthday, folks! Way, way cool. Link from Sandy Kemsley, Helen K’s daughter. On Technorati: blogging
  • 2006: Impromptu barbecue — James Iveniuk reminded me that we’d planned to have some kind of barbecue tonight. I invited Jed Smith as well because [...]
  • 2006: Interesting people, interesting conversations — It is my firm belief that if I mash interesting people together, they’ll most probably have interesting conversations – and if [...]
  • 2006: Blog hiccup — Sorry about the blog hiccup. I messed up my template last night. =) Random Japanese sentence: 鬼の居ぬ間に洗濯。 When the cat is away, [...]
  • 2005: Wahoo! iPod Photo — So much for not being a gadget freak. =) Dad got me an iPod Photo (30GB). After I formatted it to [...]
  • 2004: Testing Japanese — テスト。テスト。私はチュアです。
  • 2004: Task lists — If we store all tasks in a plain text file, we can generate task lists based on that text file instead. [...]
  • 2003: Funny Linus quote — Seriously, the way I did this was by using a special /sbin/loader binary with debugging hooks that I made (“dd” is [...]
  • 2003: More head-mounted displays — Jennifer Pellinen, wear-hard: I found this HMD that looks pretty decent and its a decent price. http://www.vrealities.com/vr1.html
  • 2003: Added TeachingReflections — Check out my TeachingReflections – stuff I learned from CS21A.
  • 2003: More problems in computer science — this website might be useful http://chortle.ccsu.ctstateu.edu/cs151/cs151java.html
  • 2003: More funky keyboards — - http://www.extremetech.com/article2/0,3973,1034116,00.asp - http://www.fingerworks.com/touchstream_products.html - http://www.cdc.gov/niosh/pdfs/97-148.pdf
  • 2003: Funny disclaimers — http://www.they.com/disclaimer/
  • 2003: OSS advocacy stats — http://www.dwheeler.com/oss_fs_why.html
  • 2003: More articles about women — “Making It on Their Merits” The U.S. high-tech sector is still predominantly male, but women have made significant progress in attaining prominence [...]

Get the highlights as a PDF!

Stories from my Twenties: Highlights from a Decade of Blogging

Free sample!