[英]Django + Apache - Can't find directory of my website
我已經使用django框架完成了一個網站。 現在,我正在嘗試使用apache + wsgi進行部署。 這是我的設置。 所以我有一個IP 59.120.185.12,這是我的.config:
<VirtualHost *:80>
ServerName www.vbgetech.com
ServerAlias vbgetech.com
ServerAdmin webmaster@localhost
Alias /media/ /home/max/v_bridge/media/
Alias /static/ /home/max/v_bridge/static/
<Directory /home/max/v_bridge/media>
Require all granted
</Directory>
<Directory /home/max/v_bridge/static>
Require all granted
</Directory>
WSGIScriptAlias / /home/max/v_bridge/v_bridge/wsgi.py
<Directory /home/max/v_bridge/v_bridge/>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
這是我的wsgi.py
"""
WSGI config for website 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.8/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
from os.path import join,dirname,abspath
PROJECT_DIR = dirname(dirname(abspath(__file__)))#3
import sys # 4
sys.path.insert(0,PROJECT_DIR) # 5
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "v_bridge.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
我想我確實遵循了官方文件的所有指示。 而且看來,如果我在瀏覽器上輸入ip,它仍然會返回我一個apache默認頁面。 我猜這是因為我的服務器無法將ip映射到.conf文件。 有人對此有想法嗎?
您應該使用URL http://www.vbgetech.com
訪問該站點。 您不一定必須使用IP地址。 如果使用IP,則將不會通過主機名對VirtualHost
匹配,因此該請求將由Apache配置文件中的第一個VirtualHost
或默認的VirtualHost
。 如果您從未更改過默認的VirtualHost
,它將為您提供默認頁面。
換句話說,如果您添加了一個新的VirtualHost
並且VirtualHost
默認的VirtualHost
,那么您將不得不在URL中使用正確的主機名來使其與VirtualHost
相匹配。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.