Skip to content

Instantly share code, notes, and snippets.

@stevenyap
Created November 20, 2013 11:01
Show Gist options
  • Select an option

  • Save stevenyap/7561359 to your computer and use it in GitHub Desktop.

Select an option

Save stevenyap/7561359 to your computer and use it in GitHub Desktop.
Setup of VirtualBox with CentOS 6 for fast testing of deployment scripts

This guide shows the step to setup VirtualBox with CentOS 6 for your testing of deployment scripts on Rails.

Pre-requistions

  • You are using Mac

VirtualBox and CentOS 6.4 Installation

  • VirtualBox is a virtual machine that will run your CentOS and acts as a separate machine
  • Follow the guide from http://opensourcedbms.com/dbms/installing-cent-os-6-3-linux-in-oracle-virtual-box-ssh-access/ to install and setup your CentOS with the following exceptions:
    • Skip the steps on editing /etc/sysconfig/network-scripts/ifcfg-eth0 and setting up of SSH
    • Use CentOS 6.4 (64-bits) instead of 6.3
    • Make sure you disable SELinux (vi /etc/sysconfig/selinux and change the string from SELINUX=enforcing to SELINUX=disabled.). Note: You need to restart server for this change.

Setup SSH and Internet on VirtualBox

  • Make sure the Virtual machine is off
  • Go to Settings > Network > Adapter 1
  • Make sure "Attached to" is set to "Nat"
  • Click on Port Forwarding and set it to Protocal: TCP, Host Port: 2222, Guest Port: 22
  • Add another Protocal: TCP, Host Port: 8888, Guest Port: 80
  • Save it. This sets up the SSH and webserver port forwarding.
  • Go to Settings > Network > Adapter 2
  • Make sure "Attached to" is set to "Bridged Adapter" and set your Name to the wireless or wired connection of your computer
  • Turn on the virtual machine.
  • You can now SSH to the VM via: ssh localhost -p 2222 -l root
  • VM can access Internet.

Further Setup for later

  • Stop iptables (Linux firewall) for easier access to your computer service iptables stop
  • You would need to setup 2 ports for SSH due to Capistrano issue:
vi /etc/ssh/sshd_config

# Uncomment Port 22
# Add Port 2222 in the second line

service sshd restart
chkconfig sshd on # Make sshd start on boot

Creating Snapshot

  • In running machine (CentOS Instance), go to Machine > Take Snapshot...
  • A snapshot of the current setup is created.
  • You can now mess with the instance :)
  • To return to the this snapshot, you simply go to VirtualBox Manager, click on the Snapshot (tab on the top right) and right-click on the snapshot to restore it.

Tips

  • To shutdown CentOS, shutdown -b now
  • You have selected the annoying mouse capture, you can disable it with VBoxManage modifyvm "your-host-name" --mouse usbmultitouch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment