Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora 17/18 > Servers & Networking
FedoraForum Search

Forgot Password? Join Us!

Servers & Networking Discuss any Fedora server problems and Networking issues such as dhcp, IP numbers, wlan, modems, etc.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 28th February 2005, 09:16 PM
Secret Agent Offline
Registered User
 
Join Date: Nov 2004
Posts: 199
Python installation?

I want to install Python on a web hosting server with cPanel. How do I check if it is installed or not? If not, how do I install? Any downside to using Python for a web hosting server?

root@server [~]# rpm -q python
python-2.3.3-6

root@server [~]# rpm -q mod_python
mod_python-3.1.3-1.fc2.2

I believe I may have to edit httpd.conf ? What changes?

Thank you in advance

Using:
Fedora Core 2
Cpanel 10.0 R-112

Last edited by Secret Agent; 28th February 2005 at 09:28 PM.
Reply With Quote
  #2  
Old 28th February 2005, 10:41 PM
duncan Offline
Registered User
 
Join Date: Feb 2004
Location: Florida (central)
Age: 63
Posts: 87
This is probably all you need for apache:
LoadModule python_module modules/mod_python.so

It might already be ok if your current config is looking at /etc/httpd/conf.d/ (which are the extra configuration files).
See /etc/httpd/conf.d/python.conf for specifics.
Reply With Quote
  #3  
Old 28th February 2005, 10:48 PM
Secret Agent Offline
Registered User
 
Join Date: Nov 2004
Posts: 199
My httpd.conf shows nothing of "python" but the python.conf is the following entirely below

#
# Mod_python is a module that embeds the Python language interpreter
# within the server, allowing Apache handlers to be written in Python.
#

LoadModule python_module modules/mod_python.so

# Override type-map handler for /var/www/manual
<Directory "/var/www/manual/mod/mod_python">
<Files *.html>
SetHandler default-handler
</Files>
</Directory>

# This will cause files beneath /var/www/html with the extension .spam
# to be handled by the Python script /var/www/html/eggs.py
#
#<Directory /var/www/html>
# AddHandler python-program .spam
# PythonHandler eggs
#</Directory>

# This will cause all requests to the /python heirachy of your
# webserver to be handled by the python script /path/to/myhandler.py
#
#<Location /python>
# SetHandler python-program
# PythonPath "sys.path + ['/path/to']"
# PythonHandler myhandler
#</Location>

# This will cause all requests to the /python heirachy of your
# webserver to be handled by mod_python's Publisher handler
# (see http://localhost/manual/mod/mod_python/hand-pub.html)
#
#<Location /python>
# SetHandler python-program
# PythonHandler mod_python.publisher
#</Location>

# This will cause the output of all requests to files beneath
# /var/www/html with the extension .flt to be filtered through
# the Python script /var/www/html/filter.py
#
#<Directory /var/www/html>
# PythonOutputFilter filter MYFILTER
# AddOutputFilter MYFILTER .flt
#</Directory>
Reply With Quote
  #4  
Old 2nd March 2005, 01:27 AM
Secret Agent Offline
Registered User
 
Join Date: Nov 2004
Posts: 199
can someone please help me?
Reply With Quote
  #5  
Old 2nd March 2005, 03:24 AM
5amYan Offline
Registered User
 
Join Date: Feb 2005
Posts: 10
is the python.conf in /etc/init.d ?
Are you on an RH based distro?
if so try
uncommenting the following, but ***note***>> the absolute path (make sure it is valid for your system.)
# This will cause all requests to the /python heirachy of your
# webserver to be handled by mod_python's Publisher handler
# (see http://localhost/manual/mod/mod_python/hand-pub.html)
#
<Location /usr/local/www/data/python> ## or in FC maybe /var/www/html/python
SetHandler python-program
PythonHandler mod_python.publisher
PythonDebug On
</Location>

