On Mon, May 18, 2009 at 06:39:41AM -0700, Jan Koprowski wrote:
> I use mod_wsgi 2.5 under Apache 2.
> My WSGI applications is in /home/username/public_wsgi/wsgi/myapp.wsgi
> where public_wsgi is directory where i have production.ini file.
> My myapp.wsgi file looks like follows:
>
> -------------- myapp.wsgi --------------
> WORKING_ENV = "/home/username/public_wsgi"
> APP_CONFIG = "/home/username/production.ini"
>
> import sys
> sys.path.append(WORKING_ENV)
>
> from paste.deploy import loadapp
> application = loadapp("config:" + APP_CONFIG)
> -------------- myapp.wsgi --------------
>
> All looks working right when Pylons app runing under / address like
> something.server.com/ but my app is hosted in server.com/something.
> Apache configuration of WSGI:
>
> -------------- WSGI apache config.py --------------
> WSGIScriptAlias /panel /home/username/public_wsgi/wsgi/myapp.wsgi
> WSGIDaemonProcess username user=username group=username processes=7
> threads=17 display-name=wsgi:appname python-eggs=/username/public_wsgi/
> data/eggs-cache
> WSGIProcessGroup username
> <Directory /home/username/public_wsgi/wsgi>
> Order deny,allow
> Allow from all
> </Directory>
> -------------- WSGI apache config.py --------------
>
> DocumentRoot for this serwer is set to /some/path/to/www and i don't
> want change this. But after I host Pylons app under server.com/
> something i get following errors in apache logs
>
> File does not exist: /some/path/to/www/stylesheets, referer:
> http://server.com/something/controllername/actionname
> File does not exist: /some/path/to/www/images, referer:
> http://server.com/something/controllername/actionname
>
> What i should change to get working images/stylsheets links which
> should bet getting from /home/username/public_wsgi/projectname/public
> not DocumentRoot
There are two parts to the solution:
1. You have to generate correct URLs pointing to /panel/images/ and
/panel/stylesheets. This means using, e.g.
<img src="${url('/images/foo.png')}" />
instead of
<img src="/images/foo.png" />
It also means no static HTML files in your Pylons app public/
folder, unless those files use relative URLs
2. You have to tell your Pylons app that it lives at /panel and not at
the website root.
I don't know offhand how to do that with mod_wsgi. Maybe it already
does this automatically. AFAIU it's a matter of setting
SCRIPT_NAME and PATH_INFO correctly in the WSGI environment.
I use Apache's mod_proxy + paster serve, and to get correct URLs from
the Pylons app I have
[filter:proxy-prefix]
use = egg:PasteDeploy#prefix
prefix = /control_panel
in my deployment.ini, and Apache has
ProxyPass /control_panel http://localhost:5000/control_panel
As an alternative, you could put Alias directives in your apache config
and point /images and /stylesheets to your WSGI app's public directory.
If you're fine with the URLs being /images and /stylesheets without the
/panel prefix, and if you're sure you won't encounter the same problem
with other static resources in your app's public/ subdir.
Marius Gedminas
--
Hacking graphics in X is like finding sqrt(pi) with roman numerals.
-- man xdaliclock
signature.asc
Description: Digital signature
