我一直对使用Ubuntu 16.04部署在Apache服务器上的应用程序感到头疼。我想可能是它在我的网站配置不当的问题,所以只部署一个测试应用程序test_app
和继Django documentation非常基本的说明和这里就是我在/etc/apache2/sites-available/000-default.conf
插入:在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>
而且,我看不到任何关于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
您是否尝试过使用WSGI hello world应用程序,而不是Django? http://modwsgi.readthedocs.io/en/develop/user-guides/quick-configuration-guide.html –
@GrahamDumpleton看起来像我必须先尝试一下。 –
@FaizanAli上面'要求所有授予',添加这一行 - '命令拒绝,允许'。看看它是否有效。 – xyres