How can i run a python script in my hosting account?

1- Start creating a test script, name the file "" for example, containing this code:

#! /usr/bin/python
print "Content-type: text/html\n\n"
print "<html>Hello world!</html>"

2- Create the file in /home/username/public_html/cgi-bin directory (replace "username" with your cPanel username)

3- Correct the file permission, you can do this with your FTP program or through SSH (if you have access):

The ssh comand is:

chmod +x

At this point, the script should work using

If you would like the script to run outside the cgi-bin directory, place the following content into the .htaccess file in your public_html directory:

Options +ExecCGI
AddHandler cgi-script .py

You could then copy the file to /home/username/public_html and have it work there as well so you can run it accessing to

Was this answer helpful? 5 Users Found This Useful (587 Votes)