Category: Uncategorized

  • Setting up a VirtualBox dev environment

    This article runs through the process of setting up a VirtualBox dev box on Windows host machine.  It was written with Laravel in mind, but the steps should apply to most circumstances. I don’t go into actually installing Laravel, there are plenty of guides out there for that!

    Mainly I wanted to achieve:

    • Ubuntu 64bit virtual machine.
    • A networking environment that would work regardless of the network I was conected to.
      • One network to allow the VM to access the internet
      • One network that would have a statically assigned IP that I could connect to from my host machine (SSH, HTTP, etc.)
    • Shared folder that auto mounts, configured to allow me to access the dev files directly on my host machine.

    Setting up the Virtual Machine

    I assume you are capable of setting up a basic Ubuntu Virtual Machine, the only difference to the defaults are the networking options.

    Set up a basic Ubuntu Virtual Machine, I used the 64bit build, but that isn’t specifically required.

    Set “Adapter 1” attached to to “NAT”.  Enable “Adapter 2” and set attached to to “Host-only Adapter”.

    Configuring the network adapters

    Once you are at the CLI run:

    sudo nano /etc/network/interfaces

    and to the end of the file add:

    # Host-only Network
    auto eth1
    iface eth1 inet static
    address 192.168.56.2
    netmask 255.255.255.0
    network 192.168.56.0
    broadcast 255.255.255.255

    and then reboot.  You should now be able to ping the box at 192.168.56.2.  If not check the config for your Host-only network and adjust the IP address as necessary.  If you are going to run multiple boxes at the same time adjust the address to avoid conflicts.

    It might be a good time to install an SSH Server so that you can SSH remotely to perform the remaining tasks:

    sudo apt-get install openssh-server

     Configuring the Shared Folders

    Basic steps here are:

    • Install the VM Guest Additions
    • Set up the shared folder on the host and in VirtualBox
    • Configure the shared folder on the Virtual Machine and set it to auto mount

    I found several guide to doing this online, most suggesting you add the mount point to your fstab file to auto-mount at boot, this wouldn’t work for me, resulting in an “unable to mount” message at boot, so I used the startup file instead, as below.

    Install the VM Guest Additions

    First install DKMS

    apt-get install dkms

    Then, mount the Guest Additions ISO in VirtualBox, located at C:\Program Files\Oracle\VirtualBox.

    On the virtual machine mount the ISO, change location to the CDROM folder and launch the installer:

    sudo mount /dev/cdrom /media/cdrom
    cd /media/cdrom
    sudo sh ./VBoxLinuxAdditions.run

    Then reboot the box

    Set up the shared folder on the Host

    Create a directory on the host to share.

    In VirtualBox edit the box properties and choose the Shared Folder tab. Select Machine Folders and click new, set the Folder path to the folder you just created and give the share a name.

    On the virtual machine edit the start script file:

    sudo nano /etc/rc.local

    and add

    sudo mount -t vboxsf Shared_Folder_Name /mnt/test

    above the exit 0 line.  You’ll need to set /mnt/test to your mount location (Ensure this exists first!) and set Shared_Folder_Name to your shared folder name.

    You can add as many shared folders as you like here, one to a line.

     

  • Using PhpStorm with remote documents directories

    If you are attempting to use JetBrains PhpStorm in a domain environment with remote home directories you have probably ran into the following error message.

    Config path '\\yourDomain\yourShare\yourUsername\.WebIde70\config' is invalid. If you have modified the 'idea.config.path' property please make sure it is corect, otherwise please re-install the IDE.

    Needless to say, reinstalling will not help, and chances are you haven’t modified the idea.config.path property, however ironically this is exactly what you do need to do to fix the issue!

    Having contacted JetBrains support (Who were very helpful!) I got to the bottom of this issue.  PhpStorm will not work with network locations, but it automatically picks up the documents directory from AD, which invariably will be a network location.

    To force it to use another location open up idea.properties (Found in C:\Program Files (x86)\JetBrains\PhpStorm 8.0.3\bin  [change the PhpStorm version number accordingly] on Windows 7 64bit), uncomment the top two settings, “idea.config.path” and “idea.system.path” and set them to a location either directly on a local drive or on a mapped drive (Remember to use forward slashes!)  Although the error message only mentions “idea.config.path” you need to do both otherwise if you only change one of the paths you’ll get a similar message complaining about “idea.system.path”

    Once done you can launch PhpStorm and it will load and work fine.