Find the answer to your Linux question:
Results 1 to 3 of 3
Hi, trying to run python scripts on my Apache2 through CGI. I am running BackTrack 5 - 2.6.39.4 This is the content of my /etc/apache2/sites-available/default Code: . . . ScriptAlias ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jan 2011
    Posts
    4

    Question Apache2 + CGI: "You don't have permission..."


    Hi,
    trying to run python scripts on my Apache2 through CGI.
    I am running BackTrack 5 - 2.6.39.4

    This is the content of my /etc/apache2/sites-available/default
    Code:
    .
    .
    .
     ScriptAlias /cgi-bin/ /root/public_html/cgi-bin/
      <Directory /cgi-bin/>
         AllowOverride None
         Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
         AddHandler cgi-script py
         Order allow,deny
         Allow from all
      </Directory>
    .
    .
    .
    After restarting the Apache server, /etc/init.d/apache restart
    I try to access the sample.py script:

    Code:
    #!/usr/bin/python
    print "Content-type: text/html\n\n"
    print "Hello, World."
    for i in 'hello':
        print i+'\n'
    ..from the following URL: localhost/cgi-bin/sample.py
    And I am getting this error:

    Code:
    403 Forbidden
    
    You don't have permission to access /cgi-bin/sample.py on this server.
    The Apache-logs shows this error:
    Code:
    [Sat Dec 31 12:21:32 2011] [error] [client 127.0.0.1] (13)Permission denied: access to /cgi-bin/sample.py denied
    Both the /cgi-bin/ and the sample.py is sat to 755 permission, have also tried with 777.

    I have also tried all this from the /cgi-bin/ directory in /root/public_html

    Any help is appreciated!

  2. #2
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,307
    It is probably that your aliased dir is in /root, which itself is not accessible by the apache user (even tho the public_html dir is). Try moving that dir to somewhere else (e.g. /www/public_html). Ensure that the parent dir (e.g. /www) has read/execute by all permissions on it.

  3. #3
    Just Joined!
    Join Date
    Jan 2011
    Posts
    4
    Thank you!
    I created /public_html outside the /root directory, sat the permissions to 777 - It works!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •