首页 > 解决方案 > 如何在 Virtualhost 上设置 Django?

问题描述

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

标签: apachelaravel-5django-rest-frameworkreact-redux

解决方案


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

示例虚拟主机配置(阅读更多)

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>

推荐阅读