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 up
inside 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/hosts
file 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.com
Where 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 up
starts the virtual machine and provisions itvagrant suspend
will essentially put the machine to 'sleep' withvagrant resume
waking it back upvagrant halt
attempts a graceful shutdown of the machine and will need to be brought back withvagrant up
vagrant ssh
gives you shell access to the virtual machinevagrant destroy
removes all known information about this box (keeps your www folder).
Table of Contents By: DocToc && Markdown Preview By: StackEdit.io