LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-03-2008, 08:46 PM   #1
Hewson
Member
 
Registered: Feb 2007
Location: /home
Distribution: Kubuntu and CentOS
Posts: 214

Rep: Reputation: 32
Apache2 - python file is downloadable instead of displayed


Hello all,

I can't figure this one out. I want to use python as a CGI handler. aka not the mod_python way.

I have python installed.
I have the python file I am attempting to view set as executable for owner, group, and everyone.
Below is my /etc/apache2/sites-enabled/000-default file.

When I try to view the file in my browser, the browser trys to download it. I have set this up correctly on one box, and attempted to duplicate the configuration on a 2nd box. The second box is not working correctly.

Typically apache forces you to download files when it does not know what to do with them. I have my 'AddHandler' directive so I'm not quiet sure what the problem is.

/var/log/apache2/error.log does not have any hints for me.


Code:
NameVirtualHost *
<VirtualHost *>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www/
        <Directory />
                Options FollowSymLinks +ExecCGI
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews +ExecCGI
                AddHandler cgi-script .cgi .php .py
                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
        </Directory>

        ErrorLog /var/log/apache2/error.log

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

        CustomLog /var/log/apache2/access.log combined
        ServerSignature On

    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>
 
Old 10-03-2008, 10:16 PM   #2
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 125Reputation: 125
Does your python script start with a proper shebang line? (e.g., #!/usr/bin/python)
 
Old 10-05-2008, 01:35 PM   #3
Hewson
Member
 
Registered: Feb 2007
Location: /home
Distribution: Kubuntu and CentOS
Posts: 214

Original Poster
Rep: Reputation: 32
This is my file:
Code:
#!/usr/bin/python
print "conent-type: text/html\n"
print "<html><body>hello python-friendly world!</body></html>"
and /usr/bin/python is there:
Code:
scattaneo@wintermute:/var/www$ /usr/bin/python
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting up Python 2.5 on Apache2 in Debian Etch michux Linux - Server 3 09-10-2008 10:21 AM
[Python] 'None' being displayed after adding feature LinuxCrayon Programming 3 03-27-2008 11:10 PM
mod python: What to use for PythonHandler in apache2.conf? BrianK Linux - Software 1 10-10-2007 05:24 PM
Downloadable ISO / file of LQ forum ? markraem LQ Suggestions & Feedback 3 06-06-2006 09:10 AM
python and apache2 mindcry Linux - Software 0 12-09-2004 01:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:11 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration