Revision history [back]
Serving from a subdirectory
Okay, I'm making a lot of progress. I want to serve Askbot from mysite.com/ask/, and furthermore, I don't want mysite.com/ being handled by WSGI/Django. As far as I can tell, that means I need to have e.g. WSGIScriptAlias /ask ...
, as opposed to WSGIScriptAlias / ...
. Specifically, when I had ASKBOT_URL = 'ask/'
and WSGIScriptAlias / ...
, mysite.com/wiki/ was getting handled by Django.
I pretty much have it working how I want, after doing the following:
- Leave
ASKBOT_URL
as''
- In settings.py, set
ASKBOT_MEDIA_URL = 'ask/'
- In askbot/skins/utils.py, in
get_media_url
, have it useASKBOT_MEDIA_URL
instead ofASKBOT_URL
- In the apache config, change the aliases given from e.g.
/upfiles/
to/ask/upfiles/
Everything seems to work, except that logging in and logging out takes people to /, not /ask/.
The question: What's the right way to fix this? Am I going about the subdirectory thing all wrong?
Here's the relevant part of my apache config:
#replace with 127.0.0.1 with real IP address
<VirtualHost 123.345.567.789:80>
ServerAdmin admin@mysite.com
DocumentURL /opt/webapps/
ServerName mysite.com
#aliases to serve static media directly
#will probably need adjustment
Alias /ask/m/ /usr/local/lib/python2.6/dist-packages/askbot-0.6.11-py2.6.egg/askbot/skins/
Alias /ask/upfiles/ /opt/webapps/ask/askbot/upfiles/
Alias /ask/admin/media/ /usr/local/lib/python2.6/dist-packages/django/contrib/admin/media/
<DirectoryMatch "/opt/webapps/ask/askbot/skins/([^/]+)/media">
Order deny,allow
Allow from all
</DirectoryMatch>
<Directory "/opt/webapps/ask/askbot/upfiles">
Order deny,allow
Allow from all
</Directory>
#must be a distinct name within your apache configuration
WSGIDaemonProcess askbot2
WSGIProcessGroup askbot2
WSGIScriptAlias /ask /opt/webapps/ask/django.wsgi
#make all admin stuff except media go through secure connection
#<LocationMatch "/admin(?!/media)">
# RewriteEngine on
# RewriteRule /admin(.*)$ https://example.com/admin$1 [L,R=301]
#</LocationMatch>
CustomLog /var/log/apache2/askbot/access_log common
ErrorLog /var/log/apache2/askbot/error_log
LogLevel debug
</VirtualHost>
Serving from a subdirectory
Okay, I'm making a lot of progress. I want to serve Askbot from mysite.com/ask/, and furthermore, I don't want mysite.com/ being handled by WSGI/Django. As far as I can tell, that means I need to have e.g. WSGIScriptAlias /ask ...
, as opposed to WSGIScriptAlias / ...
. Specifically, when I had
and ASKBOT_URL ASKBOT_ROOT = 'ask/'WSGIScriptAlias / ...
, mysite.com/wiki/ was getting handled by Django.
I pretty much have it working how I want, after doing the following:
- Leave
asASKBOT_URLASKBOT_ROOT''
- In settings.py, set
ASKBOT_MEDIA_URLASKBOT_MEDIA_ROOT = 'ask/' - In askbot/skins/utils.py, in
get_media_url
, have it use
instead ofASKBOT_MEDIA_URLASKBOT_MEDIA_ROOTASKBOT_URLASKBOT_ROOT - In the apache config, change the aliases given from e.g.
/upfiles/
to/ask/upfiles/
Everything seems to work, except that logging in and logging out takes people to /, not /ask/.
The question: What's the right way to fix this? Am I going about the subdirectory thing all wrong?
Here's the relevant part of my apache config:
#replace with 127.0.0.1 with real IP address
<VirtualHost 123.345.567.789:80>
ServerAdmin admin@mysite.com
DocumentURL DocumentRoot /opt/webapps/
ServerName mysite.com
#aliases to serve static media directly
#will probably need adjustment
Alias /ask/m/ /usr/local/lib/python2.6/dist-packages/askbot-0.6.11-py2.6.egg/askbot/skins/
Alias /ask/upfiles/ /opt/webapps/ask/askbot/upfiles/
Alias /ask/admin/media/ /usr/local/lib/python2.6/dist-packages/django/contrib/admin/media/
<DirectoryMatch "/opt/webapps/ask/askbot/skins/([^/]+)/media">
Order deny,allow
Allow from all
</DirectoryMatch>
<Directory "/opt/webapps/ask/askbot/upfiles">
Order deny,allow
Allow from all
</Directory>
#must be a distinct name within your apache configuration
WSGIDaemonProcess askbot2
WSGIProcessGroup askbot2
WSGIScriptAlias /ask /opt/webapps/ask/django.wsgi
#make all admin stuff except media go through secure connection
#<LocationMatch "/admin(?!/media)">
# RewriteEngine on
# RewriteRule /admin(.*)$ https://example.com/admin$1 [L,R=301]
#</LocationMatch>
CustomLog /var/log/apache2/askbot/access_log common
ErrorLog /var/log/apache2/askbot/error_log
LogLevel debug
</VirtualHost>