A basic Ubuntu 14.04 Vagrant set up with nginx, mysql and nodejs
##Requirements
- VirtualBox - Free virtualization software Download Virtualbox
- Vagrant 1.3+ - Tool for working with virtualbox images Download Vagrant
- Git - Source Control Management Download Git
##Setup
- Clone this repository
https://github.com/tbremer/LEMN.git - Run
vagrant upinside the newly created directory (the first time you run vagrant it will need to fetch the virtual box image which is ~300mb so depending on your download speed this could take some time) - Vagrant will then use puppet and bash scripts to provision the base virtual box with our LEMN Stack.
- Once vagrant box is up you can either navigate to your now working server by going to: http://localhost:8888 or modifying your
/etc/hostsfile and add mapping to your domain that is consistent with your server alias:
# FILE: /etc/hosts
# ADDED LEMN DOMAINS
127.0.0.1 local.example.comWhere in your /etc/nginx/sites-availble/example file you have: server_name local.example.com
Some basic information on interacting with the vagrant box:
- 8888 - nginx base
- 8889 - mysql
- User: root
- Password: blank
- Database: database
- Express *server & router (homepage, npmjs, github)
- Winston server logging (npmjs, github)
- Forever continuous running (npmjs, github)
- mysql node mysql interface (npmjs, github)
Included is one ready server setup, if you add more you will have to provision LEMN again. vagrant provision while box is running.
We use nginx as a proxy so you can run multiple node apps within one virtual environment (similar to how one would run a production server).
#FILE: /etc/nginx/sites-available/example
server {
listen 80;
charset utf-8;
server_name local.example.com
~local.example.([0-9\.]+).xip.io #for testing on mobile devices
example.com;
root /var/www/example;
access_log /var/www/example/logs/access.log;
error_log /var/www/example/logs/error.log;
include global/global.conf;
location / {
proxy_pass http://127.0.0.1:3000/;
proxy_redirect off;
}
}
Vagrant is very well documented but here are a few common commands:
vagrant upstarts the virtual machine and provisions itvagrant suspendwill essentially put the machine to 'sleep' withvagrant resumewaking it back upvagrant haltattempts a graceful shutdown of the machine and will need to be brought back withvagrant upvagrant sshgives you shell access to the virtual machinevagrant destroyremoves all known information about this box (keeps your www folder).
Table of Contents By: DocToc && Markdown Preview By: StackEdit.io
