python

How to create a Python application in cPanel

This guide shows you how to create a Python application in cPanel. The guide assumes that you are already logged into cPanel and have our hosting advanced package enabled (this is a free upgrade simply open a ticket ).

 

Step 1: Click the "Setup Python App" icon in the advanced group.

Step 2: Press the "Create Application" button.

 

Step 3:

1) Choose the python version you wish to use.

2) Enter the directory that the python application should be installed to. This is path is relative to the root directory of the web hotel and will create the specified directory if it does not exist.

3) Enter the address the application should be located on. If it should accessible directly on your domain, leave the field blank.

4) Enter the name of the file to run. This must link "Application Entry Point" (see point 5) with the application itself.
For example, assuming that this example runs a Flask server, this can be done by defining "app = Flask (__ name__)" in the specified file.

5) Enter the name of the variable containing the server.

6) This is the path to where the Phusion Passenger log file is written.

7) Here environment variables can be added for python installation if needed.

8) When all fields are filled in as desired, press the "Create" button to set up the application.

 

 

Step 4: You can now make changes and manage the python application.

1) This is the command you input in the terminal to enter the virtual environment that is set up for the application. To install packages through pip, this command must be run first.

2) These buttons allow you to start, stop and restart the application.

3) If you have added a configuration file (ref. Point 4), for example a "requirements.txt" made with pip, you can install the listed packages by pressing this button.

4) Here you can add configuration files for the python application.

5) Here you can run python script located on the web server. This is useful if you do not have access to the terminal and want to run python script to do setup, for example to create a super user in Django. The script is run in the virtual environment of the application.

6) These buttons allow you to save or discard changes as well as delete the entire application.


Notes:  In the Application Entry point text box, you can optionally specify the callable object for the application.

If you do not specify the application entry point, cPanel creates a default application object for you.

Under Environment variables, you can optionally set environment variables for the application. To do this, click ADD VARIABLE, type the variable name and value, and then click DONE.  In the top right corner of the page, click CREATE.

 

 

You can call your newly crated application via web / cron or command line using SSH run the following command 

source /home/username/virtualenv/application/version/bin/activate && cd /home/username/application

 

Replace usernameapplication, and version with the actual values.  Enter to the virtual environment. To enter to virtual environment, run the command:

You can now install modules or can control the application's running state from cPanel:

  • To stop the application, click STOP APP.
  • To restart the application, click RESTART.
  • To completely remove the application from cPanel, click DESTROY.

 

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Server Side Includes (SSI)

SSI Server Side Includes Server Side Includes (SSI)  is an interpreted Perl like programming...

Apache .htaccess

Apache htaccess htaccess is a configuration file that begins with a period (.) that is read by...

File and Folder Permissions

File & Folder Permissions                     Changing file and folder...

Cron Jobs

Cron Job Manager Cron jobs Cron jobs are an advanced developer feature that allow you to...

Sub-Domains

Sub Domains Subdomains are used to generate separate URL's for different sections of your...