apache - 如何在 Virtualhost 上设置 Django?
问题描述
如何使用 Django 应用程序设置 apache2 虚拟主机。目前我正在通过“python manage.py runserver”使用 Django。我需要远程托管 Django 应用程序。
解决方案
您需要编辑/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>
推荐阅读
- php - 在 yii2 basic 中调用控制器时出错
- wordpress - 在 wordpress 帖子循环中跳过三个帖子
- ruby-on-rails - 如何在多个 vps 服务器上运行 rails 应用程序以保持其性能良好?
- java - 如何进行 setter 和 getter 测试并使结果主要输出?
- javascript - 如何在 JavaScript 中包含 PHP 文件并传递参数
- php - 如何为 webview android 创建 id 并使用 php 获取 id
- dart - Flutter:如何在英雄动画期间更改子元素的大小?
- javascript - 在 oidc 保护的点网核心控制器中授权属性
- php - 在 PHP 中获取一组行的程序具有相同的代码结构,但在另一个上没有结果
- python - DNSSEC 使用 dnspython 错误:AttributeError: 'NS' object has no attribute 'is_absolute'