Skip to main content

Running a Python Masonite application in aaPanel

Running a Python Masonite application in aaPanel involves installing the Python manager, setting up a virtual environment, installing dependencies, and configuring a WSGI server (like Gunicorn) behind Nginx. Use the "Python Project" management feature in aaPanel to handle the environment, dependencies, and reverse proxy configuration seamlessly. 

Step-by-Step Deployment Guide
  1. Install Python Manager:
    • Log in to aaPanel.
    • Go to Software Store, find Python Project Manager, and install it.
  2. Upload Project Files:
    • Use the aaPanel File Manager to upload your Masonite project files to a directory (e.g., /www/wwwroot/masonite-app).
  3. Configure Project in Python Manager:
    • Open Python Project Manager.
    • Click Add Project.
    • Project Name: Enter a name.
    • Path: Select the folder where you uploaded the Masonite app.
    • Python Version: Select Python 3.8+ (recommended for Masonite).
    • Framework: Choose "Masonite" (or "Flask/WSGI" if Masonite isn't listed, as it's WSGI compatible).
    • Startup File/Script: Point to wsgi.py (usually app/wsgi.py or similar).
    • Port: Set a port (e.g., 8000).
    • Select "Install Dependencies" to install from requirements.txt.
    • Ensure Binding Domain is filled to map your domain to the app.
  4. Configure Environment Variables & Database:
    • In the project settings in the Python Manager, ensure the .env file is configured correctly for your database (MySQL/PostgreSQL) and that the APP_URL matches your domain.
  5. Run Migrations & Start:
    • Use the terminal in aaPanel or the command line in the project manager to run Masonite commands:
      bash
      craft migrate
      
    • Restart the application in the Python Manager to apply changes.
  6. Setup Nginx Reverse Proxy:
    • The Python Manager should automatically create an Nginx configuration that proxies requests from port 80/443 to your Python app port (e.g., 8000). 
If the app fails to start, check the logs in the Python Project Manager to resolve dependency or environment issues