Note: This does not cover everything you 'could do' - it's meant to get your server up and running with Django as quickly as possible. It should work for later versions, just remember to find the right packages and change versioning accordingly
You will likely have to change a lot of the paths included so be watchful.
I put my ‘static’ and ‘media’ folders in a separate location from my
python code ( within /var/www/example.com/ ) and I think you should
too to prevent accidentally making your python code public.
(The VirtualHost example below the instructions should make the setup more
clear)
在Ubuntu16+上使用Apache2.4使用Python3.6.1设置django1.11
1。安装Python3.6和virtualenv
2。安装Apache2 Web服务器
^{pr2}$3。为您的项目创建并输入一个文件夹,然后在其中构建一个虚拟环境
4。输入新的虚拟环境以在其中安装软件包
5。安装Django、mod wsgi和任何其他需要的软件包
6。在您的~/example.com网站文件夹
7。编辑wsgi.py在Django项目文件夹中添加文件,为项目添加sys路径
8。编辑你的Django项目设置.py并设置项目正常工作所需的任何其他内容。
9。运行以下命令并将输出复制到apache配置文件中
10。退出虚拟环境
<11>强。导航到apache2配置文件夹(/etc/apache2/在Ubuntu上),并将复制的文本放在apache2配置文件的底部。
12。导航到/etc/apache2/sites available/并为您的站点创建一个新的conf文件。编辑虚拟主机模板(在所有说明下方)并将其复制到此文件。
13。保存文件后,在Apache中启用此站点
14。如果要启用对站点的管理员访问,只需将文件从python虚拟环境复制到别名为static/admin文件夹中
15。任何时候更新任何与python或django相关的脚本时,都需要“触摸”wsgi.py文件以重新加载运行站点的守护进程以使其处于活动状态或重新启动apache…
16岁。最后检查所有文件夹和文件是否具有足够的组(通常是www数据)读写权限,以及数据库所在的文件夹(如果使用sqlite)是否具有组写入权限。
虚拟主机示例模板…
注意:请根据需要编辑错误并对说明进行改进,但不要试图将事情过于复杂
相关问题 更多 >
编程相关推荐