0
我认为我的apache2服务器已接近设置,但它仍然返回500错误。这里是我的.wsgi
文件:Django EC2的mod_wsgi配置与Apache不工作
import os, sys
#path to directory of the .wsgi file ('apache/')
wsgi_dir = os.path.abspath(os.path.dirname(__file__))
#path to project root directory (parent of 'apache/')
project_dir = os.path.dirname(wsgi_dir)
sys.path.append(project_dir)
project_settings = os.path.join(project_dir, 'settings')
os.environ['DJANGO_SETTINGS_MODULE'] = 'ecomstore.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
这里是我的virtualhost
文件:
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName www.site.com
ServerAlias site.com
Alias /static /home/ecomstore/static
DocumentRoot /home/ecomstore
WSGIScriptAlias//home/ecomstore/apache/ecomstore.wsgi
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
这里是我的服务器重启:
sudo /etc/init.d/apache2 restart
* Restarting web server apache2
[Sun Apr 08 02:47:31 2012] [warn] module wsgi_module is already loaded, skipping
... waiting ..........[Sun Apr 08 02:47:42 2012] [warn] module wsgi_module is already loaded, skipping
...done.
然而,即使我与国防部 - 没有错误wsgi配置重启,我仍然遇到前面提到的500内部服务器错误。有什么我失踪?
是的,我检查了日志,发现这:'ImportError:无法导入设置'ecomstore.settings'(它是否在sys.path?是否有语法错误?):没有模块名为ecomstore.settings ' – locoboy 2012-04-08 09:19:51
固定上面的问题通过添加'sys.path.append('/ home')' – locoboy 2012-04-08 10:29:05
顺便说一句,建议将DocumentRoot设置为你所拥有的。如果您稍后填入Apache配置,则所有源代码都可以下载,包括Django设置文件中的数据库密码。切勿将DocumentRoot设置为包含您不希望用户能够看到的敏感内容的位置。 – 2012-04-08 22:46:09