Configuring Django with mod_python, Apache on SuSE with an alias

I'm having serious problems with Django working with my Apache configuration. I did not create a server, so I do not have too many features for the server to work. Essentially, there are three virtual hosts:

board.site.org, students.site.org and insider.site.org

The main question that concerns me is insider.site.org. I am responsible for the small site below it (ideally at insider.site.org/tech). I decided to put my files separately from the source directory, because it was not by chance that something messed up there (since the site that does not contain python is already in place). Anyway, my virtual hosts are defined in separate files in / etc / apache 2 / vhosts.d /

Here's what insider.site.org configuration looks like

insider.conf

LoadModule python_module /usr/lib64/apache2/mod_python.so

<VirtualHost 10.10.1.1:80>
ServerName insider.site.org
DocumentRoot /media/nss/VWEB/docs
   <Directory /media/nss/VWEB/docs>
      Options Indexes Multiviews
      AllowOverride None
      Order Allow,Deny
      #Allow from 10.11.0.78
      Allow from all
   </Directory>

Alias /tech  /srv/www/Tech

   <Directory /srv/www/Tech>
      SetHandler python-program
      PythonPath "['/srv/www/Tech'] + sys.path"
      PythonHandler django.core.handlers.modpython
      SetEnv DJANGO_SETTINGS_MODULE Tech.settings
      PythonDebug On
   </Directory>


Alias /media /srv/www/Media

   <Directory /srv/www/Media>
      SetHandler None
   </Directory>

</VirtualHost>
  • , , site.org, , - "site.org".

, , - http://insider.site.org/tech/ :

Mod_python: "PythonHandler mod_python.publisher"

Traceback ( ):

"/usr/lib64/python2.4/site-packages/mod_python/apache.py", 299, HandlerDispatch     result = object (req)

"/usr/lib64/python2.4/site-packages/mod_python/publisher.py", 98,      = [])

"/usr/lib64/python2.4/site-packages/mod_python/apache.py", 454, import_module     f, p, d = imp.find_module ( [i], )

ImportError:

http://insider.site.org/tech ( ) 403. Django , ( _ init _.py , ( django )), , . : - (

, .

+3
3

, , Django PythonPath, ? PythonPath , django , bin, contrib, admin, core .. __init__.py. ( , Apache , , .) :

<Location "/myapp">
   SetHandler python-program
   PythonHandler django.core.handlers.modpython
   SetEnv DJANGO_SETTINGS_MODULE LogFileAnalyzer.settings
   PythonDebug on
   PythonPath "['/srv/www/dir_containing_django_dir', '/srv/www/myapp_dir'] + sys.path"
</Location>

, Location Directory , .

mod_rewrite. . . , , :

RewriteEngine  on
RewriteBase    /~quux/
RewriteRule    ^foo$  foo/  [R]

, .

+2

Alias /tech /srv/www/Tech , <Directory /srv/www/Tech> .

, Apache Python, , Python, .

, , Django- "" . , .

mod_wsgi. Django, :)

+1

, mod_python, mod_python - Django ( Python ).

, mod_wsgi , . , #django freenode.

Spawning/FastCGI , Apache.

0
source

Source: https://habr.com/ru/post/1703756/


All Articles