Skip to content

Categories:

Set up a Complete PHP Environment on Linus with Vagrant

Guest Post by Ran Argaman

This post will explain how to install a fully functional Linux PHP environment using Vagrant and Oracle’s VirtualBox on a windows host machine.

“Host” stands for the machine that the virtual machines are running on, not necessary to be a physical machine. We will use Microsoft’s Windows 7 on this example.

Linux virtual environments on Windows is a very good solution for developers who wants to enjoy the benefits of both worlds.

The powerful and scalability of the Linux and open source in general and the “normal” UI of Microsoft.

The first step is to download and install VirtualBox (https://www.virtualbox.org) and Vagrant (http://www.vagrantup.com). The next step is to create your Virtual Machine using Vagrant.

My suggestion is to create a folder that will contain all your VMs, something like c:vms

Now, let’s create a new directory, for this example I’m going to use c:vmszsdev1
cd into this folder and run the following command:

vagrant init

Now, we have to add a new “Box” instance.

My suggestion is to download the box file to your hard drive and not to download every time you create a VM.

You can download all flavors of Linux from Vagrant servers. For this example I’m going to use Ubuntu Precise32 (http://files.vagrantup.com/precise32.box). Download it to c:vmsprecise32.box.

Now, it our new Vagrant folder (c:vmszsdev1) run the following command:

vagrant box add zsdev1 c:vmsprecise32.box

Now open the c:vmszsdev1Vagrantfile and edit as follow:
Change the “config.vm.box” value from “base” to “zsdev1″ and uncomment the following line:

config.vm.network :private_network, ip: “192.168.33.10″

You can of course choose any other IP addess you want for your VM, just remember that if you are running more than one VM you have to give them different IP addresses and don’t confuse the vagrant SSH ports and the private network IPs.

Now let’s boot our new VM:

vagrant up

If you don’t know how to connect you can use the “vagrant ssh” command.

You can find more details and troubleshooting scenarios regarding Vagrant onĀ http://www.vagrantup.com.

Remember that when you connect to Vagrant provisioned VM you have to connect to 127.0.0.1 and use a “special” port like 2222 or 2200 and not to the private IP we configured before.

After connecting to the VM using SSH (putty or any other SSH client), let’s download and install Zend Server 6.1

On your home folder run the following commands:

vagrant@precise32:~$ wget http://downloads.zend.com/zendserver/6.1.0/ZendServer-6.1.0-RepositoryInstaller-linux.tar.gz
vagrant@precise32:~$ tar zxf ./ZendServer-6.1.0-RepositoryInstaller-linux.tar.gz
vagrant@precise32:~$ cd ./ZendServer-RepositoryInstaller-linux/
vagrant@precise32:~/ZendServer-RepositoryInstaller-linux$ sudo ./install_zs.sh 5.4

Now you can open your Zend Server GUI on https://192.168.33.10:10082/ or http://192.168.33.10:10081/

That’s it!

The virtual machine we created is almost the same as a physical Linux machine so you can add MySQL, Mongo or any other database software and you can have your LAMP stack up in a few minutes.

Read more : Set up a Complete PHP Environment on Linus with Vagrant

Posted in Uncategorized.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.