使apache服务器在mod_python下正确运行的问题

发布于 2024-08-07 23:19:29 字数 2678 浏览 6 评论 0原文

我们尝试将旧服务器迁移到新服务器,但 mod_python 遇到了一些问题。

问题出在此网页下:

http://auction.tinyerp.org /auction-in-europe.com/aie/

这是我们的 apache2 配置:

NameVirtualHost *
<VirtualHost *>


 DocumentRoot /var/www/
 <Directory />
  Options FollowSymLinks
  AllowOverride all
 </Directory>
 <Directory "/var/www/auction-in-europe.com/aie">
  Options Indexes FollowSymLinks MultiViews
  #AddHandler mod_python .py
  PythonOption mod_python.legacy.importer *
  SetHandler mod_python
                PythonHandler mod_python.publisher
      PythonDebug On
  AllowOverride all
  Order allow,deny
  allow from all
  # This directive allows us to have apache2's default start page
                # in /apache2-default/, but still have / go to the right place
 </Directory>

 ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
 <Directory "/usr/lib/cgi-bin">
  AllowOverride None
  Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
  Order allow,deny
  Allow from all
 </Directory>

 ScriptAlias /bin/ /home/www/auction-in-europe.com/aie/bin/
 ServerAdmin [email protected]
 ErrorLog /home/logs/auction-in-europe.com/error_log
 CustomLog /home/logs/auction-in-europe.com/access_log combined
 ServerName auction-in-europe.com
 ServerAlias www.auction-in-europe.com antique-in-europe.com www.antique-in-europe.com art-in-europe.com www.art-in-europe.com en.art-in-europe.com
 ServerAlias en.antique-in-europe.com en.auction-in-europe.com fr.antique-in-europe.com fr.art-in-europe.com fr.auction-in-europe.com auction.tinyerp.org
 #RewriteEngine on
 #RewriteRule ^/(.*)\.html /index.py [E=pg:$1]

 ErrorLog /var/log/apache2/error.log

 # Possible values include: debug, info, notice, warn, error, crit,
 # alert, emerg.
 LogLevel warn

 CustomLog /var/log/apache2/access.log combined
 ServerSignature On

 Alias /doc/ "/usr/share/doc/"
 <Directory "/usr/share/doc/">
  Options Indexes MultiViews FollowSymLinks
  AllowOverride None
  Order deny,allow
  Deny from all
  Allow from 127.0.0.0/255.0.0.0 ::1/128
 </Directory>
 <Directory /home/www/postfixadmin>
 </Directory>

</VirtualHost>

日志非常空:

[Mon Oct 12 13:25:58 2009] [notice] mod_python: (Re)importing module 'mod_python.publisher'
[Mon Oct 12 13:25:58 2009] [notice] [client 212.166.58.166] Publisher loading page /home/www/auction-in-europe.com/aie/index.py

我真的不知道从哪里开始。

请帮忙!

We try to migrate our old server to a new one but we experienced some problems with mod_python.

The problem is under this web page:

http://auction.tinyerp.org/auction-in-europe.com/aie/

Here is our apache2 configuration:

