So we're going to dig a little bit deeper into our vagrant file.
We know already that we've got the line that describes the
syntax highlighting and indentation that we need.
But we're now adding to it a variable, we've called this $script,
and this $script then is reading‑in information about
provisioning our operating system.
We're running an apt update to make sure our package cache is up to
date and then going ahead and installing Apache 2.
Now this is just describing our script and storing it in a variable,
it's not implementing the script.
To implement it, we're using our main configuration block.
And we can see we've added in a line config.vm.provision,
and then we're using a shell provisioner.
There are different provisioners that we can use.
We're concentrating on the shell provisioner here. And we
can go through and say it's an inline.
The inline says we described the script inside of our file,
and we make reference to our $script variable.
On top of this, though, we're also doing a couple of other things.
We've got our synced folder,
so this is where we can map a folder on our host machine
through to a folder in our guest machine,
so web is to go through to var/www/html.
This means that we can add in our web content to our web directory.
Ideally, the web directory would probably be a git repository,
so we can download the current content, modify it,
push it back so it can then be used by the production web servers.
The last thing that we're doing is making it easy to access
the web server by mapping port 8080 on our host system
through to the guest and port 80.
One of the things that we would see with synced folders is that
we have to have the Guest Additions installed,
and often, they are not installed.
To ensure that we have it installed, we can use a plugin.
We can list our current plugins.
If we don't have the VB Guest to plug in,
we can go ahead and install then vagrant‑vbguest.
With that done, we can then update our web page,
add in a new index page, either complex or quite simple,
like this.
Once we've done that,
we can make sure that we're working in the Apache directory where the
vagrant file is and then bring up our vagrant virtual machine.
Once the virtual machine has come up,
we can go through and check our port mapping.
We should see that we've got our new mapping from port 8080
on the host through to 80 in the guest.
And then we should be able to connect through to our web server,
seeing our new web page and being able to see that our content
has been added in from our web directory.
Now, as always,
the very best way to learn is to get hands‑on experience yourself.
So come on,
why don't you join me in the next clip where we're going to go through and see this in action.