Installing a Python App on Shared Hosting with cPanel

If you’ve ever tinkered with shared hosting, you’ll know that PHP, HTML, JavaScript, and cron jobs can take you pretty far. With those tools alone, you can build small apps, APIs, automation scripts, and even workflow systems. Digging into curl commands and browser network requests lets you mimic most web activity – authentication, tokens, form submissions, etc. – and wire everything together.

But eventually, you’ll hit a wall. A common one is WAF rejection.

What’s WAF Rejection?

A Web Application Firewall (WAF) sits between users (or bots) and a web application. (Meroshare, Cough !!) Instead of filtering network packets like a traditional firewall, it analyzes HTTP/S requests and responses. If it detects something suspicious – say, a crafted API call – it rejects the request.

When that happens, the only way forward is to simulate a real browser session, which is where tools like Python + Selenium shine. That’s why sometimes PHP alone isn’t enough – you need Python. So here’s how you can set up a Python app on cPanel shared hosting.

Step 1: Create a Subdomain

Shared hosting usually only allows one Python app per domain. That’s why you’ll need to create a subdomain first- for example: app.sushilparajuli.com

(Yes, it feels redundant since the subdomain isn’t the actual app folder, but that’s how cPanel is set up.)

Step 2: Create the Python App in cPanel

  • Go to Setup Python App in cPanel.

  • Click Create Application.

  • Choose your Python version.

  • In Application Root, type the folder name for your app (this will be created under your home directory).

  • In Application URL, pick the subdomain you created earlier.

  • For Application Startup File, enter app.py.

  • For Application Entry Point, enter app.

  • Click Create to start the app.

Step 3: Enter the Virtual Environment

At the top of the app settings, cPanel gives you a command like this: source /home/username/path/to/venv/bin/activate

Open the Terminal in cPanel, paste that command, and activate your environment.

Step 4: Install Dependencies

Once inside the virtual environment, upgrade pip and install the libraries you need. For example, to start simple: pip install flask

Step 5: Build Your App

Navigate to your app folder (the one created in Step 2). Edit app.py like this:

            from flask import Flask  

app = Flask(__name__)  

@app.route("/")  
def main():  
    return "Flask is installed and running!"  

if __name__ == "__main__":  
    app.run()  

        

Now edit passenger_wsgi.py:

            import imp  
import os  
import sys  

sys.path.insert(0, os.path.dirname(__file__))  

wsgi = imp.load_source('wsgi', 'app.py')  
application = wsgi.app  

        

Step 6: Restart the App

Go back to the Python app section in cPanel and click Restart. Then visit your subdomain (e.g., https://app.sushilparajuli.com). If everything worked, you should see:

            Flask is installed and running!

        

That’s it – we now have a Python app running on our shared hosting account. From here we can expand into APIs, automation, or even browser-driven scraping that PHP alone can’t handle.