WebFaction
Community site: login faq

I'm trying to learn how to run a cgi script. I saved the following script as hello.cgi in htdocs.

#!/usr/bin/env python
print "Content-Type: text/html"
print
print """\
<html>
<body>
<h2>Hello World!</h2>
</body>
</html>
"""

Then I then saved a test.html file with just the line:

<!--#include virtual="hello.cgi"-->

in the same folder. I uploaded both of these files in text format. I logged into my account using ssh and ran the following line:

chmod 644 hello.cgi

However when I went to test.html with my browser, I got an Internal Server Error message and am not sure how to proceed.

asked 30 Sep '11, 05:05

womble
15148
accept rate: 0%

edited 30 Sep '11, 05:08


Hi,

First of all, the permissions should be set to 755, so the script is executable. If you still have issues after fixing this, please check out our docs on solving this kind of errors.

permanent link

answered 30 Sep '11, 05:48

todork
1.2k4
accept rate: 34%

Hi todork. Thanks - I changed the permissions to 755. I am a bit confused about the file paths though. This file is in /apache/htdocs/ - if I am calling it from a webpage does the webpage need to be in the same location (/apache/htdocs/) also?

(30 Sep '11, 06:02) womble

Not necessarily - you can call it using a relative or an absolute path. If you are having issues with such matters, it would be best to open a ticket though.

(30 Sep '11, 06:08) todork
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×337
×31

question asked: 30 Sep '11, 05:05

question was seen: 14,254 times

last updated: 30 Sep '11, 06:08

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM