Emulate Staging Servers W/ Vagrant, CentOS & LAMP PHP 5.6

Post on 27-Jun-2015

339 views 3 download

Tags:

description

Get your local development environment up, running, and closely matching your production server is less than 30 minutes with vagrant.

Transcript of Emulate Staging Servers W/ Vagrant, CentOS & LAMP PHP 5.6

Emulating Staging Servers

w/ über-awesome Vagrant, CentOS, & LAMP

You need to learn Vagrant

NOWNo Excuses

$ mkdir my-vagrant-installs # or whatever$ vagrant init chef/centos-6.5$ vagrant up$ vagrant ssh

Vagrant...the best thing since peanut butter and jelly

So what is Vagrant

No More● “It works on my machine”● I can’t install that on my shared host● Do they have that on Xampp?● Do they have that package for my operating

system?

But… but…

...there’s port, homebrew, heroku

Yeah that’s true. But let me enlighten you.

Can port do this?

Strap a squirrel to a rocket ship and launch it to Greenland?

Vagrant can’t do thateither BUT it can:

● create a base Linux server using your favorite flavor (Ubuntu, CentOS, Debian, others)

● run set-up scripts (provisioning scripts)● set up port forwarding● allow tinkering with anything linux related, breaking it,

destroying it, and starting from scratch again● and much much more for an easy payment of...

A few lines of Ruby code and some shell commands

More Reasons● try things that will break your production

server without the heart attacks● having a virtualized server locally can be

much faster and convenient for development● it’s the closest thing to your actual production

server so dev/prod parity is much more realistic

Vagrant is Digital Nomad FriendlyNo Internet or sucky connection, No problem.

Staging Server vs VagrantVagrant is just another VPS living inside of your computer. So you could treat it as such.

● VirtualHosts● SSH● SSL● Node.js, Python, Ruby, Clojure, Nginx, whatever

CentOS, PHP 5.6, Apache, and Working Dev Environment in under 10 minutes

$ vagrant init chef/centos-6.5A `Vagrantfile` has been placed in this directory. You

are now

ready to `vagrant up` your first virtual environment!

Please read

the comments in the Vagrantfile as well as

documentation on

`vagrantup.com` for more information on using Vagrant.

$ vagrant up$ vagrant ssh

# make sure httpd is started after a restart$ chkconfig httpd on$ service iptables stop # turn off firewall (dev)$ exit$ exit

# now we’re back on our host machine$ vim Vagrantfile

# uncomment config.vm.network "forwarded_port", guest: 80, host: 8080# change the host port to something else if it conflicts

$ vagrant reload$ curl localhost:8080hello

Sexy Right?

Taking it one step further

# we’re on our host machine$ echo '<?php echo "hello on my host machine\n";' > index.php$ vagrant ssh$ sudo rm -rf /var/www/html$ sudo ln -s /vagrant /var/www/html

$ exit

$ curl localhost:8080

Other cool features● sharing your environment and exposing it

with a url to a co-worker/friend/evil h4x0r with vagrant connect

● spooling up AWS/DigitalOcean/Rackspace instances

● using configuration management packages like puppet, chef, and ansible

● creating your own base box

http://docs.vagrantup.com/v2/

Where’s my box...ershttp://www.vagrantbox.es

http://www.vagrantcloud.com

Online Configuratorshttps://puphpet.com

http://rove.io

Questions!?Sock ‘em to me

Follow me y’all @2upmedia

http://linkedin.com/in/2upmedia

https://coderwall.com/p/u/2upmedia