cPanel can run a Python application. This guide will go over the process of how to run Python applications from your cPanel.
Log into your cPanel to get started with your Python app. To load your first configuration screen, click on the Setup Python App, and click on Create Application.
Now, the application form will appear. In the Python Version section, you can select the Python version you want to use and fits your needs. The folder from which all of the Python files will be loaded is the Application root field, so in this text box, type the directory where the application files are located. The URL from which you would like the site to be loaded from is the Application URL. Here, select the domain and then type a URL from the application.
In the Application startup file field, you can specify the startup file for the application; however, this is optional. If you do not do this (specify a startup file), a passenger_wsgi.py startup file will be created by cPanel for you.
In the Application Entry point text box, you can specify the callable object for the application; however, this is optional as well. cPanel will create an application object that is default for you if you do not specify. You can just enter the application in the application entry point field since this is a function call that is going to be executed and load the Django instance.
The file that gets initially executed and proxied via Passenger is the passenger startup file. Within the passenger_wsgi file, the code is just a simple import.
WSGI is the file that has the application function, while the django_app is the folder of the Django installation.
In the section Environment variables, the environment variables can be optionally set for the application. You can do this by clicking on Add Variable and then typing the variable value and name. Finally, just click on Done.
Click Create, and then cPanel creates the environment in Python and creates the application.
You should connect your account with SSH if you want to work in the environment that was newly created. After you’ve connected your account with SSH, you will need to type the following command. Replace version, application, and username with the actual values that are displayed at the top of the page, next to Enter to the virtual environment. Run the following command if you want to enter the virtual environment:
source /home/username/virtualenv/application/version/bin/activate && cd /home/username/application
You can develop the Python application even further by using other commands and installing modules. In addition, you can control the running state of the application from cPanel. You can click Stop App to stop the application. You can click Restart to restart the application. And lastly, you can click Destroy to entirely eliminate the application from cPanel.