How do i host python apps in Dedicated hosting plan?
Linux Dedicated Server allows you to host multiple websites under your web hosting space. Linux Dedicated Server comes with full root access where you will be having control to make any changes at any time. Python Hosting is designed to be user-friendly and easy to learn. It’s not as widely used as PHP Hosting, but it’s well-documented, and there are lots of modules available to make coding fast and fun.In that Python is a great language for creating web applications and you can make design your websites.This article will introduce you to Python and show you how to run Python scripts in the cpanel as,
[1] Log in to your cPanel
[2] Go to section Files > File Manager
[3] You can choose whether you want to run the script in the cgi-bin folder or outside of it.
[4] Go to the cgi-bin folder
[5] Create a file with a .py extension, for example test.py in the /home/cPaneluser/public_html/cgi-bin directory).
[6] In order to create the file, click New File > specify the name of the file with the required extension and click Create New File
[7] Change the permission of the file to 0755
NOTE: Files are created with default permissions 0644. The .py file will become executable when the permissions are changed to 0755.
[8] In order to change the permissions of the file you need to select the file > click Change Permissions > Mark Execute for User, Group, World columns and click Change Permissions:
[9] Open the file, click Edit and add the code.
We will add the following script for testing purposes:
!/usr/bin/python
print “Content-type: text/html\n\n”
print “How to run Python scripts in cPanel
NOTE: The file should start with the path to the Python scripts that is /usr/bin/python on our servers, but you can run the whereis python command via SSH to check the directory.
Now the script should work using http://domain.com/cgi-bin/test.py
Also if you would like to run the Python file not in the cgi-bin folder (in public_html or any other directory), it is necessary to add the following code to the .htaccess file in the same directory where the Python script is placed
Options +ExecCGI
AddHandler cgi-script .py