Simple Vagrant/LAMP Set Up
=====
I have use Vagrant a couple of times for projects in which it has become incredibly useful in set up and operation. Its nice for me because I like to keep my computer environment clean and not possibly filled with errors that could potentially harm my computer. Therefore, having a virtual machine environment works for me. I have also used it for some of my college classes which require the LAMP stack, in this case, I just have to run vagrant up
which loads up the stack and my projects are all ready to go. But, vagrant boxes can be used for anything you can think of not just LAMP stacks. Any type of development environment can work.
I have also included a LAMP Stack set up script which I have written which works as of 3/10/15. Let me know if I have to change it. It automatically installs LAMP including phpmyadmin with default username: root and password: password. This is currently configured to be the most basic of configuration and has not been tested or meant for anything for production in terms of security etc.. Use this as a guide on how to set up a vagrant machine and LAMP stack if required.
Remember, you can take snapshots of your virtual machine in virtualbox. This way, it saves the state of the machine at that moment in time so you can revert back to it in case shit hits the fan.
Set Up Vagrant:
- install Vagrant
- install virtual box
- make a project directory
- cd into directory
- Go to https://atlas.hashicorp.com/boxes/search to find a box
- Copy name of box
- (If a box hasn't been added) run in project directory
vagrant box add (NAME i.e. ubuntu/trusty64)
- While still in project directory,
vagrant init
- Edit Vagrantfile
- Open up vagrant file within that project directory
- uncomment
config.vm.network "forwarded_port", guest: 80, host: 8080
- uncomment
config.vm.box = "(BOX NAME i.e. ubuntu/trusty64)"
- uncomment
- Save File
vagrant up
- Finished (Optional Steps Below for Entering Vagrant Machine)
vagrant ssh
- cd into /vagrant folder
Operation:
- cd into project directory
vagrant up
(if not running)vagrant halt
(if running)
Commands:
vagrant up
vagrant halt
vagrant ssh
vagrant destroy
exit
(exit vagrant ssh session)
#####How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu:
#####Or use my script to do the dirty work for you!
#####Reid's LAMP Vagrant Script:
===
- Make sure in Project Directory which is shared in the vagrant machine
vagrant ssh
- cd into the /vagrant directory
- run
sh LAMPVagrantSetupScript.sh
- Default Passwords for everything is root & password
- Restart Machine (
exit
,vagrant halt
,vagrant up
)
===
- MYSQL:
root
password
- PHPMYADMIN:
root
password
#####Random Notes:
- http://localhost:8080/
- http://localhost:8080/vagrant/
ifconfig eth0 | grep inet | awk '{ print $2 }'
- Symlink /vagrant folder to /var/www/html/ directory:
sudo ln -s /vagrant/ /var/www/html/vagrant
#####Sources: