- ubuntu:18.04
- Apache:2.4.29
- Python:3.6.6
- Django:2.1.3
系统自带Python2.7.15rc以及Python3.6.6
sudo apt install apache2
sudo apt install libapache2-mod-wsgi-py3
体验Django2,就必须要求是Python3,所以下面都是基于Python3
安装pip
sudo apt install python3-pip
安装Django2
sudo pip3 install django
这里一定要使用sudo
,否则,Apache无法import django
文件路劲: /etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
ServerAdmin example@126.com
#Alias /media/ /home/blog/media/
#Alias /static/ /home/blog/static/
#<Directory /home/blog/media>
# Require all granted
#</Directory>
#<Directory /home/blog/static>
# Require all granted
#</Directory>
WSGIScriptAlias / /home/blog/blog/wsgi.py
<Directory /home/blog/geek>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
sudo service apache2 restart