HELP - Python-CGI via Apache2 LAMP on Debian Linux

HELP - Python-CGI via Apache2 LAMP on Debian Linux

Postby Hop » Tue Aug 20, 2013 11:25 pm

I have been putting off learning Python for a long time and decided to try and start to work with the language. I have written a few python scripts, and they work fine from the command line on my Debian Linux configured as a LAMP server via Apache2 using python <scriptname.py>

But I can't for the life of me run Python scripts via CGI. I have tried everything I have read, but without a step-by-step tutorial, I am lost. I try to address my script via a remote web browser and I get 500-internal server error.

I am hoping for links to some above-mentioned tutorials on this, so I can try to diagnose the problem.

So far, all I have modified is the file "/etc/apache2/sites-available/default" to the following...
Code: Select all
 <VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www
        <Directory />
                Options  +ExecCGI FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin/">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
                AddHandler cgi-script .py              # tell Apache to handle every file with .py suffix as a cgi program
                AddHandler default-handler .html .htm  # tell Apache to handle HTML files in regular way
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn


I put the script in /usr/lib/cgi-bin/ and then address it in my browser http://192.168.0.51/cgi-bin/test.py but get the 500 error. I used chmod 755 of the script with the same result. I know the LAMP is working because going to the root (just the server address) shows the standard "It Works!" apache page.

The script I am trying...
Code: Select all
#!/usr/bin/env python

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

I tried which python from the command line and got back /usr/bin/python so I changed the top line to have that (without the 'env') but that didn't work either.

so... HELP! Is it a setting in apache's numerous conf files? I'm at rope's end. :?

Thank you SO much for your time!!
Hop
 
Posts: 11
Joined: Tue Aug 20, 2013 11:01 pm

Re: HELP - Python-CGI via Apache2 LAMP on Debian Linux

Postby metulburr » Tue Aug 20, 2013 11:50 pm

If you put this in your server, what is the output? This gives more detail of the 500 error
Code: Select all
tail -f /var/log/apache2/error.log


I havent done this in awile so thje step by step in my head is now gone. Normally a 500 error when doing CGI, means you typo'ed the script syntax. However the script works, so its a setting of some sort. Was
Code: Select all
/usr/lib/cgi-bin/

the original location? Because on my server its in
Code: Select all
/var/www/cgi-bin
, BUT i might of changed it to that location, i dont remember. I remember this being a pain in the butt. Until you get it working, its a royal pain.

I believe:
Code: Select all
AddHandler cgi-script .py

was the main thing.

I believe you also have to restart apache each time you modify something in /etc/apache2/sites-available/default if you want it to take effect
Code: Select all
sudo /etc/init.d/apache2 restart


Here is my default file on my server. I just copy and paste it if i use it again, because i hate configuring apache
Code: Select all
metulburr@server:/var/www/cgi-bin$ cat /etc/apache2/sites-available/default
<VirtualHost *:80>
   ServerAdmin metulbot@gmail.com

   DocumentRoot /var/www
   <Directory />
      Options FollowSymLinks
      AllowOverride None
      Options FollowSymLinks +ExecCGI
   </Directory>
   <Directory /var/www/>

      Options +ExecCGI Indexes FollowSymLinks MultiViews +Includes
      AllowOverride None
      Order allow,deny
      allow from all
      AddHandler cgi-script .py
      AddHandler cgi-script .cgi
      AddHandler wsgi-script .wsgi
           AddHandler default-handler .html .htm 
      AddType text/html .shtml
      AddHandler server-parsed .html
      AddHandler server-parsed .shtml
      DirectoryIndex index.shtml index.html
      AddOutputFilter INCLUDES .shtml
      AddHandler php5-script php
   </Directory>


   <Directory /var/www/forums>
      Options +ExecCGI Indexes FollowSymLinks MultiViews
      AllowOverride None
      Order allow,deny
      allow from all
      AddHandler cgi-script .py
           AddHandler default-handler .html .htm 
      AddType text/html .shtml
      AddHandler server-parsed .html
      AddHandler server-parsed .shtml
      DirectoryIndex index.shtml index.html
      AddOutputFilter INCLUDES .shtml
      AddHandler php5-script php
   </Directory>

   <Directory /var/www/subdir>
      Options +ExecCGI Indexes FollowSymLinks MultiViews +Includes
      AllowOverride None
      Order allow,deny
      allow from all
      AddHandler cgi-script .py
      AddHandler wsgi-script .wsgi
           AddHandler default-handler .html .htm 
      AddType text/html .shtml
      AddHandler server-parsed .html
      AddHandler server-parsed .shtml
      DirectoryIndex index.shtml index.html
      AddOutputFilter INCLUDES .shtml
      AddHandler php5-script php
   </Directory>


   <Directory /var/www/download>
      Options +ExecCGI Indexes FollowSymLinks MultiViews +Includes
      #AllowOverride None
      Order allow,deny
      allow from all
      AddHandler cgi-script .py
      AddHandler wsgi-script .wsgi
           AddHandler default-handler .html .htm 
      AddType text/html .shtml
      AddHandler server-parsed .html
      AddHandler server-parsed .shtml
      DirectoryIndex index.shtml index.html
      AddOutputFilter INCLUDES .shtml
   </Directory>



   #ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
   #<Directory "/usr/lib/cgi-bin">
      #AllowOverride None
      #Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
      #Order allow,deny
      #Allow from all
   #</Directory>

        ScriptAlias /cgi-bin/ /var/www/cgi-bin/
   WSGIScriptAlias /wsgi /var/www/wsgi/
<Directory "/var/www/wsgi/">
                Options +ExecCGI Indexes FollowSymLinks MultiViews +Includes
                AllowOverride None
                Order allow,deny
                allow from all
                AddHandler cgi-script .py
                AddHandler cgi-script .cgi
      AddHandler wsgi-script .wsgi
                AddHandler default-handler .html .htm
                AddType text/html .shtml
                AddHandler server-parsed .html
                AddHandler server-parsed .shtml
                DirectoryIndex index.shtml index.html
                AddOutputFilter INCLUDES .shtml
                AddHandler php5-script php

   </Directory>

        <Directory "/var/www/cgi-bin/">
   
#   ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
#   <Directory "/usr/lib/cgi-bin">
#commented on 12/18/12 in attempt to use header files in CGI scripts
#      #AllowOverride None
#      Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Includes
#      Order allow,deny
#      Allow from all
#      AddHandler cgi-script .py
 #          AddHandler default-handler .html .htm 
#      AddType text/html .shtml
#      AddHandler server-parsed .html
#      AddHandler server-parsed .shtml
#      DirectoryIndex index.shtml index.html
#      AddOutputFilter INCLUDES .shtml
                Options +ExecCGI Indexes FollowSymLinks MultiViews +Includes
                AllowOverride None
                Order allow,deny
                allow from all
                AddHandler cgi-script .py
                AddHandler cgi-script .cgi
      AddHandler wsgi-script .wsgi
                AddHandler default-handler .html .htm
                AddType text/html .shtml
                AddHandler server-parsed .html
                AddHandler server-parsed .shtml
                DirectoryIndex index.shtml index.html
                AddOutputFilter INCLUDES .shtml
                AddHandler php5-script php

   </Directory>

   ErrorLog ${APACHE_LOG_DIR}/error.log

   # Possible values include: debug, info, notice, warn, error, crit,
   # alert, emerg.
   LogLevel warn

   CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>
metulburr@server:/var/www/cgi-bin$


my cgi-bin python files are
Code: Select all
-rwxr-xr-x


I dont know if this was CGI related or just to get .shtml to work:
There was also something i did at one point about switching the owner from root to www-data. To be honest i dont remember. and then i started up the module, and restarted apache
Code: Select all
sudo a2enmod include
sudo apache2ctl restart

