Giter Club home page Giter Club logo

vagrant-vemp's Introduction

Vemp Box

Vagrant - (e)Nginx - MySQL - PHP

Why use VEMP?

If you want to see your web projects run locally without worrying about the configuration details of the webwerver then VEMP is here for you. Start a virtual machine which can handle all your projects and manage all files and configurations without even logging in the guest machine.

Installation

  1. Install VirtualBox for your platform.
  2. Install the latest version of Vagrant for your platform
  3. Create the directory of the project mkdir vemp
  4. cd vemp
  5. Init git git init
  6. Add repository git remote add upstream https://github.com/georgeyord/vagrant-vemp.git
  7. Fetch all branches git fetch upstream
  8. Check out master branch: checkout upstream/master -b master`

In the repository directory, initialze the vagrant box. Run:

> cd vagrant
> vagrant up

Doing this the first time will take a few minutes as the operating system and all the required packages will be downloaded and installed. Subsequent runs will be really quicker, promise!

Reasons to fail and solutions

Vagrant box exists but still you want to replace it with a different box

Run the following command BEFORE the commands above:

> vagrant box remove vemp virtualbox

Virtuabox returns error of type VERR_ALREADY_EXISTS

You already have a VM named "vemp". You can either change the name of the new machine to something else (or nothing at all ;-) ) or remove the previous VM from virtualbox application. For 1st option open Vagrantfile and edit "--name", "vemp", in the following line

vb.customize ["modifyvm", :id, "--name", "vemp", "--memory", "4096", "--cpus", 2, "--cpuexecutioncap", "80"]

Change "vemp" to another name or remove both "--name" and "vemp"

Vagrant up fails after "Mounting shared folders"

If Host is a linux machine, make sure that nfs-kernel-server is installed and running. In Ubuntu:

> sudo apt-get install nfs-kernel-server

Vagrant up fails STILL after "Mounting shared folders"

Check that VirtualBox Guest Additions is correctly installed and active in host (solution taken from here)

  • Connect to the guest vagrant ssh
  • Run lsmod | grep vboxsf
    • If that command does not return any output, it means that the VirtualBox Guest Additions are not loaded.
    • If the VirtualBox Guest Additions were previously installed on the machine, you will more than likely be able to rebuild them for the new kernel through the vboxadd initscript, in Ubuntu sudo /etc/init.d/vboxadd setup
    • If the VirtualBox Guest Additions are missing use this guide to install them

Intialization

  1. Host: (optional) Copy id_rsa and id_rsa.pub in vagrant/ssh to use them in Guest
  2. Host: Run cd vagrant/etc/ & cp hosts-example hosts & cd ../.. to copy/activate the basic hosts file
  3. Host: vagrant ssh to SSH into Guest
  4. Guest: Check nginx configuration is loaded correctly sudo nginx -t
  5. Guest: Run ~/bin/myservice res~/bin/myservices restartmv pa to start all the services that depend on external folders
  6. Guest: Get VM's internal IP ~/bin/myip
  7. Host: Open Browser and check the IP you got above returns a page
  8. Host: Get hosts record from above page and add it to host's /etc/hosts file
  9. Host: Open Browser and check any of the domain names from above
  10. Done!

Running

To start the virtual machine use --provision (it is used to start the servies needed after mounting shared folders):

> vagrant up --provision

or use the sh file included:

> ./vempup

A message like the following will be at the end of the script:

> Your internal IP Address is:
> [IP]
> Your external IP Address is:
> [IP]

If you think something went wrong, check vemp.log located at var/log/vemp.log or SSH into the box using:

> vagrant ssh

And try to restart all services > ~/bin/serviceStart

To shutdown the virtual machine use:

> vagrant halt

To suspend the virtual machine use:

> vagrant suspend

To start from scratch (wiping the image) use destroy. A subsequent vagrant up will re-download the packages and stash but it won't have to download the operation system again:

> vagrant destroy

If you don't feel confident that you can open the VirtualBox GUI to see the loading process. To do it uncomment the line # vb.gui = true to vb.gui = true in Vagrantfile.

Add your project

  1. Create a folder in shared/www and add all your project files
  2. Create a vhost configuration file in vagrant/etc/nginx/sites-available
  3. Add you vhost name in vagrant/etc/hosts
  4. Done! Check out how the existing sites are built using partial configuration files located in vagrant/etc/nginx/conf/, they may help you build your own conf file

Folder structure inside "shared" folder

  • Host www Guest /var/www Location of web projects
  • Host mysql Guest /shared/mysql/ Location of MySql databases

Folder structure inside "vagrant" folder

  • Host etc/hosts Guest '/etc/hosts' (through link poinitng to /vagrant/etc/hosts)
  • Host etc/nginx/sites-available Guest '/etc/nginx/sites-available' (through link poinitng to /vagrant/etc/nginx/sites-available)
  • Host var/log/nginx Guest '/var/log/nginx'
  • Host bin Guest '/home/vagrant/bin' SH script to run using ~/bin/[script]
  • Host ssh Guest '/home/vagrant/ssh' SSH keys to use in Guest

Folders structure in guest machine that point to shared folders from host

  • /etc/hosts point to /vagrant/etc/hosts
  • /etc/nginx/sites-available point to /vagrant/etc/nginx/sites-available
  • /etc/nginx/sites-enable point to /vagrant/etc/nginx/sites-available
  • /etc/nginx/conf point to /vagrant/etc/nginx/conf
  • /var/log/nginx point to /vagrant/var/log/nginx

Logs in guest machine

  • /vagrant/var/log/vemp.log (edit Vagrantfile to change)
  • /vagrant/var/log/nginx/access.log (edit vhost files in /etc/nginx/sites-available to change per vhost)
  • /vagrant/var/log/nginx/error.log
  • /vagrant/var/log/xdebug.log (edit /etc/php5/fpm/conf.d/20-xdebug.ini to change)
  • /vagrant/var/log/php5-fpm.log (edit /etc/php5/fpm/php-fpm.conf to change)
  • /var/log/mysql/error.log (edit /etc/mysql/my.cnf to change)
  • /home/vagrant/clarity.log

Credentials

  • Command line & SSH Login : vagrant/vagrant
  • MySql : root/qwerty1

Features

  • php-fpm
  • nginx
  • mysql
  • phpmyadmin (phpmyadmin.ubs.com)
  • phpunit
  • php x-debug
  • java-jdk
  • maven
  • mahout ($MAHOUT_HOME/bin/mahout)
  • ruby rvm
  • memcached
  • mongo
  • clarity (on demand)
  • n4j (on demand)
  • solr (on demand)
  • elasticsearch (on demand)

RAW notes for Windows users

See for more information

vagrant-vemp's People

Contributors

georgeyord avatar

Stargazers

Dave Ferrara avatar

Watchers

 avatar James Cloos avatar

vagrant-vemp's Issues

README.md

"8. Check out master branch: checkout upstream/master -b master`"

should read

"8. Check out master branch: git checkout upstream/master -b master"

403 Forbidden

vagrant up
returns
==> default: Box 'georgeyord/vemp' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
==> default: Loading metadata for box 'georgeyord/vemp'
default: URL: https://vagrantcloud.com/georgeyord/vemp
==> default: Adding box 'georgeyord/vemp' (v0.1) for provider: virtualbox
default: Downloading: https://vagrantcloud.com/georgeyord/vemp/version/1/provider/virtualbox.box
An error occurred while downloading the remote file. The error
message, if any, is reproduced below. Please fix this error and try
again.

The requested URL returned error: 403 Forbidden

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.