2017-03-20 13 views
0

私は、Ubuntu 16.04を使用してApacheサーバーにデプロイするアプリケーションに対して頭を悩ましています。UbuntuでApacheを使用したDjangoアプリケーションのデプロイ16.04

WSGIScriptAlias//var/www/html/python/test_app/test_app/wsgi.py 

#WSGIPythonHome /var/www/html/python/test_app/venv 
#WSGIPythonPath /var/www/html/python/test_app 

Alias /static/ /var/www/html/python/test_app/static/ 

<Directory /var/www/html/python/test_app/static> 
Order allow,deny 
Allow from all 
Require all granted 
</Directory> 


<Directory /var/www/html/python/test_app/test_app> 
<Files wsgi.py> 
Order allow,deny 
Allow from all 
Require all granted 
</Files> 
</Directory> 

そして、私が見ることができない:私はかもしれそれは、私のサイトでの設定ミスの問題ですので、単なるテストアプリtest_appを展開し、Django documentation上の非常に基本的な手順に従い、ここで私は私の/etc/apache2/sites-available/000-default.confに挿入されたものだと思いましたlocalhostのもの。私は構成を正しくしていますか?ここで

がログに発生したエラーです:だから

[Mon Mar 20 14:19:16.518151 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998] mod_wsgi (pid=12272): Target WSGI script '/var/www/html/python/test_app/test_app/wsgi.py' cannot be loaded as Python module. 
[Mon Mar 20 14:19:16.518215 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998] mod_wsgi (pid=12272): Exception occurred processing WSGI script '/var/www/html/python/test_app/test_app/wsgi.py'. 
[Mon Mar 20 14:19:16.518241 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998] Traceback (most recent call last): 
[Mon Mar 20 14:19:16.518278 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998] File "/var/www/html/python/test_app/test_app/wsgi.py", line 17, in <module> 
[Mon Mar 20 14:19:16.518351 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998]  application = get_wsgi_application() 
[Mon Mar 20 14:19:16.518366 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998] File "/usr/local/lib/python2.7/dist-packages/django/core/wsgi.py", line 13, in get_wsgi_application 
[Mon Mar 20 14:19:16.518406 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998]  django.setup(set_prefix=False) 
[Mon Mar 20 14:19:16.518421 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998] File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 22, in setup 
[Mon Mar 20 14:19:16.518462 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998]  configure_logging(settings.LOGGING_CONFIG, settings.LOGGING) 
[Mon Mar 20 14:19:16.518476 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 53, in __getattr__ 
[Mon Mar 20 14:19:16.518571 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998]  self._setup(name) 
[Mon Mar 20 14:19:16.518586 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 41, in _setup 
[Mon Mar 20 14:19:16.518605 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998]  self._wrapped = Settings(settings_module) 
[Mon Mar 20 14:19:16.518618 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 97, in __init__ 
[Mon Mar 20 14:19:16.518634 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998]  mod = importlib.import_module(self.SETTINGS_MODULE) 
[Mon Mar 20 14:19:16.518648 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998] File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module 
[Mon Mar 20 14:19:16.518694 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998]  __import__(name) 
[Mon Mar 20 14:19:16.518719 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998] ImportError: No module named test_app.settings 
+0

Djangoではなく、WSGI hello worldアプリケーションで試しましたか? http://modwsgi.readthedocs.io/en/develop/user-guides/quick-configuration-guide.html –

+0

@GrahamDumpletonは私が最初に試してみなければならないように見えます。 –

+0

@FaizanAli 'Require all'の上に、' Order deny、allow'という行を追加します。それが動作するかどうかを確認します。 – xyres

答えて

0

、最後に...私はそれを考え出しました!あなたの助けを借りてくれてありがとう。エラーログで私の最初の行として

は言う:wsgi.py意味

'/var/www/html/python/test_app/test_app/wsgi.py' cannot be loaded as Python module.

Apacheモジュールにアクセスできませんでした。私はここでそれを探して、solutionを得ました。

import os, sys 
from django.core.wsgi import get_wsgi_application 
sys.path.append('/var/www/html/python/test_app') 

、それが働いた:

だから、私のwsgi.pyで、私はこれを追加しました。

+1

http://modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.htmlを読むことをお勧めします。デーモンモードを使用し、 '' python-home''とあなたの場所を使ってPython仮想環境を設定します'' python-path''を使ってプロジェクトを作成します。 –

関連する問題