Vagrant LAMP Stack setup

I liked WAMP very much, but after discovering Vagrant I never will go back to WAMP.

What is Vagrant used for?

Create and configure lightweight, reproducible, and portable development environments.

In my words: Vagrant is used to simulate a real server environment to interact with.

In this article I want to share my basic setup.

Here is a quick introduction to vagrant if you don’t know what it is:

When I need a LAMP stack (on windows) for development, I use this vagrant box:

If gives you a web server environment (LAMP stack) with the following software already installed and configured:

  • Ubuntu
  • Apache
  • MySQL
  • PHP
  • PHPMyAdmin
  • Git

I usually create a new directory for my vagrant box and inside this directory a “html” directory which will be the server’s document root later.

Then I initialize my vagrant box with:

A short message appears, telling me that the Vagrantfile has been placed in this directory.

After this, I open the the Vagrantfile and add the following configurations at the end of this file (before “end”):

Those settings tell vagrant, to make the server available on this ip and to map the “./html” folder on my host system to my document root of my guest system (vagrant box).

If I want to change the memory limit:

I can start the vagrant box by typing:

If this is the first time using this vagrant box, vagrant will download the box initially (will take some minutes).

Now I have a fully functional web server under:

I put my projects inside the “html” directory, and they are ready to work with.

To access the server with ssh, I start PuTTy (on a windows host) and enter the following connection details (vagrant will tell you all details in the command-line)

When I am using a linux host, I just type:

To shutdown the server, I type:

All other information about this vagrant box (connection to mysql, phpmyadmin) are written down here:

If you like, check out my own base box:

2 thoughts on “Vagrant LAMP Stack setup”

  1. The only problem with avenuefactory/lamp is that it doesn’t start Apache2 when it boots, and for whatever reason, I can’t find any way to make that work. No solutions I’ve found work. I can load it manually with apachectl start but I cant get it to load on boot. Period. Going with a different box 🙁

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.