这是我第一次使用python3虚拟环境在mod_wsgi上使用apache部署django app。目录如下
(DJango_RestFramework)User @ User-virtual-machine:〜/ Project / Sample $ dir db.sqlite3 manage.py静态示例
在设置的底部添加了 STATIC_ROOT = os.path.join(BASE_DIR," / home / User / Project / Sample / static /")。 py 文件然后应用 ./ manage.py collectstatic 之后立即更改 /etc/apache2/sites-available/000-default.conf 文件,如下所示
<VirtualHost :*80>
Alias /static /home/User/Project/Sample/static
<Directory /home/User/Project/Sample/static>
Require all granted
</Directory>
<Directory /home/User/Project/Sample/Sample>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess Sample python-path=/home/User/Project/:/home/User/Project/DJango_RestFramework/lib/python3.5/site-packages
WSGIProcessGroup Sample
WSGIScriptAlias / /home/User/Project/Sample/Sample/wsgi.py
</VirtualHost>
最终应用了这些命令
1.chmod 664 /home/User/Project/Sample/db.sqlite3,2.sudo chown:www-data /home/User/Project/Sample/db.sqlite3,3.sudo chown:www -data / home / User / Project / Sample,4.sudo service apache2 restart 得到内部服务器错误如果我在error.log上检查了它&#39;显示[Tue Dec 12 15:02:32.095065 2017] [wsgi:error] [pid 1331:tid 140188564576000] [remote 127.0.0.1:5937] ImportError:没有名为&#39; django&#39;。的模块p>
不知道我错在哪里请帮助我。 提前谢谢!