which stays on until you turn it off

I dont know there are two inch thick books just on configuring apache. Its gets quite complex fast. Once you get it working save the config file for later and everything related that you did as the next time you wont have to do this. Check some of this and post back

EDIT:
192.168::: is an inet address, not an IP address. switch this number with your public IP address and try again:
http://lmgtfy.com/?q=what+is+my+IP+address
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1413
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: HELP - Python-CGI via Apache2 LAMP on Debian Linux

Postby Hop » Wed Aug 21, 2013 12:18 am

I did the first command you offered and came up with this. I wanted to post it right away to see if you see something that might help to diagnose the issue. I'll go after the rest of your post next. Thank you for the quick reply and the help. Nothing worth doing is ever easy. lol
Code: Select all
root@rpi51:/etc/apache2# tail -f /var/log/apache2/error.log
[Tue Aug 20 16:21:01 2013] [error] [client 192.168.0.100] : No such file or directory
[Tue Aug 20 16:21:01 2013] [error] [client 192.168.0.100]
[Tue Aug 20 16:21:01 2013] [error] [client 192.168.0.100] Premature end of script headers: test.py
[Tue Aug 20 16:21:01 2013] [error] [client 192.168.0.100] File does not exist: /var/www/favicon.ico
[Tue Aug 20 16:22:52 2013] [error] [client 192.168.0.100] /usr/bin/env:
[Tue Aug 20 16:22:52 2013] [error] [client 192.168.0.100] python\r
[Tue Aug 20 16:22:52 2013] [error] [client 192.168.0.100] : No such file or directory
[Tue Aug 20 16:22:52 2013] [error] [client 192.168.0.100]
[Tue Aug 20 16:22:52 2013] [error] [client 192.168.0.100] Premature end of script headers: test.py
[Tue Aug 20 16:22:52 2013] [error] [client 192.168.0.100] File does not exist: /var/www/favicon.ico
Hop
 
Posts: 11
Joined: Tue Aug 20, 2013 11:01 pm

Re: HELP - Python-CGI via Apache2 LAMP on Debian Linux

Postby metulburr » Wed Aug 21, 2013 12:31 am

Code: Select all
[Tue Aug 20 16:22:52 2013] [error] [client 192.168.0.100] /usr/bin/env:
[Tue Aug 20 16:22:52 2013] [error] [client 192.168.0.100] python\r
[Tue Aug 20 16:22:52 2013] [error] [client 192.168.0.100] : No such file or directory
[Tue Aug 20 16:22:52 2013] [error] [client 192.168.0.100]
[Tue Aug 20 16:22:52 2013] [error] [client 192.168.0.100] Premature end of script headers: test.py


this is the part that its saying there is a problem related to this subject. The first three lines my first guess would be that 1) it cannot find python or 2) it cannot find the file test.py. What is the parents directory permissions. They also have to be 755. That would be something that i would check.
The last line makes me think there is a typo in the script. However the same script runs in my ubuntu server. I would think they both would work. However i noticed that some things that work when running a python program causes a 500 error when running it as a CGI script. I found the triple quoted method removes a few of these problems. Try something like this script as your CGI:

python3.x
Code: Select all
#!/usr/bin/env python3

import cgi
import cgitb; cgitb.enable()

form = cgi.FieldStorage()

html = """Content-type: text/html\n

<html>
    <head>
        <title>{TITLE}</title>
        <script></script>
    </head>
<body>

<b>cgi.FieldStorage() is: <br></b>
{FORM} <br><br>

<form name="input" action="test.py" method="get">
Enter something: <input type="text" name="something">
<input type="submit" value="Submit">
</form>

</body>
</html>
""".format(
        TITLE='my title',
        FORM=form
    )
print(html)


This is nice
Code: Select all
import cgitb; cgitb.enable()

