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