我有安装了cPanel的Centos7 + Apache和mod_wsgi。我正在尝试立即部署到服务器。
问题是,一切似乎都已正确配置,除了我的URL显示文件列表(页面索引)而不是运行Django应用程序。我不知道怎么了。
这是我的配置:
Apache配置:
ServerName mytool.domain.me
ServerAlias www.mytool.domain.me
DocumentRoot "/home/username/public_html/ctltoolbox/smtool"
WSGIDaemonProcess mytool.domain.me python-home=/home/username/public_html/ctltoolbox/ctltoolbox-venv/ python-path=/home/username/public_html/ctltoolbox/smtool
WSGIProcessGroup mytool.domain.me
Alias /media/ /home/username/public_html/ctltoolbox/smtool/media/
Alias /static/ /home/username/public_html/ctltoolbox/smtool/static/
<Directory /home/username/public_html/ctltoolbox/smtool/static/>
Allow from all
</Directory>
<Directory /home/username/public_html/ctltoolbox/smtool/media/>
Allow from all
</Directory>
WSGIScriptAlias / /home/username/public_html/ctltoolbox/smtool/smtool/wsgi.py
<Directory /home/username/public_html/ctltoolbox/smtool/>
<Files wsgi.py>
Allow from all
</Files>
</Directory>
我的wsgi.py文件:
import os
from django.core.wsgi import get_wsgi_application
sys.path.append('/home/username/public_html/ctltoolbox/smtool')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'smtool.settings')
application = get_wsgi_application()
这是我的文件夹/home/username/public_html/ctltoolbox/
的项目结构
|-- ctltoolbox
| `-- smtool
| |-- api.py
| |-- get_data.py
| |-- mainapp
| | |-- __init__.py
| | |-- admin.py
| | |-- apps.py
| | |-- forms.py
| | |-- managers.py
| | |-- middleware.py
| | |-- models.py
| | |-- settings.py
| | |-- tests.py
| | |-- urls.py
| | `-- views.py
| |-- manage.py
| |-- requirements.txt
| |-- smtool
| | |-- __init__.py
| | |-- asgi.py
| | |-- settings.py
| | |-- urls.py
| | `-- wsgi.py
| `-- streamer.py
`-- smtool