because it basically gives you a traceback in your browser instead of hunting it down in the error logs

EDIT:
Code: Select all
File does not exist: /var/www/favicon.ico

you can also clear out your error logs by inserting a favicon.ico in your /var/www (the little picture 32x32 on the browser tab)

EDIT2:
whoops, that doesnt have to be python3.x, you can just remove the 3 on the shebang line, and the rest will work in 2.7.3+
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1413
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: HELP - Python-CGI via Apache2 LAMP on Debian Linux

Postby Hop » Wed Aug 21, 2013 12:40 am

Thank you sir for the help!
I did NOT chmod /usr/lib/cgi-bin to 755 so I did that. I thought you had to do that with the script only. Now I have...
Code: Select all
Forbidden

You don't have permission to access /cgi-bin/test.py on this server.


I tested the script using the command line and this is what I got, so it certainly looks like the script works.
Code: Select all
root@rpi51:/usr/lib/cgi-bin# python test.py
Content-type: text/html


<html>
    <head>
        <title>my title</title>
        <script></script>
    </head>
<body>

<b>cgi.FieldStorage() is: <br></b>
FieldStorage(None, None, []) <br><br>

<form name="input" action="test1.py" method="get">
Enter something: <input type="text" name="something">
<input type="submit" value="Submit">
</form>

</body>
</html>

You mentioned...
What is the parents directory permissions. They also have to be 755. That would be something that i would check.
Parents? Did you mean that another directory needs chmod 755 other than my /usr/lib/cgi-bin?
Hop
 
Posts: 11
Joined: Tue Aug 20, 2013 11:01 pm

Re: HELP - Python-CGI via Apache2 LAMP on Debian Linux

Postby metulburr » Wed Aug 21, 2013 12:49 am

using the path /usr/lib/cgi-bin/ for the example

if a file is in cgi-bin and has 755 permissions but the directory cgi-bin is 700, then its like saying you can come into my kitchen but you cannot come into my house. The same with the directories /usr and /usr/lib. I jsut meant to check to make sure those directories are allowing access, via normally 755

so this is not pulling up a traceback error on your browser?
Code: Select all
import cgitb; cgitb.enable()


Forbidden

You don't have permission to access /cgi-bin/test.py on this server.

are you root?
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1413
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: HELP - Python-CGI via Apache2 LAMP on Debian Linux

Postby Hop » Wed Aug 21, 2013 12:54 am

metulburr wrote:using the path /usr/lib/cgi-bin/ for the example

if a file is in cgi-bin and has 755 permissions but the directory cgi-bin is 700, then its like saying you can come into my kitchen but you cannot come into my house. The same with the directories /usr and /usr/lib

Pardon my ignorance about permissions, but are you suggesting I do chmod -R 755 /usr?

Also...
192.168::: is an inet address, not an IP address. switch this number with your public IP address and try again:
http://lmgtfy.com/?q=what+is+my+IP+address


The LAMP server is on my home network, served by a Raspberry Pi Model B Revision 2.0. Rasbian 7.1 I believe. Everything else, Webmin, Samba, etc are all working fine with a very small memory footprint at less than 25% of available. Removed GUI and moved GPU allocated memory to the main pool.
Hop
 
Posts: 11
Joined: Tue Aug 20, 2013 11:01 pm

Re: HELP - Python-CGI via Apache2 LAMP on Debian Linux

Postby Hop » Wed Aug 21, 2013 12:58 am

chmoding those directories made them inaccessible via samba on my windows laptop. I think I have some major hoops to jump through now because I wanted to write scripts on my laptop and save them to that directory then test it in a browser on my laptop. I will have to pair windows users with samba, and that was a while ago for me so here we go again. lol

EDIT: I thought maybe using scite to edit the script in windows might be screwing up the script (line feeds, etc) so I did the last several using nano via Putty.
Last edited by Hop on Wed Aug 21, 2013 12:59 am, edited 1 time in total.
Hop
 
