sudo find /home/lmy/grouped/ -type f -exec chmod -v ug=rw {} \;
sudo find /home/lmy/grouped/ -type d -exec chmod -v u=rwx,g=srwx {} \;
sudo adduser $(whoami) lmy
newgrp lmy
# Create a New VirtualHost for WSGI Django
sudoedit /etc/apache2/sites-available/项目名称.conf
ServerName www.example.com
WSGIDaemonProcess 用户名 user=用户名 group=用户名 threads=5 python-path="/home/用户名/grouped/项目名/"
WSGIScriptAlias / /home/用户名/grouped/项目名/项目名/wsgi.py
WSGIProcessGroup 用户名
WSGIApplicationGroup %{GLOBAL}
WSGIScriptReloading On
Require all granted
sudo a2ensite 项目名
sudo service apache2 restart
以上,就已经配置完了
如果服务器遇到500错误
cat /var/log/apache2/error.log
或 tail -f /var/log/apache2/error.log
# 初始化数据库
sudo -H python3 manage.py makemigrations
sudo -H python3 manage.py migrate
ref:
http://terokarvinen.com/2017/django-on-apache-with-python-3-on-ubuntu-16-04
https://zxtcode.com/main/37/
http://www.django-rest-framework.org/
https://docs.djangoproject.com/en/1.11/howto/static-files/
http://www.cnblogs.com/gide/p/6179975.html
http://www.runoob.com/django/django-first-app.html