Now that we have our development server up and running I'm going to explain
about how we can use our development server when we're working on our project
so because the development server is a virtual machine on our computer by
default the file system is not synchronized that means that all of the
files on our development server are different from the files on our local
machine
vagrant works by creating a synchronized directory on our vagrant
server that updates itself with all of the files in our local project every
time we make changes
if you load up the terminal or the git bash window and then
connect to our vagrant server I'll explain to you how this works once
you're connected to the vagrant server type cd /vagrant this will switch you
to the vagrant directory on our server
now everything in this vagrant directory
is synchronized with everything in our project folder so if we create a new
file in our vagrant project called test so if we do touch test.txt touch is the
Linux command for creating empty files hit enter you can see that this test dot
txt is automatically listed in our project folder on our local machine so
all of the files are synchronized if you type LS on our server this will list all
of the files that are accessible and you can see that this list here matches the
list here by default when you type LS hidden files are excluded so you can't
see dot git or dot vagrant but you can see license readme dot md text dot txt
the ubuntu log file and the vagrant file
if we go and remove this text file from
our project in atom editor and then go back to our terminal and type LS you can
see that the file has been deleted so the synchronization works both ways from
the server to our host and from our host to the server
okay so how do you
run code from our project in our vagrant server I'll show
you with a simple hello world script so if you head over to our profiles REST
API project in Atom create a new file called hello underscore world dot py hit
enter and then we'll just create a simple Python hello world script by
typing print Open bracket quote hello world exclamation mark save that file
now let's head over to our terminal make sure we're connected to our vagrant
server type LS and you should see the hello world script output here now if we
want to run this code on our server all you need to do is type Python hello
world dot py hit enter and that's how you run the hello world script on our
server finally let's go ahead and commit and
push our changes to github
so in order to use git we need to switch back to our
local machine terminal so either create a new tab by doing command T or if
you're on Windows create a new separate git bash window
then in the window let's
type git add dot to add any new files that we've created
and then let's type
git commit - am and then the git commit message which is configured
vagrant and set up hello world script
hit enter and you can see the files have
been add now lets push these files to github by doing git push origin
this will push all
of the latest changes that we've made to github so they'll be accessible in our
project