Answer the question
In order to leave comments, you need to log in
Django not starting on server?
Good afternoon!
The essence of the problem is that the project does not start under Apache, everything is fine from the console.
Error log 500 Internal Server Error
(104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server<br>
Premature end of script headers: index.fcgi<br>
<VirtualHost 89.253.247.161:80><br>
ServerName "my_project.vir-mir.ru:80"<br>
ServerAlias "www.my_project.vir-mir.ru"<br>
ServerAlias "ipv4.my_project.vir-mir.ru"<br>
UseCanonicalName Off<br>
ServerAlias "my_project.xn--b1amaptc.xn--p1ai"<br>
ServerAlias "www.my_project.xn--b1amaptc.xn--p1ai"<br>
ServerAlias "ipv4.my_project.xn--b1amaptc.xn--p1ai"<br>
ServerAlias "my_project.xn--80adsbogzenk.xn--p1ai"<br>
ServerAlias "www.my_project.xn--80adsbogzenk.xn--p1ai"<br>
ServerAlias "ipv4.my_project.xn--80adsbogzenk.xn--p1ai"<br><br><br>
<IfModule mod_suexec.c><br>
SuexecUserGroup "admin_ftp" "psacln"<br>
</IfModule><br><br>
ServerAdmin "[email protected]"<br><br>
CustomLog /var/www/vhosts/my_project.vir-mir.ru/statistics/logs/access_log plesklog<br>
ErrorLog "/var/www/vhosts/my_project.vir-mir.ru/statistics/logs/error_log"<br><br>
<IfModule mod_userdir.c><br>
UserDir "/var/www/vhosts/mysqldump.vir-mir.ru/web_users"<br>
</IfModule><br><br>
<Location /plesk-stat/><br>
Options +Indexes<br>
</Location><br>
<Location /plesk-stat/logs/><br>
Require valid-user<br>
</Location> <br><br>
<IfModule mod_ssl.c><br>
SSLEngine off<br>
</IfModule><br><br>
DocumentRoot "/var/www/vhosts/mysqldump.vir-mir.ru/vir-mir.ru/my_project/public"<br>
<Directory /var/www/vhosts/mysqldump.vir-mir.ru/vir-mir.ru/my_project/public/><br>
AddHandler fcgid-script .fcgi<br>
Order allow,deny<br>
Allow from all<br>
AllowOverride all<br>
Options +FollowSymLinks +ExecCGI<br>
RewriteEngine On<br>
RewriteCond %{REQUEST_FILENAME} !-f<br>
RewriteRule ^(.*)$ index.fcgi/$1 [QSA,L]<br>
</Directory> <br><br>
Alias "/media/" "/var/www/vhosts/mysqldump.vir-mir.ru/vir-mir.ru/my_project/media/"<br>
<Directory /var/www/vhosts/mysqldump.vir-mir.ru/vir-mir.ru/my_project/www/media/><br>
SetHandler None<br>
Order allow,deny<br>
Allow from all<br>
</Directory><br><br>
</VirtualHost><br>
#!/usr/bin/env python<br><br>
import sys, os, site<br><br>
# Add a custom Python path.<br>
PYTHON_CUSTOM_PATH = '/usr/local/lib/python2.7/site-packages'<br>
sys.path.insert (0, PYTHON_CUSTOM_PATH)<br>
site.addsitedir (PYTHON_CUSTOM_PATH)<br><br>
# Add a project path.<br>
PYTHON_CUSTOM_PATH = '/var/www/vhosts/mysqldump.vir-mir.ru/vir-mir.ru/my_project'<br>
sys.path.insert (0, PYTHON_CUSTOM_PATH)<br>
site.addsitedir (PYTHON_CUSTOM_PATH)<br><br>
print os.path.dirname(os.path.dirname(__file__))<br>
print '\n\n\n'<br><br>
os.environ['DJANGO_PROJECT'] = 'my_project'<br>
os.environ['DJANGO_SETTINGS_MODULE'] = 'my_project.settings'<br><br>
from django.core.servers.fastcgi import runfastcgi<br>
runfastcgi(method="prefork", maxchildren=3, daemonize="false")<br>
/var/www/vhosts/mysqldump.vir-mir.ru/vir-mir.ru/my_project<br><br>
WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!<br>
WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!<br>
WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!<br>
WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!<br>
Status: 200 OK<br>
Vary: Cookie<br>
X-Frame-Options: SAMEORIGIN<br>
Content-Type: text/html; charset=utf-8<br>
Set-Cookie: csrftoken=aYRV3N9zjKyIa5R5a0xJctLtCxXtIvXG; expires=Thu, 06-Feb-2014 00:16:36 GMT; Max-Age=31449600; Path=/<br><br>
<!DOCTYPE html><br>
<html xmlns="http://www.w3.org/1999/xhtml"><br>
<head><br><br>
<meta charset="utf-8" /><br><br>
<title></title><br>
<meta name="keywords" content="" /><br>
<meta name="description" content="" /><br><br>
<!--[if IE]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]--><br><br>
<meta name="viewport" content="width=device-width, initial-scale=1.0"><br><br>
<link href="/media/bootstrap/css/bootstrap.min.css" rel="stylesheet"><br>
<link href="/media/bootstrap/css/bootstrap-responsive.css" rel="stylesheet"><br>
<link href="/media/bootstrap/css/main.css" rel="stylesheet"><br>
</head><br>
<body style="padding: 50px 0 0 0; "><br><br>
<div class="navbar"><br>
<div class="navbar-inner navbar-fixed-top"><br>
<div class="container"><br>
</div><br>
</div><br>
</div><br><br>
<div class="container"><br><br>
</div><br><br>
<script src="/media/bootstrap/js/bootstrap.min.js"></script><br>
<script src="/media/bootstrap/js/main.js"></script><br>
</body><br>
</html><br>
Answer the question
In order to leave comments, you need to log in
Thanks everyone, I solved the problem myself!
If it's useful to anyone, I decided through wsgi
<VirtualHost 89.253.247.161:80>
ServerName "my_project.vir-mir.ru:80"
ServerAlias "www.my_project.vir-mir.ru"
ServerAlias "ipv4.my_project.vir-mir.ru"
UseCanonicalName Off
ServerAlias "my_project.xn--b1amaptc.xn--p1ai"
ServerAlias "www.my_project.xn--b1amaptc.xn--p1ai"
ServerAlias "ipv4.my_project.xn--b1amaptc.xn--p1ai"
ServerAlias "my_project.xn--80adsbogzenk.xn--p1ai"
ServerAlias "www.my_project.xn--80adsbogzenk.xn--p1ai"
ServerAlias "ipv4.my_project.xn--80adsbogzenk.xn--p1ai"
<IfModule mod_suexec.c>
SuexecUserGroup "admin_ftp" "psacln"
</IfModule>
ServerAdmin "[email protected]"
CustomLog /var/www/vhosts/my_project.vir-mir.ru/statistics/logs/access_log plesklog
ErrorLog "/var/www/vhosts/my_project.vir-mir.ru/statistics/logs/error_log"
<IfModule mod_userdir.c>
UserDir "/var/www/vhosts/mysqldump.vir-mir.ru/web_users"
</IfModule>
<Location /plesk-stat/>
Options +Indexes
</Location>
<Location /plesk-stat/logs/>
Require valid-user
</Location>
<IfModule mod_ssl.c>
SSLEngine off
</IfModule>
DocumentRoot "/var/www/vhosts/mysqldump.vir-mir.ru/vir-mir.ru/my_project/"
WSGIScriptAlias / /var/www/vhosts/mysqldump.vir-mir.ru/vir-mir.ru/my_project/my_project/wsgi.py
Alias /media/ /var/www/vhosts/mysqldump.vir-mir.ru/vir-mir.ru/my_project/media/
<IfModule mod_ssl.c>
SSLEngine off
</IfModule>
<Directory /var/www/vhosts/mysqldump.vir-mir.ru/vir-mir.ru/my_project/>
#php_admin_flag engine on
#php_admin_flag safe_mode off
#php_admin_value open_basedir "/var/www/vhosts/mysqldump.vir-mir.ru/vir-mir.ru/my_project:/tmp"
Options -Includes -ExecCGI
</Directory>
</VirtualHost>
#!/usr/bin/env python
import os
import sys
os.environ.setdefault("SITE", "my_project")
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "my_project.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
For the future advice: it is useful to wrap the script in try / except:
try:
# тут весь скрипт как есть
except:
exc_type, exc_obj, exc_tb = sys.exc_info()
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
file("/tmp/log", "a").write( "Exception %s at %s:%s"%(exc_type, fname, exc_tb.tb_lineno))
It is correct that they chose wsgi. If you choose between fcgi and wsgi, then the second is much easier.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question