Looking back, the ending is too stupid, but I did it for the time being, so I recorded it.
Or, it is a request that "I want everything to work for the time being in the development environment itself with emacs and terminal open".
The bottom line is that you can go to ./manage.py runserver
, but mod_wsgi doesn't allow the last request.
Prepare python3.4.0 anyway
Based on that, use pyvenv to create a world dedicated to django 1.7
Make a project
Run via mod_wsgi in Apache2
xbuild/python-install 3.4.0 /opt/python3.4.0 /opt/python3.4.0/bin/pyvenv /opt/django1.7 source /opt/django1.7/bin/activate (django1.7) > which pip /opt/django1.7/bin/pip (django1.7) > pip install https://www.djangoproject.com/download/1.7b3/tarball/ .. (django1.7) > pip list Django (1.7b3) pip (1.5.4) setuptools (2.1) (django1.7) > cd /opt
(django1.7) > django-admin.py startproject mysite (django1.7) > cd mysite (django1.7) > ls manage.py mysite (django1.7) > ./manage.py syncdb .. (django1.7) > ./manage.py runserver (Visit http://localhost:8000/)
I was feeling like, "If you move this far, you'll win for the time being. The rest is the setting of apache2."
WSGIDaemonProcess mysite user=www-data group=www-data processes=2 threads=2 \
maximum-requests=100 umask=0007 \
python-path=/opt/mysite:/opt/django1.7/lib/python3.4/site-packages
WSGIScriptAlias /mysite /opt/mysite/mysite/wsgi.py
<Directory /opt/mysite/mysite>
<Files wsgi.py>
SetEnv PROCESS_GROUP mysite
Order deny,allow
Allow from all
</Files>
</Directory>
Make the SQLite DB writable from www-data for the time being.
(django1.7) > chmod 777 db.sqlite3
(django1.7) > chmod 777 .
(django1.7) > sudo service apache2 restart
(Visit http://localhost/mysite/admin)
Minor changes to urls.py and views.py to be confident that the version is really 3.4
urls.py
from django.conf.urls import patterns, include, url
from django.contrib import admin
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'mysite.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url(r'^admin/', include(admin.site.urls)),
url(r'^$', 'mysite.views.home', name='home'),
)
views.py
from django.http import HttpResponse
import sys
def home(request):
return HttpResponse(str(sys.version_info), content_type="text/plain")
If you run it from ./manage.py runserver (with venv activated)
sys.version_info(major=3, minor=4, micro=0, releaselevel='final', serial=0)
When running with apache2 + mod_wsgi
sys.version_info(major=3, minor=2, micro=3, releaselevel='final', serial=0)
Nyoro-n …… (If libapache2-mod-wsgi-py3 is not installed, this will be a 2.7 series and it will be even more shocking)
The apache2 log says it all.
[Thu May 01 17:01:31 2014] [notice] Apache/2.2.22 (Debian) mod_auth_tkt/2.1.0 PHP/5.4.4-14+deb7u9 mod_ssl/2.2.22 OpenSSL/1.0.1e mod_wsgi/3.3 Python/2.7.3 configured -- resuming normal operations
[Thu May 01 17:04:01 2014] [notice] caught SIGTERM, shutting down
[Thu May 01 17:04:02 2014] [warn] mod_wsgi: Compiled for Python/3.2.2rc1.
[Thu May 01 17:04:02 2014] [warn] mod_wsgi: Runtime using Python/3.2.3.
There orz
It's probably not possible to have multiple mod_wsgi, so I have to have Apache separately. If you do that, you should use docker or kvm. However, if you split the OS in that way, the configuration file will also split in all directions, so it is far from the initial request.
I got the idea of using a reverse proxy from tornado + apache. The fact that I didn't know the tornado so far made me tremble
No, but I knew both xbuild and pyenv today. There is no choice.
Recommended Posts