如何在Virtualhost上设置Django?

时间:2019-05-27 07:24:26

标签: apache laravel-5 django-rest-framework react-redux

如何使用Django应用设置apache2虚拟主机。目前,我正在通过“ python manage.py runserver”使用Django。我需要远程托管Django应用。

1 个答案:

答案 0 :(得分:0)

您需要编辑/etc/apache2/sites-available/000-default.conf,并将指向/var/www/html的基于php的虚拟主机配置替换为指向项目的wsgi.py的配置。

虚拟主机配置示例(read more)

Alias /robots.txt /path/to/mysite.com/static/robots.txt
Alias /favicon.ico /path/to/mysite.com/static/favicon.ico

Alias /media/ /path/to/mysite.com/media/
Alias /static/ /path/to/mysite.com/static/

<Directory /path/to/mysite.com/static>
Require all granted
</Directory>

<Directory /path/to/mysite.com/media>
Require all granted
</Directory>

WSGIScriptAlias / /path/to/mysite.com/mysite/wsgi.py

<Directory /path/to/mysite.com/mysite>
<Files wsgi.py>
Require all granted
</Files>
</Directory>