Posts: 11
Joined: Tue Aug 20, 2013 11:01 pm

Re: HELP - Python-CGI via Apache2 LAMP on Debian Linux

Postby metulburr » Wed Aug 21, 2013 12:59 am

Pardon my ignorance about permissions, but are you suggesting I do chmod -R 755 /usr?

i would never just outright change a permission without checking its current permission settings.

check what it currently is:
Code: Select all
cd /
ls -l

it probably is already good to go, unless you changed it before
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1413
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: HELP - Python-CGI via Apache2 LAMP on Debian Linux

Postby Hop » Wed Aug 21, 2013 1:01 am

Code: Select all
drwxr-xr-x  10 root root     4096 Jul 26 04:24 usr
Hop
 
Posts: 11
Joined: Tue Aug 20, 2013 11:01 pm

Re: HELP - Python-CGI via Apache2 LAMP on Debian Linux

Postby metulburr » Wed Aug 21, 2013 1:10 am

I thought maybe using scite to edit the script in windows might be screwing up the script (line feeds, etc) so I did the last several using nano via Putty.


oh ok your in windows using Putty. I am not familiar with scite, but if it does insert windows newlines in, that would be a problem. I am not sure if nano can do this. I use Vim. B ut in vim you can change from windows to unix lines endings, and back etc. I believe the command is
Code: Select all
:set ff=unix
or
Code: Select all
:set fileformat=unix
to change to linux's line endings and
Code: Select all
:set list
will show its current line endings

or just simply rewrite a small script using nano or vim to ensure its line endings are linux and test again.
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1413
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: HELP - Python-CGI via Apache2 LAMP on Debian Linux

Postby metulburr » Wed Aug 21, 2013 1:11 am

drwxr-xr-x 10 root root 4096 Jul 26 04:24 usr

the directories permissions look fine then
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1413
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: HELP - Python-CGI via Apache2 LAMP on Debian Linux

Postby metulburr » Wed Aug 21, 2013 1:17 am

Did you make the file executable?
Code: Select all
sudo chmod a+x /usr/lib/cgi-bin/test.py
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1413
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: HELP - Python-CGI via Apache2 LAMP on Debian Linux

Postby Hop » Wed Aug 21, 2013 1:22 am

Yes, two different ways. The command you suggested AND using 0755.

Well, I tried chown to use www-data as you mentioned earlier, both on the cgi-bin directory AND the file. No go. Still forbidden. I have to go eat with the family peeps now, grrrr. I'll go after this again tomorrow. Thank you for trying to fix my issue. Maybe overnight you might remember something else that apache's config's need to get this working. I agree, I HATE messing with Apache but it IS one of the 4 letters of the acronym "LAMP" lol.

I have to get this working. It is a moral imperative! To come this far with my RPi, with the LAMP, Webmin, Samba, wireless, etc. I can't stop now. After looking at Python code, I absolutely HAVE to write with it now. Besides, I'm a huge Monty Python fan!

I hope you don't give up on my issue. You have given me some amazing info and I learned a LOT from your replies!!!

Cheers until tomorrow.

Hop
Hop
 
Posts: 11
Joined: Tue Aug 20, 2013 11:01 pm

Re: HELP - Python-CGI via Apache2 LAMP on Debian Linux

Postby Hop » Wed Aug 21, 2013 1:30 am

One more post. I have another LAMP server running on my LAN using a laptop, Linux Mint, very stable. I am going to go after Python and CGI using that platform and see if I can gain some insight into what is needed. If it works 'out of the box' like I am hoping, at least I will have a way to write and test python while I figure out how to get it working on my RPi.
Hop
 
Posts: 11
Joined: Tue Aug 20, 2013 11:01 pm

Re: HELP - Python-CGI via Apache2 LAMP on Debian Linux

