This is the continuation of a previous post where we set up an Ubuntu virtual machine in VMWare Player on a Windows host. To recap, what we’ve got so far is:
- An easily-accessible Ubuntu server.
- Folders on the host shared with the guest. We can edit code on the host machine and then test the changes in the guest directly, without having to upload / copy / publish / sync anything.
Hurrah!
Running a VM in this way has one profound annoyance: once you’re using the server, you can’t get out! The player captures your mouse and keyboard, and all input is directed to the player. You can get them back again by pressing Ctrl+Alt, but this process keeps getting in the way – stopping easy Alt+Tabbing and disrupting my working rhythm. I also had an additional problem: I use a customised version of the Dvorak keyboard layout, and didn’t fancy the effort required to set this up on Linux. Luckily there’s an easy solution.
The defacto-standard secure shell client on Windows is PuTTY, and this is great for connecting to remote servers. Just because the guest system is running on the same machine doesn’t mean I can’t pretend it’s miles away! Before you connect you’ll have to install an SSH daemon:
sudo apt-get install openssh-server
Now connecting is easy – just put the hostname in and click “Open”:
On some networks you may find that the hostname doesn’t resolve, or it may take a little time for your router to figure out what the name is. You can easily work around this by connecting directly to the IP address of your virtual machine – find it by entering the ifconfig command at the shell. Looking this up every time you boot up the VM rapidly becomes tedious and so you may want to assign a static IP. This is a pretty simple process from the shell, although you may have to persuade your router to play nicely with this process. Once you’ve fixed the IP you can save it in PuTTY as a session, or even add a meaningful name to your Windows hosts file to make it permanent.
Playing with the PuTTY settings is a worthwhile process. I usually set up a couple of changes in the “Default Settings” session to make my life better:
- Window->Behaviour, set “Full screen on Alt-Enter” to on
- Connection->Data, set “Terminal-type string” to “xterm-color” to enable the colourful shell prompt
We’ve done a lot but not made a lot of progress from the where we started. We’ve got easier access to a Linux server than ever before, but it doesn’t yet do much. Here’s what I do to get things going:
locale-gen en_GB.UTF-8 update-locale LANG=en_GB.UTF-8 apt-get install apache2 php5 mysql-server libapache2-mod-php5 php5-cli php5-curl php5-gd php5-mysql echo "AddDefaultCharset utf-8" > /etc/apache2/conf.d/charset mv /etc/php5/apache2/php.ini{,.old} cp /usr/share/doc/php5-common/examples/php.ini-development /etc/php5/apache2/php.ini a2enmod rewrite service apache2 restart exit
Once that’s all finished you can test by navigating to your server in a web browser.
Hurrah!
The final step is to make the webserver serve up the shared files from the host. You can easily dig in and edit Apache’s configuration files to accomplish this, but an alternative scheme is just to add a symlink:
sudo ln -s /mnt/hgfs/www /var/www/
(This assumes you setup the shared drive as I did in part 1, i.e. under the name “www”). Now we can access the shared files in the webserver at http://leighserver/www/, and immediately preview changes made in the host.
In future posts I’ll take a look at how we make those changes in the host, and what development tools there are to make that easier.
One Trackback
[…] just a few more steps to cover to complete the installation, and we’ll take a look at these next time. This entry was posted in Computing. Bookmark the permalink. Post a comment or leave a trackback: […]