我遵循了本教程,该教程是各种教程推荐的,用于部署Django。
这是我的000-default.conf文件的内容..
更新“.conf”文件
<VirtualHost *:80>
Alias /static /home/myproject/static
<Directory /home/myproject/static>
Require all granted
</Directory>
<Directory /home/myproject/myproject>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess myproject python-home=/home/myproject/myprojectenv python-path=/home/myproject/myprojectenv/lib/python2.7/site-packages
WSGIProcessGroup myproject
WSGIScriptAlias / /home/myproject/myproject/wsgi.py
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
这是我第一次在配备“ubuntu-16.04-64bit”的VPS上部署Django网络应用程序。
我可以在启动virtualenv时使用“myproject”Django应用程序,并使用Django默认服务器:
./manage.py runserver 0.0.0.0:8000
并且能够使用my_ip成功打开myproject应用程序,my_ip由“xx.xxx.xxx.xx”和端口8000表示。
http://xx.xxx.xxx.xx:8000
虽然在停用virtualenv并按照给定教程的描述配置apache2服务器后它无法正常工作。
正如教程所说,在服务器上成功安装和配置Django应用程序之后,它应该只适用于您的IP:
http://xx.xxx.xxx.xx
在我的情况下哪个不起作用,而不是在浏览器上显示“等待xx.xxx.xxx.xx ....”的无穷大..页面显示错误,如此..
This site can’t be reached
xx.xxx.xxx.63 refused to connect.
Search Google for 188 167 8000
ERR_CONNECTION_REFUSED
并且它没有为apache2生成任何日志
ErrorLog /home/error.log
CustomLog /home/access.log combined
我从早上起就挣扎但没有成功请帮忙......
更新
Apache2错误日志:
[Thu Nov 09 03:38:23.800566 2017] [core:warn] [pid 8823:tid 140238720010112] AH00045: child process 8827 still did not exit, sending a SIGTERM
[Thu Nov 09 03:38:25.802552 2017] [core:warn] [pid 8823:tid 140238720010112] AH00045: child process 8827 still did not exit, sending a SIGTERM
[Thu Nov 09 03:38:27.804431 2017] [core:warn] [pid 8823:tid 140238720010112] AH00045: child process 8827 still did not exit, sending a SIGTERM
[Thu Nov 09 03:38:29.805890 2017] [core:error] [pid 8823:tid 140238720010112] AH00046: child process 8827 still did not exit, sending a SIGKILL
[Thu Nov 09 03:38:30.806571 2017] [mpm_event:notice] [pid 8823:tid 140238720010112] AH00491: caught SIGTERM, shutting down
[Thu Nov 09 03:38:31.551724 2017] [mpm_event:notice] [pid 8960:tid 140082895366016] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 configured -- resuming normal operations
[Thu Nov 09 03:38:31.551837 2017] [core:notice] [pid 8960:tid 140082895366016] AH00094: Command line: '/usr/sbin/apache2'
ImportError: No module named site
ImportError: No module named site
ImportError: No module named site
ImportError: No module named site
ImportError: No module named site
这是我的“wsgi.py”内容
"""
WSGI config for myproject project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")
application = get_wsgi_application()
答案 0 :(得分:0)
有关如何正确设置虚拟环境的mod_wsgi,请参阅:
ImportError: No module named site
的问题看起来像mod_wsgi可能无法针对您想要使用的相同Python版本进行编译。参见:
因为它是该问题的变体。
完成所有安装检查: