内容
Djangoを使ってウェブアプリを作成したいと考え,とりあえず作成したテストプロジェクトをデプロイしようとしましたがうまく行きませんでした.
まず,デプロイしようとした手順を大まかに示します.
テストプロジェクトのパスは
/var/www/jyugyou
です.(このパスにmanage.pyがある)
そして,Apacheのconf.d下に置いたdjango.confの中身は以下の通りです.
LoadModule wsgi_module /usr/lib64/python3.5/site-packages/mod_wsgi/server/mod_wsgi-py35.cpython-35m-x86_64-linux-gnu.so WSGIScriptAlias /django /var/www/jyugyou/jyugyou/wsgi.py WSGIPythonPath /var/www/jyugyou WSGIPythonPath /usr/lib/python3.5/site-packages WSGIPythonPath /usr/lib64/python3.5/site-packages <Directory /var/www/jyugyou/jyugyou> <Files wsgi.py> Order deny,allow Allow from all </Files> </Directory>
(調べつつだったので何か抜けているかもしれませんが)この状態でsystemctl restart httpd
としたところ正常に起動し,直下に別で設置していたindex.htmlにはアクセスし表示できました.しかし,django.conf
で設定したディレクトリにhttps://[addres]/django
としてアクセスしようとすると,Internal Server Errorと表示されてしまいうまく行きませんでした.
該当するApacheのエラーログは以下の通りでした.
[Sat Sep 23 16:00:41.769589 2017] [mpm_prefork:notice] [pid 19137] AH00163: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/5.4.16 mod_wsgi/3.4 Python/2.7.5 configured -- resuming normal operations [Sat Sep 23 16:00:41.769648 2017] [core:notice] [pid 19137] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND' [Sat Sep 23 16:00:45.593949 2017] [:error] [pid 19139] [client ::1:51866] mod_wsgi (pid=19139): Target WSGI script '/var/www/jyugyou/jyugyou/wsgi.py' cannot be loaded as Python module. [Sat Sep 23 16:00:45.593998 2017] [:error] [pid 19139] [client ::1:51866] mod_wsgi (pid=19139): Exception occurred processing WSGI script '/var/www/jyugyou/jyugyou/wsgi.py'. [Sat Sep 23 16:00:45.594021 2017] [:error] [pid 19139] [client ::1:51866] Traceback (most recent call last): [Sat Sep 23 16:00:45.594044 2017] [:error] [pid 19139] [client ::1:51866] File "/var/www/jyugyou/jyugyou/wsgi.py", line 12, in <module> [Sat Sep 23 16:00:45.594108 2017] [:error] [pid 19139] [client ::1:51866] from django.core.wsgi import get_wsgi_application [Sat Sep 23 16:00:45.594119 2017] [:error] [pid 19139] [client ::1:51866] File "/usr/lib64/python3.5/site-packages/django/core/wsgi.py", line 2, in <module> [Sat Sep 23 16:00:45.594158 2017] [:error] [pid 19139] [client ::1:51866] from django.core.handlers.wsgi import WSGIHandler [Sat Sep 23 16:00:45.594167 2017] [:error] [pid 19139] [client ::1:51866] File "/usr/lib64/python3.5/site-packages/django/core/handlers/wsgi.py", line 8, in <module> [Sat Sep 23 16:00:45.594250 2017] [:error] [pid 19139] [client ::1:51866] from django import http [Sat Sep 23 16:00:45.594261 2017] [:error] [pid 19139] [client ::1:51866] File "/usr/lib64/python3.5/site-packages/django/http/__init__.py", line 5, in <module> [Sat Sep 23 16:00:45.594300 2017] [:error] [pid 19139] [client ::1:51866] from django.http.response import ( [Sat Sep 23 16:00:45.594310 2017] [:error] [pid 19139] [client ::1:51866] File "/usr/lib64/python3.5/site-packages/django/http/response.py", line 13, in <module> [Sat Sep 23 16:00:45.594452 2017] [:error] [pid 19139] [client ::1:51866] from django.core.serializers.json import DjangoJSONEncoder [Sat Sep 23 16:00:45.594463 2017] [:error] [pid 19139] [client ::1:51866] File "/usr/lib64/python3.5/site-packages/django/core/serializers/__init__.py", line 23, in <module> [Sat Sep 23 16:00:45.594552 2017] [:error] [pid 19139] [client ::1:51866] from django.core.serializers.base import SerializerDoesNotExist [Sat Sep 23 16:00:45.594565 2017] [:error] [pid 19139] [client ::1:51866] File "/usr/lib64/python3.5/site-packages/django/core/serializers/base.py", line 4, in <module> [Sat Sep 23 16:00:45.594641 2017] [:error] [pid 19139] [client ::1:51866] from django.db import models [Sat Sep 23 16:00:45.594651 2017] [:error] [pid 19139] [client ::1:51866] File "/usr/lib64/python3.5/site-packages/django/db/models/__init__.py", line 3, in <module> [Sat Sep 23 16:00:45.594700 2017] [:error] [pid 19139] [client ::1:51866] from django.db.models.aggregates import * # NOQA [Sat Sep 23 16:00:45.594709 2017] [:error] [pid 19139] [client ::1:51866] File "/usr/lib64/python3.5/site-packages/django/db/models/aggregates.py", line 5, in <module> [Sat Sep 23 16:00:45.594786 2017] [:error] [pid 19139] [client ::1:51866] from django.db.models.expressions import Func, Star [Sat Sep 23 16:00:45.594796 2017] [:error] [pid 19139] [client ::1:51866] File "/usr/lib64/python3.5/site-packages/django/db/models/expressions.py", line 5, in <module> [Sat Sep 23 16:00:45.595043 2017] [:error] [pid 19139] [client ::1:51866] from django.db.backends import utils as backend_utils [Sat Sep 23 16:00:45.595054 2017] [:error] [pid 19139] [client ::1:51866] File "/usr/lib64/python3.5/site-packages/django/db/backends/utils.py", line 12, in <module> [Sat Sep 23 16:00:45.595131 2017] [:error] [pid 19139] [client ::1:51866] from django.utils.timezone import utc [Sat Sep 23 16:00:45.595141 2017] [:error] [pid 19139] [client ::1:51866] File "/usr/lib64/python3.5/site-packages/django/utils/timezone.py", line 8, in <module> [Sat Sep 23 16:00:45.595224 2017] [:error] [pid 19139] [client ::1:51866] import pytz [Sat Sep 23 16:00:45.595244 2017] [:error] [pid 19139] [client ::1:51866] ImportError: No module named pytz
wsgi.py
が読み込めていないのかなあという気はしますが,解決法が全くわからず詰まってしまいました.どなたか解決法を教えていただけないでしょうか.
環境
- Cent OS7
- Python3.5(pyenv等ではなく,yumを使って入れたもの)
- Django1.11.5
- Apache 2.4.6
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/09/23 07:53 編集