Emulate Staging Servers W/ Vagrant, CentOS & LAMP PHP 5.6
-
Upload
jorge-colon -
Category
Technology
-
view
339 -
download
3
description
Transcript of Emulate Staging Servers W/ Vagrant, CentOS & LAMP PHP 5.6
Emulating Staging Servers
w/ über-awesome Vagrant, CentOS, & LAMP
http://bitly.com/2upmedia-vagrantworkshop
You need to learn Vagrant
NOWNo Excuses
Download vagrant: http://www.vagrantup.com/downloads.html
and
https://www.virtualbox.org/wiki/Downloads
$ 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
Download vagrant: http://www.vagrantup.com/downloads.html
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
$ sudo su$ rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm$ yum install -y apache php56w php56w-common
$ echo '<?php echo "hello\n";' > /var/www/html/index.php$ service httpd start$ curl localhosthello
# 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
Where’s my box...ershttp://www.vagrantbox.es
http://www.vagrantcloud.com
Online Configuratorshttps://puphpet.com
http://rove.io
Common Issueshttp://stackoverflow.com/questions/22575261/vagrant-stuck-connection-timeout-retrying
http://stackoverflow.com/questions/5984217/vagrants-port-forwarding-not-working
http://stackoverflow.com/questions/9885108/ssh-to-vagrant-box-in-windows
http://stackoverflow.com/questions/21195635/nginx-not-picking-up-changes-in-vagrant-synced-folder
Questions!?Sock ‘em to me
Follow me y’all @2upmedia
http://linkedin.com/in/2upmedia
https://coderwall.com/p/u/2upmedia