Virtualisation: A Symfony Developer’s Best Friend - Part 2

In my previous post, I talked about setting up your development environment using VMware Server and a pre-built FreeBSD 7.0 VM. Today, I’ll be showing you a few easy configuration tweaks as well as my own “best practice” with regards to directory layout and user management.

Performance Tweaks

If you have an AMD multi-core processor, you may have noticed that your VM’s system clock ticks rather slowly. A number of VMware users picked up on this, blogged about it but didn’t seem to get anywhere initially. VMware themselves, in fact, we’re that helpful. It took me a fair bit of blog comment digging to arrive at a partial solution for this irritating little quirk! Enough waffle, here’s the fix:

  • Log into your VM as ‘root‘ with the password ‘thoughtpolice‘ (unless you changed it!)
  • Type nano /boot/loader.conf and hit Enter*
  • Drop in the following line:
    • hint.apic.0.disabled=1
  • Hit Ctrl-X to save and exit
  • Issue the command shutdown -r now to reboot your VM
  • You’re done!

* I should point out that ‘nano’ is a text editor that ISN’T installed by default, so I may have jumped the gun a bit. You can install it using the ports collection, which I intend to go into detail about in my next post. Therefore, it would probably be a good idea to skip this configuration tweak and come back to it once I’ve shown you how to install and maintain the software for your VM distro of FreeBSD. Cue mild facepalming! :-)
I say “partial solution” because you will notice timestamp slippage over a protracted period of time, but I guess it isn’t that much of a big deal if don’t keep the VM running 24/7. As we’re setting up a development environment, uptime isn’t the most crucial factor.

Directory Layout

One thing that a development server needs is a good directory layout. You want to be able to find projects quickly without the need for extensive grepping and searching. My own personal preference all revolves around the /var directory - don’t ask me why, it just does! For the sake of this example, let’s say we are going to be building a website for “Acme Computers“, using the domain ‘acmecomputers.com‘. Here is how I would go about the initial setup of my fangled development directory structure for such a website. Please note that we won’t be filling the directories with anything at this point in time; I will cover this in subsequent posts. Okay, here goes:

  • Log into your VM as ‘root
  • First of all, we want to create the directories where the actual website code will reside. Type the following commands, hitting Enter after each:
    • mkdir /var/websites/
    • mkdir /var/websites/acmecomputers.com/
    • mkdir /var/websites/acmecomputers.com/www/
  • Next up, we want to setup a version control directory structure for our new project. Again, we want to stick to the same conventions as before. Type the following commands, hitting Enter after each:
    • mkdir /var/repos/
    • mkdir /var/repos/acmecomputers.com/
    • mkdir /var/repos/acmecomputers.com/www/
  • Finally, we want to setup an area where we can store Trac installations - for those who don’t know, Trac is project management and ticketing webapp written in Python that hooks into various repository formats to offer an integrated view of a project’s lifecycle. No, I didn’t copy and paste that - I’m pretty sure I was in marketing in a former life.. Type the following commands, hitting Enter after each:
    • mkdir /var/trac/
    • mkdir /var/trac/acmecomputers.com/
    • mkdir /var/trac/acmecomputers.com/www/
  • You’re done!

Really not that much to it, to be honest. The format is always…

  • /var/<area>/<domain>/<subdomain>

… as I found it to be the most intuitive. YMMV, of course, but this system just makes sense to me.

User Management

First rule of UNIX - don’t do things as ‘root‘ unless you really, really have to. Second rule of UNIX - pay attention to the first rule. Your trusty VM does not come bundled with any user accounts, so you will need to make some! Fortunately, the process is a breeze - for this example, we will create a user account called ‘jbloggs‘ with a randomly-generated password.

  • Log into your VM as ‘root
  • Type the following commands, hitting Enter after each. Whenever you see <default>, just hit Enter without typing anything:
    • adduser
    • Username: jbloggs
    • Full name: Joe Bloggs
    • Uid: <default>
    • Login group: <default>
    • Login group is jbloggs. Invite jbloggs into other groups?: <default>
    • Login class: <default>
    • Shell: bash
    • Home directory: <default>
    • Use password-based authentication?: <default>
    • Use an empty password?: <default>
    • Use a random password?: YES
    • Lock the account after creation?: <default>
    • You will see something similar to the following confirmation text:
      • Username: jbloggs
      • Password: <random>
      • Full Name: Joe Bloggs
      • Uid: 1003
      • Class:
      • Groups: jbloggs
      • Home: /home/jbloggs
      • Shell: /usr/local/bin/bash
      • Locked: no
    • OK?: YES
    • You will see something similar to the following final confirmation text:
      • adduser: INFO: Successfully added (jbloggs) to the user database.
      • adduser: INFO: Password for (jbloggs) is: dvq8724.828
    • Remember and write this password information down!
    • Add another user?: NO
    • You’re done!

Finally, you will want to change the permissions on the directory structures you just created so that your new user is able to read and write to them.

  • As ‘root‘, type the following commands, hitting Enter after each:
    • chown -R jbloggs:jbloggs /var/websites/
    • chown -R jbloggs:jbloggs /var/repos/
    • chown -R jbloggs:jbloggs /var/trac/

We will play around with these permissions once we have set up the Apache webserver and all the delicious web development trimmings. This, and more, will be covered in my next post. Ta-ta for now!

This entry was posted on Wednesday, April 30th, 2008 at 5:09 pm and is filed under Tutorial. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

3 Responses to “Virtualisation: A Symfony Developer’s Best Friend - Part 2”

  1. catchamonkey Says:

    I really need to pull up my proverbial socks and get going with svn.

  2. neonard0 Says:

    Hi thanks for this great job, there’s few information about the installation and configuration of a Web development environment using a production perspective. This is great I just hope you could write the next parts as soon as you can cause this information is soo helpfull.

    One more thing, you did not mentioned if there is a special reason why you chose that linux distribution

  3. superhaggis Says:

    Thanks for the kind comments!

    I’ve been using FreeBSD for over 10 years now and think it probably the most stable webserver O/S I’ve worked with. The ports collection makes everything a breeze to work with and beats RPM hands down, IMO. :-)
    Next part of this tutorial should be posted in the next couple of days.

Leave a Reply