Archive for January 2011
Eclipse PHP with VMWare LAMP on Windows
With the free tools now available I decided to jump in and finally set up a better PHP toolkit. I work primarily in Windows… so there’s that… and my end production environments are half IIS and half LAMP so I set up IIS locally with PHP and also installed VMWare Player with a LAMP appliance from rPath on the VMWare site. My criteria for the LAMP appliance were a. LAMP and b. smallest download.
VMWare Player is awesome. Installation is a breeze, and running the appliance is pretty simple. One annoying trick with this one is that Ctrl-Alt is the shortcut to return keyboard/mouse control to the system, and the VM demands Ctrl-Alt-F2 for shell login. You need to hold Ctrl-Alt-SPACE-F2.
VMWare installs a pair of virtual network interfaces which you can use in Windows to talk to your VM. You have network options of Host-Only, NAT or Bridged. I first used Host-Only which assigned an IP address from my machine, but ended up using Bridged which uses an IP from your physical network — this was needed in order to connect to the outside world to retrieve installation packages. Either way, you want to be able to hit http://192.168.x.x which is the address the VM is running on, and you should see a LAMP appliance welcome screen. Use ifconfig, ifdown eth0 and ifup eth0 to mess around with the interface.
At first all I cared about was setting up FTP access so I could dump my files into the Apache document root. On this VM the documents are stored under /srv which was a little weird. I needed to make some changes to /etc/vsftpd.conf in order to set up FTP service the way I wanted it. Once that was done, I had my working LAMP dev environment and could do things the way I always had.
Once I had Eclipse installed, I wanted a way to simplify the way to deploy code to the VM. I found Aptana Studio which, among other things, allows you to synchronize local project files to a remote system (or VM in this case). All that was left was a way to round out the IDE with integrated debugging.
Eclipse PHP is automatically set up for use with Zend or XDebug. Zend didn’t seem like an option after the above setup so I went after XDebug. However it was a little tricky to get going on the VM since rPath had trimmed out a lot of utility “stuff”. They used a package manager called conary (new to me) and XDebug wasn’t included. XDebug would have been a snap to install using PECL but there were several missing dependencies:
– php (the php:devel libraries needed to build php extensions with phpize were not included, such as php.h)
– autoconf (from the world of compiling-from-source)
– gcc (the c compiler)
– glibc (the c libraries with which to build the extension)
As you can guess, I trudged through these missing dependencies as PECL returned error messages. Luckily all of these were available in rPath’s repository. I had no problems running these installers:
conary update php
conary update autoconf
conary update gcc
conary update glibc
During my flailings I got an error about out-of-date channel for PECL so I ran a channel update (basically, what it told me to do):
pecl channel-update pecl.php.net
Then the XDebug install using PECL went perfectly.
pecl install xdebug
Once I actually had the XDebug.so created, I added the following lines to /etc/php.ini:
[xdebug]
zend_extension="/usr/lib/php5/xdebug.so"
xdebug.remote_enable=on
xdebug.remote_log="/var/log/xdebug.log"
xdebug.remote_host=127.0.0.1
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
Restarted apache (/etc/init.d/httpd restart).
In Eclipse, I needed to set up my debugging to use an SSH tunnel (Run->Debug Configurations->Advanced) which allowed me to connect to the “remote host” of 127.0.0.1. Apparently Eclipse will automatically set up forwarding for port 9000.
That’s it! Eclipse PHP with full debug capabilities through a LAMP VM appliance. It may have been easier to put XAMPP on my machine but I think I prefer the cleanliness of the VM. Also, rPath itself offers a way to generate custom VMs which includes all of the above, but I’m still fiddling around with their interface.
