How do I deploy a Python App in cPanel?
Python is a powerful programming language commonly used for web development, scientific computing, data analysis, and more. cPanel makes it easy to deploy Python applications through the Setup Python App feature, allowing you to host your Python applications without needing SSH access. Follow this guide to deploy your Python app in cPanel.
Navigate to cPanel: Locate and click on Setup Python App in the Software section of cPanel.
Click "Create Application": Start the setup process.
Select Python Version: Choose your preferred Python version (e.g., 3.11).
Application Root: Specify a directory name (e.g., python_app) where your app files will be stored.
Application URL: Leave blank to host on the root domain, or enter a subdirectory (e.g., myapp).
Application Startup File: (optional) Input the main .py entry file, used to start your web application.
Application Entry Point: (optional) Specify the name of the wsgi file for your application.
Click "Create" and wait for the environment to initialise.
Open File Manager: Right-click File Manager in cPanel and select "Open Link in New Tab" for easier navigation.
Navigate to Application Root Directory: Open the directory you set as the root (e.g., /python_app).
Upload Files: Add all necessary files for your app, such as manage.py, modules, and any configuration files (e.g., requirements.txt).
Return to Setup Python App: Go back to Setup Python App in cPanel.
Add requirements.txt: Under "Configuration Files," enter requirements.txt, then click Add and Edit to specify all dependencies.
Run Pip Install: Click Run Pip Install to install dependencies from requirements.txt.
If needed, click Add Variable under Environment Variables.
Enter each Variable Name and Value.
Click Done and Save to apply changes.
Click Start Application: Start your app using the Start Application button.
Verify the Application: Open the Application URL in your browser to check if it’s running correctly.
Error Logs: Check the stderr.log file in the app root for troubleshooting.
Stop/Start/Restart Application: Use the buttons in Setup Python App for managing your app.
Change Python Version: Stop the app, select a new version, and restart if necessary.
Following these steps will enable you to deploy your Python app efficiently using cPanel without requiring SSH.
If you have SSH/Terminal access through a Business or Reseller package, you can manage the app directly via the command line. Many users prefer this option for faster or more detailed control over their applications. This feature enables you to work within a secure virtual environment specifically for your app, providing convenient access to command-line tools.
In Setup Python App, click Edit next to your app.
Copy the source command provided next to Enter to the virtual environment.
Open Terminal in cPanel or log in via SSH, paste, and run the command to enter the environment.
If you need help, reach out to our support team or email helpdesk@elitehost.co.za.
Step 1: Create a Python Application
Navigate to cPanel: Locate and click on Setup Python App in the Software section of cPanel.
Click "Create Application": Start the setup process.
Select Python Version: Choose your preferred Python version (e.g., 3.11).
Application Root: Specify a directory name (e.g., python_app) where your app files will be stored.
Application URL: Leave blank to host on the root domain, or enter a subdirectory (e.g., myapp).
Application Startup File: (optional) Input the main .py entry file, used to start your web application.
Application Entry Point: (optional) Specify the name of the wsgi file for your application.
Click "Create" and wait for the environment to initialise.
Step 2: Upload Your Application Files
Open File Manager: Right-click File Manager in cPanel and select "Open Link in New Tab" for easier navigation.
Navigate to Application Root Directory: Open the directory you set as the root (e.g., /python_app).
Upload Files: Add all necessary files for your app, such as manage.py, modules, and any configuration files (e.g., requirements.txt).
Step 3: Install Dependencies
Return to Setup Python App: Go back to Setup Python App in cPanel.
Add requirements.txt: Under "Configuration Files," enter requirements.txt, then click Add and Edit to specify all dependencies.
Run Pip Install: Click Run Pip Install to install dependencies from requirements.txt.
Step 4: Configure Environment Variables (Optional)
If needed, click Add Variable under Environment Variables.
Enter each Variable Name and Value.
Click Done and Save to apply changes.
Step 5: Start the Application
Click Start Application: Start your app using the Start Application button.
Verify the Application: Open the Application URL in your browser to check if it’s running correctly.
Managing and Monitoring the Application
Error Logs: Check the stderr.log file in the app root for troubleshooting.
Stop/Start/Restart Application: Use the buttons in Setup Python App for managing your app.
Change Python Version: Stop the app, select a new version, and restart if necessary.
Following these steps will enable you to deploy your Python app efficiently using cPanel without requiring SSH.
Virtual Environment Command Line Access
If you have SSH/Terminal access through a Business or Reseller package, you can manage the app directly via the command line. Many users prefer this option for faster or more detailed control over their applications. This feature enables you to work within a secure virtual environment specifically for your app, providing convenient access to command-line tools.
In Setup Python App, click Edit next to your app.
Copy the source command provided next to Enter to the virtual environment.
Open Terminal in cPanel or log in via SSH, paste, and run the command to enter the environment.
If you need help, reach out to our support team or email helpdesk@elitehost.co.za.
Updated on: 25/10/2024
Thank you!