Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: How to test python script under cPanel  (Read 2332 times)

0 Members and 1 Guest are viewing this topic.

rinop

  • Guest
How to test python script under cPanel
« on: September 25, 2017, 06:28:49 pm »
Run 'python -V' to see the python version.
Run 'whereis python' to ensure it is /usr/bin/python

Step 1 : Create a file test.py in /home/username/public_html/cgi-bin with the content below :

#! /usr/bin/python

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

Step 2 : Change ownership and file permissions

chown username:username /home/username/public_html/cgi-bin/test.py
chmod +x /home/username/public_html/cgi-bin/test.py

script should work using http://domain.com/cgi-bin/test.py

step 3. to test script outside cgi-bin ,add the following content into /home/username/public_html/.htaccess file:

Options +ExecCGI
AddHandler cgi-script .py

copy script to /home/username/public_html

it will work using http://domain.com/test.py