0

I'm a newbie and trying to create the following simple cgi script and stored it in /usr/lib/cgi-bin/hello.py:

 #!/usr/bin/python
 print "Content-type: text/html"
 print
 print "<html>"
 print "<center>Hello, Linux.com!</center>"
 print "</html>"

Also, I have add the following code to the /etc/apache2/sites-available/000-default.conf:

<Directory "/var/www/cgi-bin">
  Options +ExecCGI
  AddHandler cgi-script .py
</Directory>

and tried to run on browser by http://usr/lib/cgi-bin/hello.py. It's not working

-2

Finally, This article worked for me.

Instead of modifying '/sites-available/000-default.conf', I write the following code in '/etc/apache2/conf-available/serve-cgi-bin.conf':

   ScriptAlias /cgi-bin/ /var/www/cgi-bin/
         <Directory "/var/www/cgi-bin/">
              AllowOverride None
              Options +ExecCGI 
         </Directory>

Also, I saved the hello.py in /var/www/cgi-bin folder and then open the file in the browser.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.