我正在尝试使用vestacp 面板部署一个瓶子应用程序。我不断收到 500 错误,显然这是由于服务器设置不正确造成的。我有三个配置文件:
- wsgi.sh(对于这个文件我没有找到配置信息,显然是没有正确配置,默认是django的)
# Adding php wrapper
user="$1"
domain="$2"
ip="$3"
home_dir="$4"
docroot="$5"
echo "# Wsgi template
AddHandler wsgi-script .wsgi
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.$2\.ru\$ [NC]
RewriteRule ^(.*)\$ http://$2/\$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)\$ /django.wsgi/\$1 [QSA,PT,L]
" > $docroot/.htaccess
chown $user:$user $docroot/.htaccess
echo "import os, sys
sys.path.insert(0, '$home_dir/$user/web/$domain/private/django/$domain/env/lib/python2.6/site-packages')
sys.path.insert(0, '$home_dir/$user/web/$domain/private/django/$domain/project/src/shared/')
sys.path.insert(0, '$home_dir/$user/web/$domain/private/django/$domain/project/src/')
os.environ['DJANGO_SETTINGS_MODULE'] = 'main.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()" > $docroot/django.wsgi
chown $user:$user $docroot/django.wsgi
exit 0
- wsgi.stpl(我试图编辑这个文件但没有成功)
<VirtualHost %ip%:%web_ssl_port%>
ServerName %domain_idn%
%alias_string%
ServerAdmin %email%
DocumentRoot %sdocroot%
ScriptAlias /cgi-bin/ %home%/%user%/web/%domain%/cgi-bin/
Alias /vstats/ %home%/%user%/web/%domain%/stats/
Alias /error/ %home%/%user%/web/%domain%/document_errors/
SuexecUserGroup %user% %group%
CustomLog /var/log/%web_system%/domains/%domain%.bytes bytes
CustomLog /var/log/%web_system%/domains/%domain%.log combined
ErrorLog /var/log/%web_system%/domains/%domain%.error.log
<Directory %home%/%user%/web/%domain%/stats>
AllowOverride All
</Directory>
SSLEngine on
SSLVerifyClient none
SSLCertificateFile %ssl_crt%
SSLCertificateKeyFile %ssl_key%
%ssl_ca_str%SSLCertificateChainFile %ssl_ca%
<IfModule mod_ruid2.c>
RMode config
RUidGid %user% %group%
RGroups www-data
</IfModule>
<IfModule itk.c>
AssignUserID %user% %group%
</IfModule>
<IfModule mod_wsgi.c>
WSGIDaemonProcess apx-s$domain% user=%user% group=%user% processes=1 threads=5 display-name=%{GROUP} python-path=%home%/%user%/web/%domain%$
WSGIProcessGroup apx-idea
WSGIApplicationGroup %{GLOBAL}
</IfModule>
<Directory %sdocroot%>
AllowOverride FileInfo
Options ExecCGI Indexes
MultiviewsMatch Handlers
Options +FollowSymLinks
Order allow,deny
Allow from all
</Directory>
IncludeOptional %home%/%user%/conf/web/s%web_system%.%domain%.conf*
</VirtualHost>
- wsgi.tpl
<VirtualHost %ip%:%web_port%>
ServerName %domain_idn%
%alias_string%
ServerAdmin %email%
DocumentRoot %docroot%
ScriptAlias /cgi-bin/ %home%/%user%/web/%domain%/cgi-bin/
Alias /vstats/ %home%/%user%/web/%domain%/stats/
Alias /error/ %home%/%user%/web/%domain%/document_errors/
SuexecUserGroup %user% %group%
CustomLog /var/log/%web_system%/domains/%domain%.bytes bytes
CustomLog /var/log/%web_system%/domains/%domain%.log combined
ErrorLog /var/log/%web_system%/domains/%domain%.error.log
<Directory %home%/%user%/web/%domain%/stats>
AllowOverride All
</Directory>
<IfModule mod_ruid2.c>
RMode config
RUidGid %user% %group%
RGroups www-data
</IfModule>
<IfModule itk.c>
AssignUserID %user% %group%
</IfModule>
<Directory %docroot%>
AllowOverride FileInfo
Options ExecCGI Indexes
MultiviewsMatch Handlers
Options +FollowSymLinks
Order allow,deny
Allow from all
</Directory>
Include %home%/%user%/conf/web/%web_system%.%domain%.conf*
</VirtualHost>
应用程序启动文件 (wsgi.py) 如下所示:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import bottle
import os
import sys
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
os.chdir(os.path.dirname(os.path.abspath(__file__)))
"""С этого файла запускается программа"""
application = bottle.default_app()
Ожидается что настройка конфигурации приведет к сообщению о том что нет определенной директории "/", а не кошибки 500。
Error: 404 Not Found
Sorry, the requested URL 'https://some.url/' caused an error:
Not found: '/'
服务器运行的是 debian 9,vestacp 是撰写本文时的最新版本。使用此指令配置 wsgi_mod https://forum.vestacp.com/viewtopic.php?t=10867