Then put something like the following in the /directory/path/you/chose/hello.py
Code:
from mod_python import apache

 def handler(req):
     req.content_type = "text/html"
     req.write("Hello World! Hello __self__!")
     return apache.OK

And read the mod_python documentation

luck. let me know how it goes.

5

Last edited by 5amYan; 2nd March 2005 at 03:28 AM. Reason: indentation in code
Reply With Quote
  #6  
Old 2nd March 2005, 03:50 AM
Secret Agent Offline
Registered User
 
Join Date: Nov 2004
Posts: 199
Before I do anything let me show you what I have and please explain to me what I should do

root@server [~]# locate python.conf
/etc/httpd.old/conf.d/python.conf
/usr/local/apache/conf.d/python.conf
Reply With Quote
  #7  
Old 2nd March 2005, 03:51 AM
Secret Agent Offline
Registered User
 
Join Date: Nov 2004
Posts: 199
This is my python.conf file (/usr/local/apache/conf.d/python.conf

Please tell me what I should edit here (thank you)

#
# Mod_python is a module that embeds the Python language interpreter
# within the server, allowing Apache handlers to be written in Python.
#

LoadModule python_module modules/mod_python.so

# This will cause files beneath /var/www/html with the extension .spam
# to be handled by the Python script /var/www/html/eggs.py
#
#<Directory /var/www/html>
# AddHandler python-program .spam
# PythonHandler eggs
#</Directory>

# This will cause all requests to the /python heirachy of your
# webserver to be handled by the python script /path/to/myhandler.py
#
#<Location /python>
# SetHandler python-program
# PythonPath "sys.path + ['/path/to']"
# PythonHandler myhandler
#</Location>

# This will cause all requests to the /python heirachy of your
# webserver to be handled by mod_python's Publisher handler
# (see http://localhost/manual/mod/mod_python/hand-pub.html)
#
#<Location /python>
# SetHandler python-program
# PythonHandler mod_python.publisher
#</Location>

# This will cause the output of all requests to files beneath
# /var/www/html with the extension .flt to be filtered through
# the Python script /var/www/html/filter.py
#
#<Directory /var/www/html>
# PythonOutputFilter filter MYFILTER
# AddOutputFilter MYFILTER .flt
#</Directory>
Reply With Quote
  #8  
Old 2nd March 2005, 12:25 PM
5amYan Offline
Registered User
 
Join Date: Feb 2005
Posts: 10
#python.conf
<Location /var/www/html/python>
SetHandler python-program
PythonHandler mod_python.publisher
PythonDebug On
</Location>

/etc/init.d/httpd restart # Don't forget to restart apache

#/var/www/html/python/test.py
# test.py
def main(req, name="Secret Agent!"):
return "Hello %s" % name
Reply With Quote
  #9  
Old 2nd March 2005, 12:34 PM
Secret Agent Offline
Registered User
 
Join Date: Nov 2004
Posts: 199
I'm sorry but I"m confused here. What exactly am I suppsoed to do with the pieces you showed me?
Reply With Quote
  #10  
Old 2nd March 2005, 12:52 PM
5amYan Offline
Registered User
 
Join Date: Feb 2005
Posts: 10
#python.conf <<<<----- Goes in this file that you cut and pasted earlier. If you are using FC3 w/ SElinux bindings you won't be able to do it in /python It will have to be in the /var/www/html tree.
Also I added debugging so you can deug problems you experience.
<Location /var/www/html/python>
SetHandler python-program
PythonHandler mod_python.publisher
PythonDebug On
</Location>

/etc/init.d/httpd restart # Don't forget to restart apache as root or sudo

#/var/www/html/python/test.py The following goes in a file called test.py in the /var/www/html/python tree declred to be handled by mod_python.publisher above.
# test.py
def main(req, name="Secret Agent!"):
return "Hello %s" % name

point browser at http://yourURL/python/test.py
Reply With Quote
  #11  
Old 2nd March 2005, 01:48 PM
Secret Agent Offline
Registered User
 
Join Date: Nov 2004
Posts: 199
Ok... I inserted

<Location /var/www/html/python>
SetHandler python-program
PythonHandler mod_python.publisher
PythonDebug On
</Location>

at the very end of /usr/local/apache/conf.d/python.conf

Then restarted apache

But, /var/www/html/python does not exist inside /var/www/html

So I can't test the test.py

Am I supposed to create that directory or something? Also, if I remember correctly I'm supposed to enable mod_python in httpd.conf (however 'python' is not found anywhere in httpd.conf so i have to add loadmodule / addmodule ??)
Reply With Quote
  #12  
Old 2nd March 2005, 03:03 PM
jayemef's Avatar
jayemef Offline
Registered User
 
Join Date: Sep 2004
Location: Juniata College, PA
Age: 28
Posts: 629
I'm not familiar with cPanel, but are you just trying to write CGI scripts? If so, I don't think any of this is necessary. You just need to write scripts within your cgi-bin that a user can then request. When the user requests your script, any printing you have done to standard output will effectively be sent to his/her browser and displayed as a webpage (thus you will likely want/need to print out the necessary html tags). This is great when you need dynamic material.

As I said though, I'm not familiar with cPanel. You may be trying to do something completely unrelated.
__________________
- JMF
Registered Linux User #371168

+Fedora Core 3 - k2.6.10-1.766_FC3
+WindowMaker 0.91.0
Reply With Quote
  #13  
Old 2nd March 2005, 03:10 PM
Secret Agent Offline
Registered User
 
Join Date: Nov 2004
Posts: 199
Basically my clients were requesting mod_python

I just want to enable mod_python
Reply With Quote
  #14  
Old 2nd March 2005, 03:18 PM
jayemef's Avatar
jayemef Offline
Registered User
 
Join Date: Sep 2004
Location: Juniata College, PA
Age: 28
Posts: 629
I see. This is good, as mod_python is significantly more efficient than traditional CGI. I don't have much background with it though, unfortunately, so I don't really have any tips. Have you checked http://www.modpython.org/? The documentation and FAQ could be helpful.
__________________
- JMF
Registered Linux User #371168

+Fedora Core 3 - k2.6.10-1.766_FC3
+WindowMaker 0.91.0

Last edited by jayemef; 2nd March 2005 at 03:20 PM.
Reply With Quote
  #15  
Old 2nd March 2005, 05:21 PM
Secret Agent Offline
Registered User
 
Join Date: Nov 2004
Posts: 199
I don't know whats wrong with me but I cannot seem to get it right.

http://www.modpython.org/live/mod_py...configure.html

I did:

root@server [/usr/local/apache/bin]# ./configure --with-apxs=/usr/local/apache/bin/apxs
-bash: ./configure: No such file or directory

That apxs path is in fact correct and apxs is there in that directory too. Not sure what I am missing.

root@server [/usr/local/apache/bin]# python
Python 2.2.3 (#1, Feb 15 2005, 02:41:06)
[GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-49)] on linux2

root@server [/usr/local/apache/bin]# ./configure --with-python=/usr/local/src/Python-2.0
-bash: ./configure: No such file or directory

Right, I'm a noob but please help me
Reply With Quote
Reply

Tags
installation, python

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL-python installation help bhanu08 Servers & Networking 3 2nd April 2010 12:48 PM
Enthought Python Distribution installation problem llb Programming & Packaging 3 13th July 2008 08:23 AM
invalid Python installation _tone_ Using Fedora 1 4th May 2008 11:59 AM
Parallel Python 2.5 installation burkina76 Using Fedora 0 10th October 2007 04:09 PM
big problem-gtk module missing after python installation kjamal Using Fedora 1 14th May 2006 06:19 PM


Current GMT-time: 15:10 (Sunday, 19-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat