Bilal Shafiq



10. HANDS-ON TUTORIAL: Deploying a full-stack application on Ubuntu

10. HANDS-ON TUTORIAL: Deploying a full-stack application on Ubuntu

Using AWS to deploy a Flask App with MySQL on Ubuntu 22.04 LTS in an EC2 Instance using Visual Studio Code

Bilal Shafiq's photo
Bilal Shafiq
·Jan 17, 2023·

2 min read

Table of contents

Tools Utilised:

  • Ubuntu

  • Git

  • GitHub

  • venv

  • Python

  • Flask

  • pip3

  • MySQL

Step-by-Step Guide

1. Update and install the necessary packages

sudo apt update && sudo apt install pip mysql-server python3-virtualenv -y

2. Clone the repo & cd into the directory

git clone && cd DevOps-Project-1

3. Initiate the virtual environment

virtualenv venv

4. Activate the virtual environment

source venv/bin/activate

5. Install the requirements

pip3 install -r application/requirements.txt

6. Log into MySQL

sudo mysql -u root

7. Create the user which matches what is written in

CREATE USER 'bilalhalal'@'localhost' IDENTIFIED BY 'password';

8. Grant the necessary privileges to the newly created user

GRANT ALL PRIVILEGES ON *.* TO 'bilalhalal'@'localhost';

9. Flush the privileges to update the privileges table


10. Create the database which matches the database name written in

CREATE DATABASE halalworlddb;

11. Exit out of MySQL


12. Create the tables


13. Find your public IP


14. Start the app using Python


15. Enter your public IP in your browser on port 5000


16. Test the application

Clean Up

17. Stop the app correctly (using CTRL+Z will leave the process running)


18. Deactivate the virtual environment


Did you find this article valuable?

Support Bilal Shafiq by becoming a sponsor. Any amount is appreciated!

See recent sponsors Learn more about Hashnode Sponsors
Share this