NameVirtualHost *
<VirtualHost *>


 DocumentRoot /var/www/
 <Directory />
  Options FollowSymLinks
  AllowOverride all
 </Directory>
 <Directory "/var/www/auction-in-europe.com/aie">
  Options Indexes FollowSymLinks MultiViews
  #AddHandler mod_python .py
  PythonOption mod_python.legacy.importer *
  SetHandler mod_python
                PythonHandler mod_python.publisher
      PythonDebug On
  AllowOverride all
  Order allow,deny
  allow from all
  # This directive allows us to have apache2's default start page
                # in /apache2-default/, but still have / go to the right place
 </Directory>

 ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
 <Directory "/usr/lib/cgi-bin">
  AllowOverride None
  Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
  Order allow,deny
  Allow from all
 </Directory>

 ScriptAlias /bin/ /home/www/auction-in-europe.com/aie/bin/
 ServerAdmin [email protected]
 ErrorLog /home/logs/auction-in-europe.com/error_log
 CustomLog /home/logs/auction-in-europe.com/access_log combined
 ServerName auction-in-europe.com
 ServerAlias www.auction-in-europe.com antique-in-europe.com www.antique-in-europe.com art-in-europe.com www.art-in-europe.com en.art-in-europe.com
 ServerAlias en.antique-in-europe.com en.auction-in-europe.com fr.antique-in-europe.com fr.art-in-europe.com fr.auction-in-europe.com auction.tinyerp.org
 #RewriteEngine on
 #RewriteRule ^/(.*)\.html /index.py [E=pg:$1]

 ErrorLog /var/log/apache2/error.log

 # Possible values include: debug, info, notice, warn, error, crit,
 # alert, emerg.
 LogLevel warn

 CustomLog /var/log/apache2/access.log combined
 ServerSignature On

 Alias /doc/ "/usr/share/doc/"
 <Directory "/usr/share/doc/">
  Options Indexes MultiViews FollowSymLinks
  AllowOverride None
  Order deny,allow
  Deny from all
  Allow from 127.0.0.0/255.0.0.0 ::1/128
 </Directory>
 <Directory /home/www/postfixadmin>
 </Directory>

</VirtualHost>

Logs are quite empty:

[Mon Oct 12 13:25:58 2009] [notice] mod_python: (Re)importing module 'mod_python.publisher'
[Mon Oct 12 13:25:58 2009] [notice] [client 212.166.58.166] Publisher loading page /home/www/auction-in-europe.com/aie/index.py

I really have no idea where to start.

Please help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你是暖光i 2024-08-14 23:19:29

那是index.py吗?我相信你正在混淆你的安装。如果您不想编写自己的处理程序,则可以使用“PythonHandler mod_python.publisher”。您刚刚发布的文件包含一个处理程序,如下行:

def handler(req):
   return app.run(apacheapp.Request(req)) 

这很难排除故障,但我相信您的 apache 配置应该更接近此:

 <Directory "/var/www/auction-in-europe.com/aie">
   Order allow,deny
   Allow from all
   SetHandler python-program .py
   PythonHandler index ## or what ever the above file is called without the .py
   PythonDebug On   
  </Directory>

这将使所有请求发送到“/var/www/auction-in-europe.txt”。 com/aie”由index.py处理。

Is that the index.py? I believe you are mixing up your install. You use the "PythonHandler mod_python.publisher" if you do not want to write your own handler. The file you just posted contains a handler, the lines:

def handler(req):
   return app.run(apacheapp.Request(req)) 

This is rather difficult to trouble-shoot but I believe your apache config should be closer to this:

 <Directory "/var/www/auction-in-europe.com/aie">
   Order allow,deny
   Allow from all
   SetHandler python-program .py
   PythonHandler index ## or what ever the above file is called without the .py
   PythonDebug On   
  </Directory>

This will make all requests to "/var/www/auction-in-europe.com/aie" get handled by index.py.

dawn曙光 2024-08-14 23:19:29

#!/usr/bin/python
import os, sys
base_dir = "/home/www/auction-in-europe.com/aie/"
sys.path.insert(0, base_dir)
import albatross
import sql_db
from albatross.apacheapp import Request
from albatross import apacheapp
from albatross.template import Content, EmptyTag, EnclosingTag
import string
import common
class AppContext(albatross.SessionFileAppContext):
   def __init__(self, app):
       albatross.SessionFileAppContext.__init__(self, app)
