在apache上布置mod_python

1. apt-get install apache2

2. apt-get isntall libapache2-mod-python

 

3. vim /etc/apache2/httpd.conf :

     <Directory /var/www/test> AddHandler mod_python .py PythonHandler mytest PythonDebug On </Directory> 

4. mkdir /var/www/test

 

5.  cd /var/www/test

     touch mytest.py

     vim mytest.py

 

    from mod_python import apache def handler(req): req.content_type = 'text/plain' req.write("Hello,world!") return apache.OK 

6. /etc/init.d/apache2 restart

7. http://localhost/test/mytest.py  :Hello.world!

你可能感兴趣的:(在apache上布置mod_python)