hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Hosting Security and Technology : Hosting Security and Technology Tutorials : mod_python DSO compilation
Reply

Hosting Security and Technology Tutorials Tutorials related to server security or the like.
Forum Jump

mod_python DSO compilation

Reply Post New Thread In Hosting Security and Technology Tutorials Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 02-10-2004, 05:06 AM
case case is offline
Riiiiiiiiiiiiight...
 
Join Date: Apr 2002
Location: Hollywood Proper, CA
Posts: 3,044

mod_python DSO compilation


Ok, this is a really simple way to give your users the ability to run python without recompling apache. Most of this information can be found in the mod_python help files.

PLEASE NOTE:
this tutorial is specific to :

apache 1.3x
mod_python Release 2.7.8 (do not try Release 3.0.4)

====================================================
Side notes:
Chances are, python is already installed on your system. A couple easy way's to check are

Redhat:
root@newyork> rpm -q python
python-2.2.3-5

BSD:
-bash-2.05b$ pkg_info python*

Information for python-2.2.1:

Comment:
An interpreted object-oriented programming language

Required by:
libxml2-2.4.23
p5-XML-LibXML-1.52
libxslt-1.0.19

Description:
Python is an interpreted object-oriented programming language, and is
often compared to Tcl, Perl or Scheme.

If you're having some problems finding python on bsd, you can also try :

-bash-2.05b$ pkg_info | less

hopefully you see something similiar to :

python-2.2.1 An interpreted object-oriented programming language

Being this is not a python installed tutorial, i will not be lending any assistance to those who do not have or cannot get python on there system (this probably isnt you anyways =] )

====================================================


First step:(make sure you're in a comfortable directory)

wget http://mirrors.midco.net/pub/apache....hon-2.7.10.tgz

Second Step:

tar -zxvf mod_python-2.7.10.tgz

Third Step:

cd mod_python-2.7.10

forth step:

./configure --with-apxs=/usr/local/apache/bin/apxs

Fifth step:

make

Sixth Step:

make dso

Seventh Step: ( $su and or sudo prior, if not already root)

make install

Eighth Step: (tell Apache to load the module)
note (use the editor of your choice)

vi /etc/httpd/conf/httpd.conf

or

vi /usr/local/apache/conf/httpd.conf

Find the portion of your httpd.conf file that looks like this :

#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Please read the file http://httpd.apache.org/docs/dso.html for more
# details about the DSO mechanism and run `httpd -l' for the list of already
# built-in (statically linked and thus always available) modules in your httpd
# binary.
#
# Note: The order in which modules are loaded is important. Don't change
# the order below without expert advice.
#
# Example:
# LoadModule foo_module libexec/mod_foo.so


once you have found it, add the line below:

LoadModule python_module libexec/mod_python.so

NOTE:
If your Apache configuration uses ClearModuleList directive, you will need to add mod_python to the module list in the Apache configuration file.

Locate : (usually right below the above mentioned)

# Reconstruction of the complete module list from all available modules
# (static and shared ones) to achieve correct module execution order.
# [WHENEVER YOU CHANGE THE LOADMODULE SECTION ABOVE UPDATE THIS, TOO]
ClearModuleList


once you have found it, add the line below:

AddModule mod_python.c

Nineth Step:

locate :

<VirtualHost xx.xx.xx.xx>
ServerAlias www.xxxxx.com xxxxx.com
ServerAdmin webmaster@xxxxx.com
DocumentRoot /home/xxxxx/public_html
BytesLog domlogs/xxxxx.com-bytes_log
ServerName www.xxxxx.com
User xxxxx
Group xxxxx
CustomLog domlogs/xxxxx.com combined
ScriptAlias /cgi-bin/ /home/xxxxx/public_html/cgi-bin/
</VirtualHost>

directly underneath is add:

<Directory /home/xxxxx/public_html/>
AddHandler python-program .py
PythonHandler mptest
PythonDebug On
</Directory>


change the /home/xxxxx/public_html/ to the folders of users who you want to have this feature. Every user who you want to be able to use mod_python must have their own

Tenth Step:

Restart Apache:

/usr/local/apache/bin/apachectl restart

you may notice:
Loaded DSO libexec/mod_python.so uses plain Apache 1.3 API, this module might crash under EAPI! (please recompile it with -DEAPI)

this is a documented SSL bug and nothing to be concerned with.

Eleventh Step:

Testing it out.. Lets go ahead and get into a web folder you specified in httpd.conf to test this. In my case it's :

cd /home/xxxxx/public_html/

Once were there:

vi test.py

and lets add: (be careful, windows machines like to add useless characters)

from mod_python import apache

def handler(req):
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;req.send_http_header()
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;req.write("python is installed!")
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return apache.OK


using your browser, navigate to the test.py file: If you did everything right you should see:

python is installed!

give yourself a pat on the back, update your features list... and enjoy


Last edited by case; 02-10-2004 at 05:18 AM.
Reply With Quote


Sponsored Links
  #2  
Old 02-10-2004, 03:10 PM
Doggy Doggy is offline
Disabled
 
Join Date: Oct 2003
Location: Portugal
Posts: 62
Nice

Reply With Quote
  #3  
Old 02-10-2004, 04:39 PM
Pheaton Pheaton is offline
Web Hosting Master
 
Join Date: Oct 2003
Location: Georgetown, Ontario
Posts: 1,761
What exactly is python. Ive heard of it before, but im unclear as to what it is exactly. Is it a programming language or something of the sort?

<edit>signature removed</edit>


Last edited by choon; 02-17-2004 at 03:26 PM.
Reply With Quote
Sponsored Links
  #4  
Old 02-11-2004, 12:33 AM
case case is offline
Riiiiiiiiiiiiight...
 
Join Date: Apr 2002
Location: Hollywood Proper, CA
Posts: 3,044
yo

python is actually quite (for lack of a better word) neat. I also find its a decent primer for beginner programing. If you're interested make your way to:

http://www.python.org/

Reply With Quote
  #5  
Old 02-16-2004, 11:09 PM
daveman daveman is offline
Web Hosting Master
 
Join Date: Sep 2002
Posts: 873
Looks good, thanks.

<edit>signature removed</edit>


Last edited by choon; 02-17-2004 at 03:27 PM.
Reply With Quote
  #6  
Old 02-17-2004, 06:25 AM
devilbala devilbala is offline
Junior Guru Wannabe
 
Join Date: Feb 2004
Location: India
Posts: 45
You can get an neat documentation related to mod_python at there website,

As you may know the beauty of mod_python is in it can be linked dynamically with apache rather than re-compiling apache to add this module.

Just 10 minutes work for an professional to do it (If everything went on fine).

Regards,

-Devil

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Softaculous Launches AMPPS Installer Version 1.5 Web Hosting News 2012-01-26 16:52:40
Internet Backbone Provider Hurricane Electric Upgrades Global Peering Bandwidth Web Hosting News 2011-11-16 18:14:57
Netcraft Survey Names Rackspace Most Reliable Web Hosting Site in October Web Hosting News 2011-11-02 19:13:38
Web Host A2 Hosting Launches QuickInstaller Tool for VPS Plans Web Hosting News 2011-08-19 20:00:53
Communications Software Firm 4PSA Launches Developer Resource Website Web Hosting News 2011-07-06 20:38:56


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?