#        path = os.environ.get('PATH_INFO','').split('/')
#        path = filter(lambda x: x, path)
#        self.module = path.pop(0)
#        self.path = {}
#        while path:
#            val = path.pop()
#            self.path[ path.pop() ] = val
   def load_template_once(self, template):
       new_template = os.path.join(self.lang_get(),template)
       return albatross.SessionFileAppContext.load_template_once(new_template)
   def load_template(self, template):
             new_template = os.path.join(self.lang_get(),template)
       return albatross.SessionFileAppContext.load_template(self,new_template)
   def run_template_once(self, template):
       new_template = os.path.join(self.lang_get(), template)
       return albatross.SessionFileAppContext.run_template_once(self,new_template)
   def run_template(self, template):
       new_template = os.path.join(self.lang_get(), template)
       return albatross.SessionFileAppContext.run_template(self,new_template)
   def req_get(self):
       return self.current_url()[len(self.base_url())+1:]
   def args_calc(self):
       path = self.current_url()[len(self.base_url())+1:].split('/')
       path = filter(lambda x: x, path)
       if not len(path):
           path=['index']
       self.module = path.pop(0)
       self.path = {}
       while path:
           val = path.pop()
           self.path[ path.pop() ] = val
   def lang_get(self):
       if self.request.get_header('host')[:3] in ('fr.','en.'):
           return self.request.get_header('host')[:2]
       try:
           language = self.request.get_header('Accept-Language')
           if language:
               new_lang = language[:2]
               if new_lang in ('fr','en'):
                   return new_lang
       except:
           return 'en'
       return 'en'
   def hostname_get(self):
       if self.request.get_header('host')[-17:]=='art-in-europe.com':
           return 'art'
       elif self.request.get_header('host')[-21:]=='antique-in-europe.com':
           return 'antique'
       else:
           return 'auction'
   def module_get(self):
       self.args_calc()
       return self.module
   def path_get(self, key):
       self.args_calc()
       return self.path[key]
class App(albatross.ModularSessionFileApp):
   def __init__(self):
       albatross.ModularSessionFileApp.__init__(self,
           base_url = '/index.py',
           module_path = os.path.join(base_dir, 'modules'),
           template_path = os.path.join(base_dir, 'template'),
           start_page = 'index',
           secret = '(=-AiE-)',
           session_appid='A-i-E',
           session_dir='/var/tmp/albatross/')
   def create_context(self):
       return AppContext(self)
class alx_a(albatross.EnclosingTag):
   name = 'alx-a'
   def to_html(self, ctx):
       ctx.write_content('')
       albatross.EnclosingTag.to_html(self, ctx)
       ctx.write_content('')
