2012-06-24 5 views
1

Django 프로젝트를 프로덕션 서버로 마이그레이션하는 데 어려움이 있습니다. 여기 상황이 있습니다. 내 최종 결과 페이지 (HTML 소스)이 같은 같습니다Django를 프로덕션 서버로 마이그레이션

Number of exponentials: 1 <br /><br /> 
Function: 98.919106*2.71828182845905**(-0.014026249*t) <br /><br /> 
Parameters of exponentials: {&#39;a&#39;: [98.919105999999999], &#39;k&#39;: [0.014026248999999999], &#39;c&#39;: [0]} <br /><br /> 
Non physical solution: False <br /><br /> 

<img src="plots/data_2e_03.png" alt="some_text"/> 

그것은 내 장고 응용 프로그램에서 데이터로 채워진 템플릿입니다. 템플릿은 다음과 같습니다.

Number of exponentials: {{rp.user_choice.number_of_exponentials}} <br /><br /> 
Function: {{rp.user_choice.function}} <br /><br /> 
Parameters of exponentials: {{rp.user_choice.parameters_of_exponentials}} <br /><br /> 
Non physical solution: {{rp.user_choice.non_physical_solution}} <br /><br /> 

<img src="plots/{{rp.input_file_name}}.png" alt="some_text"/> 

문제는 이미지가 표시되지 않는 것입니다. alt 만 인쇄됩니다. HTML 소스 (위의 붙여 넣기)를 확인하면 HTML 소스에서 링크로/data_2e_03.png 줄거리가 표시됩니다. 클릭하면 다른 페이지의 소스로 이동합니다.

<html><head> 
<title>500 Internal Server Error</title> 
</head><body> 
<h1>Internal Server Error</h1> 
<p>The server encountered an internal error or 
misconfiguration and was unable to complete 
your request.</p> 
<p>Please contact the server administrator, 
[no address given] and inform them of the time the error occurred, 
and anything you might have done that may have 
caused the error.</p> 
<p>More information about this error may be available 
in the server error log.</p> 
<hr> 
<address>Apache/2.2.16 (Debian) Server at bioinformatika.djangoserver Port 80</address> 
</body></html> 

가 여기 내 아파치 사이트 구성입니다 :

Alias /plots/ /home/user/bioinformatika/Server/bioinformatika/bioinformatika/plots/ 

<Directory /home/user/bioinformatika/Server/bioinformatika/bioinformatika/plots> 
Order deny,allow 
Allow from all 
</Directory> 

다른 부분은 아파치 설정에 대한 있습니다 : 아파치 내 미디어 파일을 처리시키기의 목적

<VirtualHost *:80> 

ServerName bioinformatika.djangoserver 
DocumentRoot /home/user/bioinformatika/Server/bioinformatika/apache 

Alias /plots/ /home/user/bioinformatika/Server/bioinformatika/bioinformatika/plots/ 

<Directory /home/user/bioinformatika/Server/bioinformatika/bioinformatika/plots> 
Order deny,allow 
Allow from all 
</Directory> 


<Directory /home/user/bioinformatika/Server/bioinformatika/apache> 
    Order allow,deny 
    Allow from all 
</Directory> 

WSGIDaemonProcess bioinformatika.djangoserver processes=2 threads=15 display-name=%{GROUP} 
WSGIProcessGroup bioinformatika.djangoserver 

WSGIScriptAlias//home/user/bioinformatika/Server/bioinformatika/apache/django.wsgi 

, 나는 추가 mod_wsgi과 Django가 작동하고 있습니다.

일단 Django settings.py에서 디버그를 제거합니다. 소스가 표시된 페이지 (내부 서버 오류 포함)가 렌더링되어 브라우저에 표시됩니다.

[Sun Jun 24 11:22:15 2012] [error] [client 192.168.0.14]  return callback(request, **param_dict) 
[Sun Jun 24 11:22:15 2012] [error] [client 192.168.0.14] File "/home/user/bioinformatika/virtual_bio/lib/python2.6/site-packages/Django-1.4-py2.6.egg/django/utils/decorators.py", line 91, in _wrapped_view 
[Sun Jun 24 11:22:15 2012] [error] [client 192.168.0.14]  response = view_func(request, *args, **kwargs) 
[Sun Jun 24 11:22:15 2012] [error] [client 192.168.0.14] File "/home/user/bioinformatika/virtual_bio/lib/python2.6/site-packages/Django-1.4-py2.6.egg/django/views/defaults.py", line 32, in server_error 
[Sun Jun 24 11:22:15 2012] [error] [client 192.168.0.14]  t = loader.get_template(template_name) # You need to create a 500.html template. 
[Sun Jun 24 11:22:15 2012] [error] [client 192.168.0.14] File "/home/user/bioinformatika/virtual_bio/lib/python2.6/site-packages/Django-1.4-py2.6.egg/django/template/loader.py", line 145, in get_template 
[Sun Jun 24 11:22:15 2012] [error] [client 192.168.0.14]  template, origin = find_template(template_name) 
[Sun Jun 24 11:22:15 2012] [error] [client 192.168.0.14] File "/home/user/bioinformatika/virtual_bio/lib/python2.6/site-packages/Django-1.4-py2.6.egg/django/template/loader.py", line 138, in find_template 
[Sun Jun 24 11:22:15 2012] [error] [client 192.168.0.14]  raise TemplateDoesNotExist(name) 
[Sun Jun 24 11:22:15 2012] [error] [client 192.168.0.14] TemplateDoesNotExist: 500.html 

어떤 조언은 감사 : /etc/log/apache2/error.log는 다음과 같은 수 있습니다. 이상한 행동이 내 서버 설정과 관련이있을 수 있다고 생각하고 내 기본 설정이 아니라 쉽게 해결할 수있는 문제가 될 수 있습니다. 내 아파치 설정이 올바른지 확인해 주시면 고맙겠습니다.

업데이트 :

경로 문제가 잘못 구성되었습니다. STATIC_URL, STATIC_ROOT, MEDIA_URL 및 MEDIA_ROOT의 의미는 완전히 진단 할 수없는 배포 문제에 대한 문제를 야기한 내게 불분명했습니다.

그러나이를 피하는 방법은 개발 및 프로덕션 서버에서 파일을 제공하는 방법에 대한 개념적 지식을 얻는 것입니다.

답변

4

DEBUG이 아닌 모드에서 서버를 표시하려면 projectname/templates 폴더에서 500.html이라는 파일을 만들어야합니다. 비슷한 목적으로 404.html 파일을 만들어야합니다.

또한 settings.TEMPLATE_DIRS에는 서버의 프로젝트 이름/템플릿 폴더에 대한 절대 경로가 포함되어 있어야합니다.

관련 문제