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
- Install Python Manager:
- Log in to aaPanel.
- Go to Software Store, find Python Project Manager, and install it.
- Upload Project Files:
- Use the aaPanel File Manager to upload your Masonite project files to a directory (e.g.,
/www/wwwroot/masonite-app).
- Use the aaPanel File Manager to upload your Masonite project files to a directory (e.g.,
- 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(usuallyapp/wsgi.pyor 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.
- Configure Environment Variables & Database:
- In the project settings in the Python Manager, ensure the
.envfile is configured correctly for your database (MySQL/PostgreSQL) and that theAPP_URLmatches your domain.
- In the project settings in the Python Manager, ensure the
- Run Migrations & Start:
- Use the terminal in aaPanel or the command line in the project manager to run Masonite commands:
craft migrate - Restart the application in the Python Manager to apply changes.
- Use the terminal in aaPanel or the command line in the project manager to run Masonite commands:
- 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