I’ve two server running my PHP application with both server have different LAMP version.
Server A use Centos 7, PHP 5.5 and Maria-DB
Server B use Centos 6.5, PHP 5.3 and Mysql 5.3.3
My development machine using Ubuntu 14, PHP 5.4 and mysql 5.5.
Sometimes it’s a bit difficult to publish my app to both server as they are using different version.
So i decided to use Vagrant on my local machine – to perform the Server A & B running on my local machine, at least i can test my app before publish to both live server.
Here are the steps i do on my local Ubuntu 14:
Then create new folder in my Home:
Then add the box:
vagrant box add nrel/CentOS-6.5-x86_64;
Then start initialize the folder:
vagrant init nrel/CentOS-6.5-x86_64;
You can try to use Provisioning to configure the box environment.
Configure your Vagrantfile as below: (make changes with your environment)
config.vm.box = "fillup/centos-6.5-x86_64-minimal" config.vm.provision :shell, path: "bootstrap.sh" config.vm.network :forwarded_port, guest: 80, host: 4568 config.vm.synced_folder "/var/www", "/var/www"
You will have a shared www folder between local and environment.
Then create file bootstrap.sh, and below just simple example of the content:
yum --quiet -y install httpd-2.2.15 yum --quiet -y install git yum --quiet -y install php-5.3.3-40.el6_6 yum --quiet -y install mysql-server-5.1.73-5.el6_6 mysql-5.1.73-5.el6_6
Save and in the terminal run:
vagrant up –provision
The box will loaded the centos os and the provision setup (run provision one time only, next time just use vagrant up).
*** If you are not using the provision. then you can manual install the apache,php, mysql, redis etc in the centos environment.
Use command below to enter the centos environment:
To exit the ssh, just type exit command.
To stop the vagrant, use below command — it will save all data/configuration and stop the vagrant.
For more details about the vagrant, please click here.