Topics Map > Communication and Collaboration > cPanel Web Hosting

cPanel, How to use Python on cPanel

You can use Python for scripting and programming on the web.illinois.edu platform.

  

Important difference when hosting Python on cPanel

Python hosted on cPanel is served using Passenger. You cannot specify a port for your application to run on. When visting your application, you will also not include a port number in the URL.

Initial Setup

The cPanel dashboard includes a utility that allows you to choose the Python version and install additional modules.

  1. Log in to your cPanel account dashboard at https://web.illinois.edu/.
  2. In the Software section of the dashboard, click on the Setup Python App utility.
  3. Click the Create Application button
  4. Choose the Python version you want from those available.
  5. In Application root, enter the path in your home directory where you would like your application files to be stored.
  6. In Application URL, select the domain and enter the path (if any) where visitors will access your application
  7. In Application startup file, enter the name of the file that will start your application
  8. In Application Entry point, enter a name for your entry point. You may leave this blank for an entry point name of "application"
  9. In Passenger log file, enter a path for your log file
  10. If you would like to define Environment variables, do so in the last section by clicking ADD VARIABLE and filling in the relevant information.
  11. Click Create and wait for the page to update. 

When it is done with the configuration, your new application will be listed under the "Existing applications" section.

Post Setup

Once the application is configured, you can change the directory, the URI and the version of Python you are using in the Web Applications section.  

The newly created application will be supplied with a stub only. The real application can be developed or put into the application folder now.

Module Installation

You have two options for installing modules.
  1. Enter the virtual environment and run pip install from the command line
  2. Use the cPanel interface to run pip install against a specified config file in your application directory

Using the virtual environment to install modules

  1. From your cPanel dashboard, click Setup Python app
  2. Find your app in the list on the resulting page and click the pencil to edit the app (you won't be making any edits)
  3. Copy to command listed at the top of the page and paste it into your terminal window to enter the virtual environment
  4. For an app called "AnotherDemo" using python 3.5 in the cPanel account "jakramerdemo" the command will look as follows:
  5. source /home/jakramerdemo/virtualenv/AnotherDemo/3.5/bin/activate && cd /home/jakramerdemo/AnotherDemo
  6. From the command line within the virtual environment, you can now run pip install to install your modules

Using the cPanel interface to install modules

  1. Create your requirements file in your application directory using the cPanel file manager or terminal window
  2. From your cPanel dashboard, click Setup Python app
  3. Find your app in the list on the resulting page and click the pencil to edit the app (you won't be making any edits)
  4. In the Configuration Files section, enter the filename of your config file and click add
  5. Optional: click Edit next to your configuration file to make changes before installing
  6. Click the Run Pip Install button and select the appropriate config file from the dropdown list

  



Keywords:
cPanel, web hosting, python, scripting, programming 
Doc ID:
84995
Owned by:
Web H. in University of Illinois Technology Services
Created:
2018-08-17
Updated:
2024-04-22
Sites:
University of Illinois Technology Services