In Part 1, we installed Vagrant with only Ubuntu. See:
Part 1: Gettng Started with Vagrant on Windows 7 PC
In this tutorial, we will be installing Vagrant along with a DLAMP stack. (Drupal/Linux/Apache/PHP/mySQL) You will need to have VirtualBox, Git and Putty installed.
Requirements:
A hard connection to the Internet
VirtualBox needs to be installed.
Git needs to be installed.
Putty needs to be installed. (
putty-0.62-installer.exe)
Recommended: 8 GB RAM is recommended to run VirtualBox on Windows PCs
We will be using a chef script written by Jeff Eaton to download the base box, precise32, instead of using lucid32 like the example in Part 1.
1. Download and install VirtualBox from
https://www.virtualbox.org/wiki/Downloads
Start VirtualBox.
2. Download and install the latest version of Vagrant from
http://downloads.vagrantup.com. For this tutorial, we will use version 1.0.6.
Windows users, download Vagrant.msi
Open Windows cmd prompt
-
For Windows 8, press Windows key and then press “R” key. This will open the RUN dialog box for you. Type “cmd” and press Enter.
Note: I typed vagrant command and I got the error message saying, ‘vagrant’ command not recognized. It was not added to the Path during install. Restarting your computer may help to refresh the path.
Change directory to C:\vagrant\vagrant\bin
Then type the following commands:
C:\vagrant\vagrant\bin> vagrant box add lucid32
http://files.vagrantup.com/lucid32.box
C:\vagrant\vagrant\bin> vagrant init lucid32
C:\vagrant\vagrant\bin> vagrant up
3. In Windows, go to C:/Users/User>
> mkdir workflow
4. Download Git for Windows here:
http://code.google.com/p/msysgit/downloads/list
See tutorial on
How to Install Git in Windows 7 PC.
Download Vagrant Chef script using Git
Open Git-Bash and type the following commands:
$ cd C:/Users/User/workflow
$ git clone
https://github.com/eaton/vagrant-chef-dlamp
This step creates a directory called vagrant-chef-dlamp and downloads a git repo from github.com
6. Edit Vagrantfile
In order for this chef script to work on Wndows 7, you need to make the following edits in a file called Vagrantfile
Line 24 should be: config.vm.forward_port(80,8888)
Line 29 should be: config.vm.share_folder(“v-root”, “/vagrant”, “.” :nfs => FALSE)
7. Open your text editor in Windows and edit /etc/hosts file
10.0.0.10 dev-site.vm
Note: Windows 8 prevents you from editing hosts file. Follow these instructions:
http://windows8transfer.com/windows-8-transfer/editing-hosts-file-in-windows-8-consumer-preview/
8. Shut down any other instances of Vagrant
Use Windows cmd prompt
C:/Users/User>
C:/Users/User> cd workflow
C:/Users/User> cd vagrant-chef-dlamp
7. Type the following:
C:/Users/User/workflow/vagrant-chef-dlamp> vagrant destroy
C:/Users/User/workflow/vagrant-chef-dlamp > vagrant up
Note: It takes about 30 minutes to install everything, depending on the speed of your Internet connection.
8. You will now see the new Vagrant instance running in your VirtualBox
See screenshot
9. Create a Shared folder - shared between Windows and Vagrant DLAMP server
In Windows cmd prompt:
C:/Users/User/workflow/vagrant-chef-dlamp> mkdir public
10. Open Putty
Hostname: 127.0.0.1
Port: 2222
You will see the following message:
Warning – Potential Security Breach
Server’s host key does not match the one Putty has cached.
Blah, Blah.
Click Yes.
Login: vagrant
Password: vagrant
$ cd /vagrant/public
10. Create a database using command line mysql
$ mysql –u root –p
Enter root for password
mysql> create database d7start;
mysql > show databases
mysql> exit
11. Go to
http://drushmake.me and create your drush make file.
Download it and save it to C:/Users/SWD/workflow/vagrant-chef-dlamp/public
Name it simple-seven.make or starter.make
12. Back to Putty
Run Drush make to download Drupal core and modules
$ drush make simple-seven.make
$ drush site-install - -db-url=mysql://root:root@localhost/dbname
Note: Drushmake.me generates a drush make file with several bugs. This line
projects[drupal][version] = 7
should be
projects[drupal][version] = 7.19
or
projects[] = drupal
Be sure to write down the password that the Drush make file generates for you
Login: admin
Password: Uy9wbAkXdF
13. Here are some drush commands
Drush dl modulename1 for download
Drush en modulename1 for enable
Drush pm-disable modulename1 for disable
$ drush dl views, views_ui
$ drush en views, views_ui
$ drush pm-disable overlay, toolbar
To recreate an existing Drupal site:
- You can use FTP or WINscp – secure ftp software to copy over the files directory
Or use scp command to copy files directory
- Use Backup Migrate module to import your site database
14. Open your browser and type in
http://dev-site.vm to see your Drupal site
C. Shutting down
When you exit and turn off VirtualBox be sure to Save the State
NOTES:
1. Open VirtualBox
Start vagrant instance
It opens a terminal window and asks me to login – don’t
2. Use Putty to SSH in
Host Name: 127.0.0.1
Port: 2222
Login: vagrant
Pswd: vagrant
3. cd /vagrant/public
- be sure to use forward slashes
Notes:
-
This chef script provided by Jeff Eaton of Lullabot.com creates one Drupal site or a multi-site. You can install VirtualMin or WebMin to add virtual hosts to create multiple Drupal sites.
-
You will need to learn Linux command line to manage your new server. It does not come with a GUI
-
You have the option to install additional software such as phpMyAdmin and Vim editor
Comments
Typo?
No information.
Thank you for your questions.
I changed those lines in the vagrant file to get the chef script to work on a Windows PC. The script was originally set up for Macs. I'm sorry that I couldn't help you more. I refer you to VagrantUp.com for more information on how to setup instances of Vagrant. I also found it confusing and don't use Vagrant for my development server. I recommend XAMPP. It's a free download: http://www.apachefriends.org/en/xampp.html