Search

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

Vagrant Provisioning – Installing PHP and MySQL

In this Vagrant provisioning tutorial let’s review how to make basic software provisioning for the Vagrant server.

If you don’t know how to install Vagrant, please consider watching the previous lesson:

Vagrant provisioning

So basically, there are two major steps.

  1. We need to create a file where we can specify the necessary applications that we want to get installed.
  2. We need to include this file into Vagrant configuration, so every time when Vagrant starts, it will make sure that necessary applications are installed.

Let’s create a new folder in the root directory of Vagrant:

mkdir environment

Let’s go to this folder:

cd environment

Let’s create the new file, a command called “bootstrap.sh”. The command is:

touch bootstrap.sh

Now we should add the software applications that we want to be installed into this file.

In our example, we are going to install PHP and MySQL server.

So, open this file with a text editor such as Notepad++ or use the command line editor as Vi. If you’d like to continue with the command line, follow the below:

vi bootstrap.sh

To enter insert mode, type: i

And add the list of required applications. In our case, we are going to add PHP and MySQL:

#!/usr/bin/env bash 
apt-update 
apt- install -y php 
apt-install -y mysql-serve

Done with editing? Click Esc and then Shift + “:”. Type “WQ” and press Enter to Save and Exit for Vi editor. Now let’s return to the root folder of Vagrant installation, command:

..\

And edit the file “Vagrant”. Open it as you did in the step above and scroll to the very bottom.
Add the following code before the “end” last string in the file:

config.vm.provision :shell, path: "environment/bootstrap.sh"

This will help us to include the file with the required applications. Finally, execute the command to rebuild the Vagrant with the new configuration.

vagrant reload --provision

Wait for a while…

Login to Vagrant using the command below to confirm that necessary applications are installed:

vagrant ssh

Done

Other materials to consider:

Tags: Vagrant
Leave a Reply

Alex Kostritsa

About author
My name is Alex. For more than 10 last years I've been worked in the role of Project Manager in an Agile environment. I have experience working with different business domains including e-commerce, social networks, and gambling. As a Software Manager, I try to keep myself tuned and continue self-development.
View all posts (20)
  • Odessa, Ukraine