# Escape text for attribute values
def escape_br(text):
   text = str(text)
   text = string.replace(text, '&', '&')
   text = string.replace(text, '', '>',)
   text = string.replace(text, '"', '"')
   text = string.replace(text, "'", '')
   text = string.replace(text, "\n", '
') return text class alx_value(EmptyTag): name = 'alx-value' def __init__(self, ctx, filename, line_num, attribs): EmptyTag.__init__(self, ctx, filename, line_num, attribs) #self.compile_expr() def to_html(self, ctx): value = ctx.eval_expr(self.get_attrib('expr')) format = self.get_attrib('date') if format: value = time.strftime(format, time.localtime(value)) ctx.write_content(value) return lookup_name = self.get_attrib('lookup') if lookup_name: lookup = ctx.get_lookup(lookup_name) if not lookup: self.raise_error('undefined lookup "%s"' % lookup_name) lookup.lookup_html(ctx, value) return if self.has_attrib('noescape'): ctx.write_content(str(value)) else: ctx.write_content(escape_br(value)) app = App() app.register_tagclasses(alx_a) app.register_tagclasses(alx_value) def handler(req): return app.run(apacheapp.Request(req))

#!/usr/bin/python
import os, sys
base_dir = "/home/www/auction-in-europe.com/aie/"
sys.path.insert(0, base_dir)
import albatross
import sql_db
from albatross.apacheapp import Request
from albatross import apacheapp
from albatross.template import Content, EmptyTag, EnclosingTag
import string
import common
class AppContext(albatross.SessionFileAppContext):
   def __init__(self, app):
       albatross.SessionFileAppContext.__init__(self, app)
#        path = os.environ.get('PATH_INFO','').split('/')
#        path = filter(lambda x: x, path)
#        self.module = path.pop(0)
#        self.path = {}
#        while path:
#            val = path.pop()
#            self.path[ path.pop() ] = val
   def load_template_once(self, template):
       new_template = os.path.join(self.lang_get(),template)
       return albatross.SessionFileAppContext.load_template_once(new_template)
   def load_template(self, template):
             new_template = os.path.join(self.lang_get(),template)
       return albatross.SessionFileAppContext.load_template(self,new_template)
   def run_template_once(self, template):
       new_template = os.path.join(self.lang_get(), template)
       return albatross.SessionFileAppContext.run_template_once(self,new_template)
   def run_template(self, template):
       new_template = os.path.join(self.lang_get(), template)
       return albatross.SessionFileAppContext.run_template(self,new_template)
   def req_get(self):
       return self.current_url()[len(self.base_url())+1:]
   def args_calc(self):
       path = self.current_url()[len(self.base_url())+1:].split('/')
       path = filter(lambda x: x, path)
       if not len(path):
           path=['index']
       self.module = path.pop(0)
       self.path = {}
       while path:
           val = path.pop()
           self.path[ path.pop() ] = val
   def lang_get(self):
       if self.request.get_header('host')[:3] in ('fr.','en.'):
           return self.request.get_header('host')[:2]
       try:
           language = self.request.get_header('Accept-Language')
           if language:
               new_lang = language[:2]
               if new_lang in ('fr','en'):
                   return new_lang
       except:
           return 'en'
       return 'en'
   def hostname_get(self):
       if self.request.get_header('host')[-17:]=='art-in-europe.com':
           return 'art'
       elif self.request.get_header('host')[-21:]=='antique-in-europe.com':
           return 'antique'
       else:
           return 'auction'
   def module_get(self):
       self.args_calc()
       return self.module
   def path_get(self, key):
       self.args_calc()
       return self.path[key]
class App(albatross.ModularSessionFileApp):
   def __init__(self):
       albatross.ModularSessionFileApp.__init__(self,
           base_url = '/index.py',
           module_path = os.path.join(base_dir, 'modules'),
           template_path = os.path.join(base_dir, 'template'),
           start_page = 'index',
           secret = '(=-AiE-)',
           session_appid='A-i-E',
           session_dir='/var/tmp/albatross/')
   def create_context(self):
       return AppContext(self)
class alx_a(albatross.EnclosingTag):
   name = 'alx-a'
   def to_html(self, ctx):
       ctx.write_content('')
       albatross.EnclosingTag.to_html(self, ctx)
       ctx.write_content('')
# Escape text for attribute values
def escape_br(text):
   text = str(text)
   text = string.replace(text, '&', '&')
   text = string.replace(text, '', '>',)
   text = string.replace(text, '"', '"')
   text = string.replace(text, "'", '')
   text = string.replace(text, "\n", '
') return text class alx_value(EmptyTag): name = 'alx-value' def __init__(self, ctx, filename, line_num, attribs): EmptyTag.__init__(self, ctx, filename, line_num, attribs) #self.compile_expr() def to_html(self, ctx): value = ctx.eval_expr(self.get_attrib('expr')) format = self.get_attrib('date') if format: value = time.strftime(format, time.localtime(value)) ctx.write_content(value) return lookup_name = self.get_attrib('lookup') if lookup_name: lookup = ctx.get_lookup(lookup_name) if not lookup: self.raise_error('undefined lookup "%s"' % lookup_name) lookup.lookup_html(ctx, value) return if self.has_attrib('noescape'): ctx.write_content(str(value)) else: ctx.write_content(escape_br(value)) app = App() app.register_tagclasses(alx_a) app.register_tagclasses(alx_value) def handler(req): return app.run(apacheapp.Request(req))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文