2010-01-29 4 views
1

1) J'essaie de configurer un nouvel environnement Web pour héberger le code python + psycopg2. Voici mes étapes:Problème Installation et exécution psycopg2 + Windows + Apache2 + mod_wsgi

2) Télécharger http://modwsgi.googlecode.com/files/mod_wsgi-win32-ap22py26-3.0.so

3) Copier mod_wsgi-win32-ap22py26-3.0.so à C: \ Program Files modules \ Apache Software Foundation \ Apache2.2 \, et renommez comme mod_wsgi.so

Ajouter les nouvelles lignes suivantes dans C: \ Program Files \ Apache Software Foundation \ Apache2.2 \ conf \ httpd.conf

LoadModule wsgi_module modules/mod_wsgi.so 
WSGIScriptAlias /wsgi/ "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/wsgi/" 

4) Enregistrer un fichier nommé C: \ Program Files \ Apache Software Foundation \ Apache2.2 \ htdocs \ wsgi \ myapp.py avec le contenu suivant:

def application(environ, start_response): 
    status = '200 OK' 
    output = 'Hello World!' 

    response_headers = [('Content-type', 'text/plain'), 
         ('Content-Length', str(len(output)))] 
    start_response(status, response_headers) 

    return [output] 

5) Accès à l'aide http://localhost/wsgi/myapp.py

6) Installer http://www.stickpeople.com/projects/python/win-psycopg/psycopg2-2.0.13.win32-py2.6-pg8.4.1-release.exe

7) Si je modifie le contenu du fichier à

import psycopg2 

def application(environ, start_response): 
    status = '200 OK' 
    output = 'Hello World!' 

    response_headers = [('Content-type', 'text/plain'), 
         ('Content-Length', str(len(output)))] 
    start_response(status, response_headers) 

    return [output] 

Je vais obtenir

ImportError: Aucun module nommé psycopg2

Comment puis-je dire apache, j'avais installer le module psycopg2 dans C: \ Python26

8 Je lance le script autonome suivant pour montrer que psycopg2 a été installé.

import psycopg2 

print "Hello, World!" 

Je cours à l'aide

C:\Documents and Settings\yan-cheng.cheok\Desktop>mypython.py 
Hello, World! 

Semblent mon environnement python est OK.

Répondre

1

Je suis en mesure de résoudre le problème, en déplaçant script python dehors htdocs

WSGIScriptAlias /wsgi "C:/wsgi/" 

<Directory "C:/wsgi"> 
    AllowOverride None 
    Options None 
    Order deny,allow 
    Allow from all 
</Directory> 
+0

Cela devrait avoir des problèmes ainsi que lors du mappage dans un répertoire de la barre oblique sur l'URL où il monte en WSGIScriptAlias ​​ligne est importante. –

Questions connexes