Postby metulburr » Thu Aug 22, 2013 12:41 am

did you figure it out?
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1413
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: HELP - Python-CGI via Apache2 LAMP on Debian Linux

Postby Hop » Mon Aug 26, 2013 8:35 pm

metulburr wrote:did you figure it out?

No I have not and it is killing me. I know the problem is with Apache's configuration files. And possibly the permissions as well, but I am going to run through everything you included in this thread again, and see if I can get that door opened.

The python scripts work fine from the command line, just can't get it working from a browser.

EDIT (after-thought): I wonder if Apache is the best answer for my Raspberry Pi. The standard LAMP has been all I have used for years, even though I changed linux distro's here and there. I was so happy to get the LAMP working, even with webmin and samba, with such a low memory footprint, that I wanted to use Apache. I can't get python, perl, or even CGI scripts to work through a remote browser, even on my Linux Mint LAMP. Is it a virtual host thing? SO many questions for something I would think is pretty simple. I'll keep trying.
Hop
 
Posts: 11
Joined: Tue Aug 20, 2013 11:01 pm

Re: HELP - Python-CGI via Apache2 LAMP on Debian Linux

Postby Hop » Mon Aug 26, 2013 10:08 pm

Something new that is happening, although it is with a perl script. The script shows when I try to access it through the browser. I know, I have to configure sites-available/default to allow perl as well.

At this point, Python is my choice. I am just trying to get ANY scripting language to work other than PHP, through a web browser that is.
Hop
 
Posts: 11
Joined: Tue Aug 20, 2013 11:01 pm

Re: HELP - Python-CGI via Apache2 LAMP on Debian Linux

Postby Hop » Tue Aug 27, 2013 12:45 am

Another thing I am confused about metulburr is what I have been reading on the web about using CGI. In one thread, I read that putting all the scripts in a single folder with permissions is so "old school". And other threads talking about running CGI, Perl, and Python from any place, not just in the CGI-BIN folder. And I do not understand how I put my script in the usr/lib/cgi-bin/ and access it via a browser at localhost/cgi-bin/.

So with all this confusion going on, at least for my noob eyes, I guess I will have to fully understand the apache config files, the commands placed in them, how CGI works, and semi-master all that before I can write my first line of usable python code. All this was exactly what I hoped to avoid. I can care-a-less how apache works. I hoped it was a layer of server software I could just configure and build on. I know a bit about MySQL also, but I really don't need to know where it stores the data or how it interacts with apache.

I guess if I wanted to be an I.T. Pro all this would matter, but all I really want to do is write Python I can run from a browser that controls my RPi. I guess I will have to map the whole territory before I can just travel the main road. Or do I have to?

Thanks for letting me vent! Hop
Hop
 
Posts: 11
Joined: Tue Aug 20, 2013 11:01 pm

Re: HELP - Python-CGI via Apache2 LAMP on Debian Linux

Postby critikaster » Fri Nov 15, 2013 11:46 pm

Not sure if this will help you (I think not), but maybe someone else that came across this thread like me:

In my case, I made a mistake with my
Code: Select all
ScriptAlias
directive. I uncommented the original one, but forgot to configure a new one.

As soon as I *correctly* changed and saved my
Code: Select all
sites-available/default
config file from this:

Code: Select all
    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">


.. to this:

Code: Select all
    ScriptAlias /cgi-bin/ /var/www/cgi-bin/
    <Directory "/var/www/cgi-bin">


.. and reloaded apache2, it just worked: it stopped displaying my scripts as text, and started running them as a script. Also, it no longer displayed `/var/www/cgi-bin` as a directory in the browser, but now correctly displays the error:

Forbidden
You don't have permission to access /cgi-bin/ on this server.
critikaster
 
Posts: 1
Joined: Fri Nov 15, 2013 11:43 pm


Return to Web Development

Who is online

Users browsing this forum: No registered users and 2 guests