Страница 1 из 1

Apache + mod_python

Добавлено: 2014-02-17 10:18:03
tray.irk
Есть задача запускать Python скрипты через апач. Поставил mod_python ...

Код: Выделить всё

<VirtualHost *:80>
    ServerAdmin email@gmail.com
    DocumentRoot /usr/local/www/apache22/virtualhosts/ta_web.octi.org
    ServerName ta_web.octi.org
    <Directory />
PythonPath "['/usr/local/www/apache22/virtualhosts/ta_web.octi.org']"
AddHandler python-program .py
PythonHandler 1
PythonDebug On
allow from all
Options +Indexes

   </Directory>
</VirtualHost>

в папке создал файл 1.py

Код: Выделить всё


print('Content-type: text/html\n') # http-заголовок плюс пустая строка
print('<title>Reply Page</title>') # html-разметка ответа
print('<h1>Who are you?</h1>')
print('<h1>Hello <i>%s</i>!</h1>')
при открытии скрипта

Код: Выделить всё

MOD_PYTHON ERROR

ProcessId:      99539
Interpreter:    'ta_web.octi.org'

ServerName:     'ta_web.octi.org'
DocumentRoot:   '/usr/local/www/apache22/virtualhosts/ta_web.octi.org'

URI:            '/1.py'
Location:       None
Directory:      '/'
Filename:       '/usr/local/www/apache22/virtualhosts/ta_web.octi.org/1.py'
PathInfo:       ''

Phase:          'PythonHandler'
Handler:        '1'

Traceback (most recent call last):

  File "/usr/local/lib/python2.7/site-packages/mod_python/importer.py", line 1537, in HandlerDispatch
    default=default_handler, arg=req, silent=hlist.silent)

  File "/usr/local/lib/python2.7/site-packages/mod_python/importer.py", line 1206, in _process_target
    object = apache.resolve_object(module, object_str, arg, silent=silent)

  File "/usr/local/lib/python2.7/site-packages/mod_python/apache.py", line 696, in resolve_object
    raise AttributeError, s

AttributeError: module '/usr/local/www/apache22/virtualhosts/ta_web.octi.org/1.py' contains no 'handler'

Первый раз столкнулся с питоном, раньше даже не работал с ним.

Re: Apache + mod_python

Добавлено: 2014-02-17 10:19:26
tray.irk

Код: Выделить всё

web# pkg_info | grep python
ap22-mod_python-3.3.1_3 Apache module that embeds the Python interpreter within the
python27-2.7.3_6    An interpreted object-oriented programming language
python33-3.3.0_2    An interpreted object-oriented programming language

Re: Apache + mod_python

Добавлено: 2014-02-26 6:15:15
tray.irk
up

Re: Apache + mod_python

Добавлено: 2014-02-26 13:45:46
hizel
Попытайтесь, таки, прочитать начало документации по mod_python. Хотя бы примеры осильте.