我有问题试图在Ubuntu / Apache上部署我的第一个Django应用程序。 我已经按照djangoproject.com上的指南,并search互联网寻找答案,我卡住了。 我有基本的启动和运行,但是当我尝试访问我的网站(twilightinternal.com),我得到以下错误:
ImportError: Could not import settings 'twilight_boutique.settings' (Is it on sys.path? Does it have syntax errors?): No module named twilight_boutique.settings
我的django代码位于/ root / django_projects / twilight_boutique文件夹中
我在我的网站有以下信息 – 可用/ twilightinternal:
<VirtualHost *> ServerAdmin [email protected] ServerName www.twilightinternal.com ServerAlias twilightinternal.com DirectoryIndex index.html DocumentRoot /var/www/twilightinternal/ ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined <Location "/"> SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE twilight_boutique.settings PythonOption django.root /root/django_projects/twilight_boutique PythonDebug Off PythonPath "['/root/django_projects', '/var/www'] + sys.path" </Location> </VirtualHost>
我真的卡住了,任何帮助将不胜感激。
首先,如果可以,可以使用mod_wsgi,或者使用FastCGI作为后备选项。
你的Apache设置看起来是正确的,所以它可能是你的settings.py。 这很可能是一个权限问题。 你从/ root运行它有一个特定的原因吗? 通常情况下,Apache不能以root身份运行,并且不能读取/ root下的任何文件。 尝试将项目移动到另一个位置。
如果这没有帮助,这里有一些其他的debugging步骤来尝试。
开发服务器是否正常工作?
cd /root/django_projects/twilight_boutique python manage.py runserver
如果失败,您的设置文件中会出现语法错误。
您也可以尝试使用python shell来尝试debugging。 从任何目录运行python并运行以下代码:
import sys sys.path.insert(0, '/root/django_projects') import twilight_boutique.settings