44

I've just started learning Python, and I'm pretty lost right now. I want to run my script on my server that is hosted through hosting24.com. Their FAQ says they support Python, but I have no clue where to put my script for it to run.

There is a folder called cgi-bin in my root, I'm guessing that is where I put my script? Can someone explain to me how this works?

Carlos
  • 1,897
  • 3
  • 19
  • 37
HellaMad
  • 5,294
  • 6
  • 31
  • 53

1 Answers1

32

Very simply, you can rename your Python script to "pythonscript.cgi". Post that in your cgi-bin directory, add the appropriate permissions and browse to it.

This is a great link you can start with.

Here's another good one.

Hope that helps.


EDIT (09/12/2015): The second link has long been removed. Replaced it with one that provides information referenced from the original.

Alexander Rossa
  • 1,900
  • 1
  • 22
  • 37
Carlos
  • 1,897
  • 3
  • 19
  • 37
  • I placed a file called test.cgi in the cgi-bin, gave it 777 perms, navigated to it, but I get a 500 internal service error. – HellaMad Feb 22 '12 at 16:20
  • Can you post what your, I'm assuming, Apache error.log states? – Carlos Feb 22 '12 at 16:21
  • Here's a [great writeup](http://encodable.com/internal_server_error/) of what would constitute a 500 error – Carlos Feb 22 '12 at 16:23
  • [Wed Feb 22 11:16:28 2012] [error] [client 204.xx.xx.70] (13)Permission denied: exec of '/home/xxxxx/public_html/cgi-bin/test.py' failed – HellaMad Feb 22 '12 at 16:32
  • Though I gave it 777 Perms (or so I thought). – HellaMad Feb 22 '12 at 16:33
  • See [this aricle](http://www.slingcode.com/suexec.php) regarding user directories and suexec. – Carlos Feb 22 '12 at 16:41
  • It turned out that my FTP client wasn't setting the permissions even though it said it did. – HellaMad Feb 22 '12 at 16:54
  • Cool answer @Carlos, but the second link is now broken. Is there a fresh link I was really interested to read it. Cheers – JasTonAChair Sep 12 '15 at 04:36
  • Thanks @JasTonAChair. Even though the original link is dead, I put up one that references data from the original. – Carlos Sep 13 '15 at 08:42