我想用django和apache。我的目录树如下
/home/avlahop/development/django/rhombus2
├── accounts
│ ├── __init__.py
│ ├── __init__.pyc
│ ├── models.py
│ ├── tests.py
│ ├── urls.py
│ ├── urls.pyc
│ ├── views.py
│ └── views.pyc
├── admin
│ ├── css
│ ├── img
│ │ ├── gis
│ └── js
├── customer
│ ├── migrations
│ ├── models.py
│ ├── models.pyc
│ ├── views.py
│ └── views.pyc
├── __init__.py
├── __init__.pyc
├── manage.py
├── media
├── mycal
├── mypil
│ ├── __init__.py
│ ├── __init__.pyc
│ ├── models.py
│ ├── tests.py
│ ├── urls.py
│ ├── urls.pyc
│ ├── views.py
│ └── views.pyc
├── rhombus
│ ├── api.py
│ ├── api.pyc
│ ├── __init__.py
│ ├── __init__.pyc
│ ├── rhombus.db
│ ├── settings.py
│ ├── settings.pyc
│ ├── urls.py
│ ├── urls.pyc
│ ├── wsgi.py
│ └── wsgi.pyc
├── scripts
│ ├── create_data_files.py
│ ├── create_data_files.pyc
│ ├── find_server.py
│ ├── __init__.py
│ ├── __init__.pyc
│ └── populatedb.py
├── settings
├── static
├── tastypie
├── templates
你知道吗wsgi.py公司你知道吗
import os, sys
root = os.path.join(os.path.dirname(__file__),'..')
sys.path.insert(0, root)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "rhombus.settings")
# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
# Apply WSGI middleware here.
# from helloworld.wsgi import HelloWorldApplication
# application = HelloWorldApplication(application)
我的站点.conf文件具有以下代码(并且已启用)
WSGIPythonPath /home/avlahop/development/django/rhombus2
<VirtualHost *:80>
ServerAdmin webmast@rhombus.com
ServerName myrhombus.com
ServerAlias www.myrhombus.com
DocumentRoot /home/avlahop/development/django/rhombus2
WSGIScriptAlias / /home/avlahop/development/django/rhombus2/rhombus/wsgi.py
<Directory /home/avlahop/development/django/rhombus2/rhombus>
<Files wsgi.py>
Require all granted
</Files>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
在/home/avlahop/development/django/rhombus2(包括root)下的所有内容都被chmoded为755,这对其他人来说是rx。但我得到以下错误
ImportError: Could not import settings 'rhombus.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named rhombus.settings
怎么了。。。这里出了问题。我对另一个站点(另一个virtualhost在另一个conf文件中)有相同的东西,我得到了许可拒绝。而且我复制粘贴了上面的代码,并更改了路径。所以两个站点代码相同,错误不同。我在这里真的很沮丧。我不想去php…php很容易部署。。。你知道吗
如Django documentation中所述,应按如下方式指定python路径:
或者,您可能希望将^{} 指令与
python_path argument
一起使用(这在Django docs中也有说明)在你的例子中
/path/to/mysite.com
应该是/home/avlahop/development/django/rhombus2
另外,请注意,将源代码放在DocumentRoot下被认为是一种不好的做法,因为(1)不需要运行站点,(2)在某些情况下允许攻击者访问源代码。如果我没有搞错的话,只有静态文件应该位于DocumentRoot下。你知道吗
相关问题 更多 >
编程相关推荐