mod_wsgi loading python script from wrong Pyramid app directory -


i have 2 apps identical code base (same functionality, different branding) trying virtual hosting using mod_wsgi , apache.

the virtual host settings both apps (in 2 separate files) identical (with exception of paths of course)

wsgipythonhome /home/ubuntu/baseline  <virtualhost *:80>     servername appa.com     serveralias www.appa.com     serveradmin admin@appa.com     documentroot /home/ubuntu/appa_virtualenv/appa-server/appa     errorlog /home/ubuntu/appa_virtualenv/appa-server/error.log     customlog /home/ubuntu/appa_virtualenv/appa-server/access.log combined      alias /static/ /home/ubuntu/appa_virtualenv/appa-server/appa/appa/static/      wsgiapplicationgroup %{global}     wsgipassauthorization on     wsgidaemonprocess appa user=www-data group=www-data \         python-path=/home/ubuntu/appa_virtualenv/lib/python2.7/site-packages/ \         home=/home/ubuntu/appa_virtualenv/appa-server/appa/     wsgiprocessgroup appa     wsgiscriptalias / /home/ubuntu/appa_virtualenv/appa-server/appa.wsgi      <directory /home/ubuntu/appa_virtualenv/appa-server>         wsgiprocessgroup appa         order allow,deny         allow     </directory> </virtualhost> 

.

<virtualhost *:80>     servername appb.com     serveralias www.appb.com     serveradmin admin@appb.com     documentroot /home/ubuntu/appb_virtualenv/server/appb     errorlog /home/ubuntu/appb_virtualenv/server/error.log     customlog /home/ubuntu/appb_virtualenv/server/access.log combined      alias /static/ /home/ubuntu/appb_virtualenv/server/appb/appb/static/      wsgiapplicationgroup %{global}     wsgipassauthorization on     wsgidaemonprocess appb user=www-data group=www-data \         python-path=/home/ubuntu/appb_virtualenv/lib/python2.7/site-packages/ \         home=/home/ubuntu/appb_virtualenv/server/appb/     wsgiprocessgroup appb     wsgiscriptalias / /home/ubuntu/appb_virtualenv/server/appb.wsgi      <directory /home/ubuntu/appb_virtualenv/server>         wsgiprocessgroup appb         order allow,deny         allow     </directory> </virtualhost> 

contents of appa.wsgi

import os os.environ['python_egg_cache'] = '/home/ubuntu/appa_virtualenv/appa-server/python-eggs'  pyramid.paster import get_app, setup_logging ini_path = '/home/ubuntu/appa_virtualenv/appa-server/appa/development.ini' setup_logging(ini_path) application = get_app(ini_path, 'main') 

contents of appb.wsgi

import os os.environ['python_egg_cache'] = '/home/ubuntu/appb_virtualenv/server/python-eggs'  pyramid.paster import get_app, setup_logging ini_path = '/home/ubuntu/appb_virtualenv/server/appb/development.ini' setup_logging(ini_path) application = get_app(ini_path, 'main') 

i enabled both sites in apache , realize when accessing appa, python scripts in appb's directory loaded instead. confirmed adding print statement in __init__.py of both apps , text appb printed when try access appa.

i disabled appb $ sudo a2dissite appb. appb.com fails load, appa.com still loading appb's codes...

i added following appb __init__.py (note: not appa)

print sys.path[0] print os.getcwd() 

the outputs are

/home/ubuntu/appa_virtualenv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg /home/ubuntu/appa_virtualenv/appa-server/appa 

which beyond comprehension because output point correctly appa's directory, yet print added appb's __init__.py located in /home/ubuntu/appb_virtualenv/server/appb/appb/__init__.py

also, have disabled appb , apache settings no longer refer appb's directory anywhere anymore, why appa still loading appb's scripts?!

what doing wrong? settings need change appa load scripts in own directory? thanks


additional checks suggested graham

embedded or daemon mode

  • daemon mode: mod_wsgi.process_group = 'appa'

sub interpreter being used

  • main interpreter: mod_wsgi.application_group = ''

request environment

  • path_translated: '/home/ubuntu/appa_virtualenv/appa-server/appa.wsgi/'
  • server_name: 'appa.com'
  • script_filename: '/home/ubuntu/appa_virtualenv/appa-server/appa.wsgi'
  • mod_wsgi.application_group: ''
  • mod_wsgi.process_group: 'appa'
  • mod_wsgi.version: (3, 4)

nothing looks issue on first glance.

use:

to confirm process , application group each executing in.

use:

to see server_name set each in requests.

edit question results.


update 1

where there 2 virtualhost's in apache configuration, 1 cause of requests ending @ first virtualhost , never reaching second because namevirtualhost directive isn't being specified port virtualhost's listening on. on linux isn't problem though port 80 on default.

the other reason can occur because host name used in url doesn't match either servername or serveralias in desired virtualhost. when happens apache fallback directing url first virtualhost found when apache configuration file read. catch when occurring, idea declare default virtualhost read first , denies access. @ least way request not end @ wrong virtualhost , blocked.

for details of issue falling first read virtualhost, see discussion in:

try defining default virtualhost , see whether issue of falling first virtualhost issue. can workout issue apache configuration causing occur.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -