Pwan Pwan - 1 month ago 4x
Apache Configuration Question

Django + Apache - Can't find directory of my website

I have done a website by using django framework. Now I'm trying to deploy using apache+wsgi. Here is my setting.
So I have a ip and here is my .config:

<VirtualHost *:80>
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 /home/max/v_bridge/static>
Require all granted

WSGIScriptAlias / /home/max/v_bridge/v_bridge/

<Directory /home/max/v_bridge/v_bridge/>
Require all granted

And its my

WSGI config for website project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see

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()

I think I do follow all the instruction by official document. And It seems that If I type the ip on browser it still return me a apache default page. I guess that is because my server can't map the ip to the .conf file. Anyone has idea about it?


You should access the site using the URL You can't necessarily use the IP address. If you use the IP it will not match by host name lookup against VirtualHost and so the request will instead be handled by the first VirtualHost in the Apache configuration file, or in other words the default VirtualHost. That default VirtualHost is going to give you the default page if you never changed it.

In other words, if you added a new VirtualHost and didn't modify the default one, then you are going to have to use a proper host name in the URL for it to match your VirtualHost.