aster.cloud aster.cloud
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
    • Learning
  • Tools
  • About
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
    • Learning
  • Tools
  • About
aster.cloud aster.cloud
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
    • Learning
  • Tools
  • About
  • Engineering
  • Software Engineering

How-To: Deploy Python Flask applications using NGINX and uWSGI – Installation (Part 1 of 3)

  • aster.cloud
  • November 3, 2022
  • 3 minute read

Completed your Python Flask application? In this series we will be deploying the application on a Ubuntu 22.04 machine. Which you can provision from different Cloud Service Providers like Google Cloud, Microsoft Azure, Amazon Web Service or Digital Ocean.

To create a simple Web/Flask Python application and deploy it on an NGINX server with uWSGI and uWSGI Emperor. This is a 3-part guide. This part covers the Installation of the required packages. It will install the following


Partner with aster.cloud
for your next big idea.
Let us know here.



From our partners:

CITI.IO :: Business. Institutions. Society. Global Political Economy.
CYBERPOGO.COM :: For the Arts, Sciences, and Technology.
DADAHACKS.COM :: Parenting For The Rest Of Us.
ZEDISTA.COM :: Entertainment. Sports. Culture. Escape.
TAKUMAKU.COM :: For The Hearth And Home.
ASTER.CLOUD :: From The Cloud And Beyond.
LIWAIWAI.COM :: Intelligence, Inside and Outside.
GLOBALCLOUDPLATFORMS.COM :: For The World's Computing Needs.
FIREGULAMAN.COM :: For The Fire In The Belly Of The Coder.
ASTERCASTER.COM :: Supra Astra. Beyond The Stars.
BARTDAY.COM :: Prosperity For Everyone.

    • NGINX
    • uWSGI
    • uWSGI-Emperor
    • Flask

It will also cover creation of

    • Virtual Environment
    • Installation of python packages via the requirements.txt

Prerequisites

    • Ubuntu 22.04
    • Python 3.x has been installed. For instructions see here.

Verification

01. Verify that Python and Pip3 has been installed

$ python -V 
# or
$ python3 -V

$ pip -V
# or
$ pip3 -V

Output:

Python 3.10.6

Install Pip and Virtual environment if not yet installed. Execute the following.

$ sudo apt-get install python3-pip -y 
$ sudo apt-get install python3-venv -y

Setup the Python Virtual Environment

01. Create the python virtual environment. In this example we are creating the environment in the user’s home directory. But you can change its location depending on your preference and standards

$ cd ~/ 
$ python3 -m venv geek-venv

02. Move to the virtual environment directory

$ cd geek-venv/bin

03. Under the /bin directory activate the virtual environment using the source command. This will activate the virtual environment

$ source activate

04. Once the virtual environment is activated, use pip command to install the python packages required by your app.

(geek-venv) geek@box:~/geek-venv/bin$ pip install --upgrade pip

05. To deactivate the virtual environment.

(geek-venv) geek@box:~/python3-venv/bin$ deactivate

uWSGI Installation

01. Install the uwsgi.

$ sudo apt-get update

# Minimal Install (Recommended for Production Environment)
$ sudo apt-get install uwsgi uwsgi-plugin-python3 -y
  
# Complete Install (Generally used for Development Environment)
$ sudo apt-get install uwsgi uwsgi-extra uwsgi-plugins-all uwsgi-plugin-python3 -y

If the build-essential package is not installed, install it using the following command.

$ sudo apt-get install build-essential -y 

02. Check and verify the installation

$ uwsgi --version

Output:

Read More  Scheduling A Command In GCP Using Cloud Run And Cloud Schedule

2.0.20-debian

Note: The packages uwsgi-extra and uwsgi-plugins-all are optional packages that ensures that all uwsgi packages are needed during development and might not be needed during production deployments.

03. Install the uwsgi emperor.

Note: Normally, uwsgi is enough for running single app deployment, but we use emperor mode for running single and multi-app deployments. It is a special uWSGI instance that will monitor specific events and will spawn/stop/reload instances on demand.

$ sudo apt-get install uwsgi-emperor -y

uWSGI Directories

Below are the uWSGI directories you have to be wary of, as some of them are the ones you will be troubleshooting if there are any problems.

# uWSGI file system

    ## Default root configuration
      /usr/share/uwsgi/conf/default.ini

    ## Configuration location for applications
      /etc/uwsgi/apps-available
      /etc/uwsgi/apps-enabled

# uWSGI (Emperor) file system

    ## Default root configuration
      /etc/uwsgi-emperor/emperor.ini
    
    ## Configuration location for applications
      /etc/uwsgi-emperor/vassals

    ## Logs
      /var/log/uwsgi/emperor.log

    ## Socket
      /var/run/

Nginx Installation

01. Install the nginx.

# Minimal Install (Recommended for Production Environment)
$ sudo apt-get install nginx nginx-extras

# Complete Install (Generally used For Development Environment)
$ sudo apt-get install nginx-full

02. Verify if NGINX is installed

$ nginx -V

It should show the NGINX version. Sample is below:

nginx version: nginx/1.18.0 (Ubuntu) built with OpenSSL 3.0.2 15 Mar 2022 TLS SNI support enabled configure arguments: –with-cc-opt=’-g -O …

03. To test if nginx is working.

$ curl http://localhost

It should show the NGINX page.

<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

04. Remove the default nginx configuration and restart the NGINX service.

$ sudo rm /etc/nginx/sites-enabled/default 
$ sudo service nginx restart

Execute the following.

$ curl http://localhost

It will return an error that we will fix later.

Read More  Canonical Releases Ubuntu 24.04 LTS Noble Numbat
curl: (7) Failed to connect to localhost port 80 after 0 ms: Connection refused

For enquiries, product placements, sponsorships, and collaborations, connect with us at [email protected]. We'd love to hear from you!

Our humans need coffee too! Your support is highly appreciated, thank you!

aster.cloud

Related Topics
  • Flask
  • Python
  • Tutorials
  • Ubuntu
  • Ubuntu 22.04
  • uWSGI
You May Also Like
Points, Lines and a Question
View Post
  • Architecture
  • Design
  • Engineering
  • People

What Is The Point In Making Points?

  • November 26, 2025
View Post
  • Software Engineering

Embedded Swift Improvements Coming in Swift 6.3

  • November 22, 2025
Visual Studio Code
View Post
  • Software Engineering

Visual Studio 2026 is here: faster, smarter, and a hit with early adopters

  • November 12, 2025
View Post
  • Software Engineering

Introducing Google Gen AI .NET SDK

  • October 24, 2025
View Post
  • Software Engineering

Julia 1.12 Highlights

  • October 13, 2025
View Post
  • Engineering
  • Software Engineering

Development gets better with Age

  • October 9, 2025
View Post
  • Software Engineering

The Growth of the Swift Server Ecosystem

  • September 27, 2025
men with computer website information and chat bubbles vector illustration
View Post
  • Software
  • Software Engineering

What is an ISV (independent software vendor)?

  • August 27, 2025

Stay Connected!
LATEST
  • 1
    Expectations vs. Reality: The AI We Thought We’d Have in 10 Years
    • June 19, 2026
  • digital-nomad-freelancer-worker-2151205464 2
    One paperwork problem – Get your Digital Nomad Visa employment documents fast from UK, EU or Singapore
    • June 16, 2026
  • 3
    Samsung Art Store Brings Art Basel to Homes Worldwide With New Curated Collection
    • June 15, 2026
  • 4
    You Do Not Need to Invest in the IPO of SpaceX, Anthropic, and OpenAI
    • June 10, 2026
  • 5
    The consequences of relying on AI for accurate news
    • June 10, 2026
  • 6
    Connecting AI agents with unstructured data using Google Cloud Storage MCP Servers
    • June 10, 2026
  • 7
    WWDC26: Apple unveils next generation of Apple Intelligence, Siri AI, powerful parental controls, and an expansive set of software improvements
    • June 8, 2026
  • 8
    IBM and Google Cloud Announce Strategic Partnership to Scale AI with Human Expertise and AI‑Powered Delivery
    • June 4, 2026
  • Data center 9
    Data Sovereignty in Spain. It’s Not Just About the Law, It’s About Efficiency
    • June 3, 2026
  • 10
    Ink vs Pixels. What you miss versus what you are actually missing.
    • June 1, 2026
about
Hello World!

We are aster.cloud. We’re created by programmers for programmers.

Our site aims to provide guides, programming tips, reviews, and interesting materials for tech people and those who want to learn in general.

We would like to hear from you.

If you have any feedback, enquiries, or sponsorship request, kindly reach out to us at:

[email protected]
Most Popular
  • 1
    Banks race to patch new cyber vulnerabilities, and other cybersecurity news
    • May 25, 2026
  • pope-leo-xiv-cq5dam-1500.844 2
    Pope Leo XIV to Publish First Encyclical on Artificial Intelligence and Human Dignity on 25 May
    • May 22, 2026
  • 3
    Portfolio to Clients, and is Strengthened by Ongoing Project Glasswing Work
    • May 20, 2026
  • reMarkable Paper Pure 4
    Everything The reMarkable Paper Pure Actually Does
    • May 14, 2026
  • 5
    Scaling cloud and AI: Microsoft Azure’s commitment to Europe’s digital future
    • May 11, 2026
  • /
  • Technology
  • Tools
  • About
  • Contact Us

Input your search keywords and press Enter.