2014-04-02 75 views
-1

我的Django的Apache部署服务Django模板为静态HTMLDjango的阿帕奇部署服务Django模板为静态HTML

我得到下面的标签在我的网页

{% 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 }} 

是不是有什么毛病我的部署配置

我在我的语言环境ubuntu盒子上使用Apache2进行部署。

+0

您的模板目录在settings.py文件中的外观如何? –

+0

TEMPLETE_DIRS =( '/ var/www/TEServices/templates', ) –

+0

当您没有提供任何有关您的Apache配置,您使用的URL,Django的详细信息时,我们希望诊断您的Apache安装程序urls.py和视图代码,或其他任何相关的? –

回答

0

最后我得到了它与下面的细节

创建.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() 

创建的.conf文件中的/ etc/apache2的/网站可用/

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

重启Apache服务器

1

我部署的设置: 项目结构法:

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 [email protected] 
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> 

相关问题