I'll leave it as a memo, but Backlift at the URL below may be easy to remember with the service. Also, the directory structure has changed in the Django version, so that needs to be fixed.
http://jp.techcrunch.com/2013/04/11/20130410yc-backlift-launch/
Directory structure
sample
|-wsgi
|-dispatch.wsgi
|-src
|-sample
|-settings.py
|-・ ・ ・
dispatch.wsgi
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import site
import sys
sys.stdout = sys.stderr
PROJECT_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
# Add the virtual Python environment site-packages directory to the path
site.addsitedir(os.path.join(PROJECT_ROOT, 'python', 'lib', 'python2.7', 'site-packages'))
# Avoid ``[Errno 13] Permission denied: '/var/www/.python-eggs'`` messages
os.environ['PYTHON_EGG_CACHE'] = os.path.join(PROJECT_ROOT, 'wsgi', 'egg-cache')
#If your project is not on your PYTHONPATH by default you can add the following
sys.path.append(os.path.join(PROJECT_ROOT, 'src', 'sample'))
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
Place the following files in sites-available
sample
<VirtualHost *:80>
ServerName Server name
# Log Files
ErrorLog /var/log/apache2/sample.error-lostquery.log
CustomLog /var/log/apache2/sample.access-lostquery.log combined
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule .*robots\.txt$ ~/sample/www/robots.txt [L]
Alias /www/ ~/sample/www/
<Directory ~/sample/www>
Order deny,allow
Allow from all
</Directory>
# Setup mod_wsgi
WSGIScriptAlias / ~/sample/wsgi/dispatch.wsgi
<Directory ~/sample/wsgi>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
After activating the site with Apache, restart
Recommended Posts