How to update your website after deployment

So basically this is kind of documentation for my future self and I’m sure it will be quite helpful to others.

Coming from a non-traditional background, I started my software engineering journey recently and graduated from a coding bootcamp where I built my first full-stack web application. But after I deployed it on AWS Lightsail I had no idea how to make changes to it.

I was looking for a simple and concise way to do it and stumbled upon shell scripts. You know, those files with a .sh extension that you can run in your Terminal.

As I was researching it, I was fascinated by the simplicity and straightforwardness of the approach: you basically set up several commands for the computer to perform, save them all in one file and call the file with one line of code when you need it. Boom!

Suddenly an old anecdote about a developer who wrote scrips for all the repetitive tasks that would take over 90 seconds to complete (even for brewing a cup of coffee) — started to make sense to me.

Requirements and steps:

At this point, your app must be up and running and just waiting for you to make changes. This means you should:

  • have access to your remote server (should be able to log into it)
  • have a folder there with your cloned repo

In my case, I had a web app running on a Flask server. I deployed on AWS Lightsail using an instance of an Ubuntu 18.04 machine and Nginx as a proxy. My code was sitting in a GitHub repo.

Steps / pseudocode:

  1. Get a copy of the latest commit in your repo (GitHub)
  2. Restart the server (Flask)
  3. Restart the proxy/load balancer (Nginx)


📌 Navigate to the folder with your code and create a new file called there:

ubuntu@aws:~$ cd mywebsiteubuntu@aws:~/mywebsite$ touch

📌 Use Nano, a command-line editor for Linux machines to update your file:

ubuntu@aws:~/mywebsite$ nano

📌 When prompted to edit your file, you need to enter the list of commands that will execute every time when you want to update (see “Steps” above). In my case it was:

cd ~/mywebsite                           # go to my project’s folderecho “Update Git Repo”git pull origin master         # pull the latest commit from my repoecho "Update Nginx Config"cp <nginx target file> <nginx destination>       # copy nginx configecho "Update Flask Config"cp <flask target file> <flask destination>       # copy flask configecho “Restart Flask”sudo systemctl restart flask          # restart server as super-userecho “Reload Nginx”sudo systemctl reload nginx            # restart proxy as super-userecho “All Done”cd —                      # go back to the directory you were before

📌 Make sure not to leave any blank lines after the last line of scripts so your cursor will sit at the end of the last line of code.

📌 Hit Control X and Y (macOS) to save changes.

📌 When done you can cat to view the file in the command line and make sure that everything you’ve entered is in the file now.

You’re all set!

A few notes here:

  1. echo commands: completely optional (yet helpful) and only needed to explicitly report the progress every step of the way
  2. nginx and flask config files: you should have proxy and server configuration files. For me, it was Nginx and Flask configuration files that I had in my GitHub repo, and they’re being copied with every git pull command. If I were to make any changes to the configuration I would want to apply those changes to the live files. So basically what I’m saying

computer, when you’re done copying the latest commit from GitHub, take the config files and update them in directories where they belong on my Ubuntu

In my case, Flask config file was sitting in the/etc/nginx/sites-enabled folder while Nginx was sitting in the /etc/systemd/system folder. However, the “dummy” config files that I copied from GitHub would sit it the ~/mywebsite/config folder, so those two cp commands look like this

cp ./config/nginx.conf /etc/nginx/sites-enabled/mywebsite.confcp ./config/flask.service /etc/systemd/system/flask.service


Every time, after you push changes to your remote repo (GitHub for example) you can log into your machine and launch this file with

ubuntu@aws:~$ cd mywebsiteubuntu@aws:~/mywebsite$ sh

The updates should appear in a few minutes!

As I said, I’m a beginner, and it took me quite some time to deploy and then learn how to make changes to what I deployed earlier. I’m hoping this could be helpful to someone like me who is making their first steps into the marvelous world of technology.

Let me know if you have any questions or comments below!

I’m a former Technical PM transitioning to Software Engineering. I write about my journey to the tech world without a CS degree