1 python+django 网站
2 安装apache2和mod_wsgi
sudo apt install apache2 sudo apt install libapache2-mod-wsgi
3 准备网站,配置apache
# 添加配置vi /etc/apache2/apache2.conf
# Django # 媒体文件 Alias /media/ /home/ubuntu/media/ Alias /static/ /home/ubuntu/static/ <Directory /home/ubuntu/static/> Order deny,allow Require all granted </Directory> <Directory /home/ubuntu/media/> Order deny,allow Require all granted </Directory> # wsgi path WSGIScriptAlias / /home/ubuntu/resume/resume/wsgi.py # django project path WSGIPythonPath /home/ubuntu/resume <Directory /home/ubuntu/resume/resume> <Files wsgi.py> Order deny,allow Require all granted </Files> </Directory>
sudo /etc/init.d/apache2 restart # 重启apache,即可输入网址,测试配置正确与否
4 设置权限
一般目录权限设置为 755,文件权限设置为 644
cd /home/ubuntu sudo chmod -R 644 resume sudo find resume -type d -exec chmod 755 \{\}
sqlite3数据库权限
cd /home/ubuntu sudo chgrp www-data resume sudo chmod g+w resume sudo chgrp www-data resume/db.sqlite3 # 更改为你的数据库名称 sudo chmod g+w resume/db.sqlite3
5 激活网站
sudo a2ensite sitename 或 sudo a2ensite sitename.conf
时间: 2024-10-17 23:28:51