Python django apache部署将django模板作为静态html提供
我的django apache部署将django模板作为静态html提供 我在我的网页上看到下面的标签Python django apache部署将django模板作为静态html提供,python,django,apache,deployment,Python,Django,Apache,Deployment,我的django apache部署将django模板作为静态html提供 我在我的网页上看到下面的标签 {% if cmd %} {{ cmd }} {% endif %} {% if command %} {{ command}} Running python script baby....wait... {% endif %} {% if documents %} {% for document in documents %} {% endfor %} {% else %} No docu
{% if cmd %} {{ cmd }} {% endif %} {% if command %} {{ command}}
Running python script baby....wait...
{% endif %} {% if documents %}
{% for document in documents %} {% endfor %}
{% else %}
No documents.
{% endif %} {% csrf_token %}
{{ form.non_field_errors }}
我的部署配置是否有问题
我正在使用Apache2在我的语言环境ubuntu框中进行部署。最后我使用了以下详细信息 为您的项目创建一个.wsgi文件(比如mysite.wsgi),其中包含以下信息,最好是在项目内部的任何位置
import os
import sys
path = '/home/synerzip/Documents/pavanWork/mysite'
if path not in sys.path:
sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
在/etc/apache2/sites available/
<VirtualHost *:80>
WSGIScriptAlias / /path/to/.wsgi # file which is created in above step
ServerName mysite.com # Name of your site
Alias /static/ /path/to/your/project /static/files
<Directory /path/to/your/project />
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
WSGIScriptAlias//path/to/.wsgi#文件,该文件在上述步骤中创建
ServerName mysite.com#您的站点名称
别名/static//path/to/your/project/static/files
命令允许,拒绝
通融
重新启动apache服务器我的部署设置:
项目结构:
sites/
└── motivate-me.local
├── project
│ ├── api
│ │ ├── __pycache__
│ │ └── v1
│ │ └── __pycache__
│ └── project
│ └── __pycache__
└── static
├── admin
│ ├── css
│ ├── img
│ │ └── gis
│ └── js
│ └── admin
└── rest_framework
├── css
├── img
└── js
django.wsgi:
import os
import sys
sys.path.append('/home/mikhail/sites/motivate-me.local/')
sys.path.append('/home/mikhail/sites/motivate-me.local/project/')
sys.path.append('/usr/local/lib/python3.3/dist-packages')
os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings'
from django.core.handlers.wsgi import WSGIHandler
application = WSGIHandler()
我的主人:
127.0.0.1 localhost
127.0.0.2 www
127.0.0.3 loss-weight.local
127.0.0.4 test.local
127.0.0.5 motivate-me.local
127.0.1.1 ube-work
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
我的虚拟主机:
<VirtualHost 127.0.0.5:80>
ServerAdmin webmaster@motivate-me.local
ServerName motivate-me.local
ServerAlias motivate-me.local
WSGIScriptAlias / /home/mikhail/sites/motivate-me.local/project.wsgi
WSGIPassAuthorization on
DocumentRoot /home/mikhail/sites/motivate-me.local
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/mikhail/sites/motivate-me.local/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
Alias /static/ /home/mikhail/sites/motivate-me.local/static/
<Location "/static/">
Options -Indexes
</Location>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
服务器管理员webmaster@motivate-我是本地人
ServerName-me.local
ServerAlias-me.local
WSGIScriptAlias//home/mikhail/sites/motivate-me.local/project.wsgi
WSGIPassAuthorization on
DocumentRoot/home/mikhail/sites/motivate-me.local
选项如下符号链接
不允许超限
选项索引跟随符号链接多视图
不允许超限
命令允许,拒绝
通融
别名/static//home/mikhail/sites/motivate-me.local/static/
选项-索引
ScriptAlias/cgi-bin//usr/lib/cgi-bin/
不允许超限
选项+执行CGI-多视图+符号链接所有者匹配
命令允许,拒绝
通融
ErrorLog${APACHE_LOG_DIR}/error.LOG
#可能的值包括:调试、信息、通知、警告、错误、临界值、,
#警惕,埃默格。
日志级别警告
CustomLog${APACHE\u LOG\u DIR}/access.LOG组合
别名/doc/“/usr/share/doc/”
选项索引多视图跟随符号链接
不允许超限
命令拒绝,允许
全盘否定
允许从127.0.0.0/255.0.0.0::1/128开始
您的模板目录在settings.py文件中的外观如何?TEMPLETE_DIRS=(“/var/www/TEServices/templates”),如果您没有提供有关Apache配置、正在使用的URL、Django URL.py和视图代码或其他任何相关信息,我们将如何诊断您的Apache设置?