LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 12-06-2008, 02:17 AM   #1
darkphaux
LQ Newbie
 
Registered: Dec 2008
Posts: 2

Rep: Reputation: 0
Help needed: Apache help


Hello guys

I have been running a LAMP stack for awhile now but have never really explored the server side end of things. What I am trying to do is have a python script on a website run a bash command. This will accomplish a system so someone can create an account for proxy access via a webpage. I am running Ubuntu server edition 8.04.1


Here is my python script to do so:
Code:
import os

def main():
    username = "Test1"
    password = "Enter new password"
    os.system("htpasswd -b /etc/squid/passwd '%s' '%s'" % (username.replace("'"$
    return apache.OK
if __name__ == '__main__': main()
Now I read a bit on the net and from what I gathered I would need to run this as a CGI script. So I placed it in my /usr/lib/cgi-bin/ directory as a .py file.

Then when I go to my site (mysite.com/cgi-bin/program.py)

I get a 500 internal server error. So Once again I looked around and I figured out that I had bad handlers in my site configuration so I tried various different things and nothing seemed to work so I reset my site configuration to as follows:
Code:
NameVirtualHost *
<VirtualHost *>
        ServerAdmin webmaster@localhost

        DocumentRoot /home/carter/public_html
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /home/carter/public_html>
                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
                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>
Could someone please revise what I have to get this to work. It has been causing me a headache for over a month.

Thanks!
-Carter Hansen
 
Old 12-07-2008, 10:34 AM   #2
linuxpyro
Member
 
Registered: Apr 2004
Distribution: Gentoo
Posts: 134

Rep: Reputation: 16
Well, it looks like you have the Directory container twice for your cgi-bin directory. I would maybe do something like this:

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

        DocumentRoot /home/carter/public_html
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /home/carter/public_html>
                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
        </Directory>
Other than that, make sure you chmod your cgi script to 755, like this:
chmod 755 program.cgi
That should give apache permission to execute your script.
 
Old 12-08-2008, 04:59 PM   #3
darkphaux
LQ Newbie
 
Registered: Dec 2008
Posts: 2

Original Poster
Rep: Reputation: 0
Well, I tried what you did, and as I thought it didn't run.

It just gives me the same old 500 Internal Server Error that I have become quite familiar with. Here is a section of my error log that pertains to this error:
Code:
[Sun Dec 07 06:33:46 2008] [notice] mod_python: Creating 8 session mutexes based on 150 max processes and 0 max threads.
[Sun Dec 07 06:33:46 2008] [notice] mod_python: using mutex_directory /tmp
[Sun Dec 07 06:33:46 2008] [notice] Apache/2.2.8 (Ubuntu) mod_python/3.3.1 Python/2.5.2 PHP/5.2.4-2ubuntu5.3 with Suhosin-Patch configured -- resuming normal operations
[Sun Dec 07 09:42:16 2008] [error] [client 222.187.220.162] script '/home/carter/public_html/prx1.php' not found or unable to stat
[Sun Dec 07 18:51:35 2008] [error] [client 137.186.97.98] File does not exist: /home/carter/public_html/favicon.ico
[Sun Dec 07 22:14:22 2008] [error] [client 192.168.1.4] File does not exist: /home/carter/public_html/mad_scientist.txt
[Sun Dec 07 22:24:23 2008] [error] [client 72.25.192.4] File does not exist: /home/carter/public_html/favicon.ico
[Sun Dec 07 23:52:00 2008] [error] [client 222.187.220.162] script '/home/carter/public_html/prx1.php' not found or unable to stat
[Mon Dec 08 17:53:46 2008] [notice] caught SIGWINCH, shutting down gracefully
[Mon Dec 08 17:53:57 2008] [notice] mod_python: Creating 8 session mutexes based on 150 max processes and 0 max threads.
[Mon Dec 08 17:53:57 2008] [notice] mod_python: using mutex_directory /tmp
[Mon Dec 08 17:53:57 2008] [notice] Apache/2.2.8 (Ubuntu) mod_python/3.3.1 Python/2.5.2 PHP/5.2.4-2ubuntu5.3 with Suhosin-Patch configured -- resuming normal operations
[Mon Dec 08 17:54:23 2008] [error] [client 192.168.1.4] (8)Exec format error: exec of '/usr/lib/cgi-bin/carternet.py' failed
[Mon Dec 08 17:54:23 2008] [error] [client 192.168.1.4] Premature end of script headers: carternet.py
Also note that I am not using a .cgi script, it is written in python.
 
  


Reply



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
help needed in the apache configuration abhijeetgk Linux - Newbie 3 04-16-2008 03:16 AM
Apache Vhost Help Needed 2kau Linux - Software 2 03-30-2006 02:27 AM
apache help needed legal2k Linux - Newbie 8 02-08-2004 05:25 AM
Apache and Frontpage, no apache mods needed cli_man Linux - General 0 09-27-2003 09:31 AM
Apache helps needed !!! chuck77 Linux - General 1 05-15-2002 10:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 06:51 PM.

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
Open Source Consulting | Domain Registration