The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

I am willing to PAY for help installing Python....

Discussion in 'General Discussion' started by mpierre, Apr 9, 2003.

  1. mpierre

    mpierre Well-Known Member

    Joined:
    Jun 30, 2002
    Messages:
    196
    Likes Received:
    0
    Trophy Points:
    16
    I have been wanting to setup Python so it is usuable by my clients.

    Python is already on EVERY CPanel machines.

    I just want help in allowing my users to use .PY scripts.

    I don't want to install any other Python versions, I believe that the addhandler command is supposed to be sufficient, only it doesn't work :

    I added the handler, as suggested elsewhere in the forum, but I still see every .py file as if they were HTML files : the content is displayed.

    What should I do ?

    I asked, but never got an answer. So I am offering money... I can send money via Paypal to the person who succesfully help me install it.
     
  2. mpierre

    mpierre Well-Known Member

    Joined:
    Jun 30, 2002
    Messages:
    196
    Likes Received:
    0
    Trophy Points:
    16
    No one is taking my offer ???

    If you have Python installed, why not share the solution here, in a clear step-by-step manner ?
     
  3. Noldar

    Noldar Well-Known Member

    Joined:
    Jun 26, 2002
    Messages:
    64
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Ponchatoula, LA
    All you should have to do is edit /usr/local/apache/conf/httpd.conf and change the following line from

    AddHandler cgi-script .cgi .pl

    to

    AddHandler cgi-script .cgi .pl .py

    Then restart apache.

    Here's a python script that you can test it with.
    Code:
    #!/usr/bin/python
    
    def main():
      print "Content-type: text/html"
      print
      print "<TITLE> Hello, World!</TITLE>"
      print "Hello, World!"
    
    if (__name__ == "__main__"):
      main()
    
    Save it to hello.py and chmod it to 755 and it should work.

    Richard
     
  4. mpierre

    mpierre Well-Known Member

    Joined:
    Jun 30, 2002
    Messages:
    196
    Likes Received:
    0
    Trophy Points:
    16
    Seem to be a little better...

    Now I get an Internal Server Error, with the message :

    Premature end of script headers: /home/user/public_html/hello.py
     
  5. mpierre

    mpierre Well-Known Member

    Joined:
    Jun 30, 2002
    Messages:
    196
    Likes Received:
    0
    Trophy Points:
    16
    A little more information :

    Python Version :

    Python 1.5.2 (#1, Jan 31 2003, 10:58:35) [GCC 2.96 20000731 (Red Hat Linux 7.3 2 on linux-i386
    Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam


    SSH output of the file :
    --------------------------------------------------------------
    root@server [/home/user/www]# cat hello.py
    #!/usr/bin/python

    def main():
    print "Content-type: text/html"
    print
    print "<TITLE> Hello, World!</TITLE>"
    print "Hello, World!"

    if (__name__ == "__main__"):
    main()


    root@server [/home/user/www]#
    -------------------------------------------------------------

    The file is 755, and owned by the user...

    Here is the listing from ls -0 :
    -------------------------------------------------------------------
    -rwxr-xr-x 1 username 178 Apr 9 14:28 hello.py*
    ------------------------------------------------------------------
     
  6. Arthur

    Arthur Member

    Joined:
    Jan 23, 2003
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    1
  7. Noldar

    Noldar Well-Known Member

    Joined:
    Jun 26, 2002
    Messages:
    64
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Ponchatoula, LA
    Check the group owner on the file also with ls -l. It should be the same as the username. suexec is very picky.

    Richard
     
  8. mpierre

    mpierre Well-Known Member

    Joined:
    Jun 30, 2002
    Messages:
    196
    Likes Received:
    0
    Trophy Points:
    16
    It was indeed the group !

    Thanks Noldar...

    Send me a private message if you want me to send a little money...
     
  9. Finkinstein

    Finkinstein Well-Known Member

    Joined:
    Mar 21, 2003
    Messages:
    131
    Likes Received:
    0
    Trophy Points:
    16
    If a line:
    AddHandler cgi-script .cgi .pl
    does not excist, should it or can I add it.

    The handlers are still present in cpanel but I can't find the line.

    cPanel.net Support Ticket Number:
     
  10. xerophyte

    xerophyte Well-Known Member

    Joined:
    Mar 16, 2003
    Messages:
    216
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Canada
    Now I get an Internal Server Error, with the message :

    Premature end of script headers: /home/user/public_html/hello.py

    This error comes when you have syntax error on the script. Python is sensitive to spaces so you need to indent the code good.

    first try to run the script using python scriptname.py.

    If you get error fix it and try it again.

    if you have problems let know me, i might be able to hlep you for free ;)

    my email address sutha[at]voxtreme.com or xerophyte[at]linuxnetworkcare.com

    cPanel.net Support Ticket Number:
     
  11. xerophyte

    xerophyte Well-Known Member

    Joined:
    Mar 16, 2003
    Messages:
    216
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Canada
    Now I get an Internal Server Error, with the message :

    Premature end of script headers: /home/user/public_html/hello.py

    This error comes when you have syntax error on the script. Python is sensitive to spaces so you need to indent the code good.

    first try to run the script using python scriptname.py.

    If you get error fix it and try it again.

    if you have problems let know i can help you for free ;)

    my email address sutha[at]voxtreme.com or xerophyte[at]linuxnetworkcare.com

    cPanel.net Support Ticket Number:
     
Loading...

Share This Page