什么是Django?
Python下有许多款不同的 Web 框架。Django是重量级选手中最有代表性的一位。许多成功的网站和APP都基于Django。
Django是一个开放源代码的Web应用框架,由Python写成。Django遵守BSD版权,初次发布于2005年7月,并于2008年9月发布了第一个正式版本1.0。
Django采用了MVC的软件设计模式,即模型M,视图V和控制器C。
1. 启动EC2
如果读者期望可以在本文中看到如何启动一个Ubuntu 16.04版本的EC2,如何通过 ./configure make make install 等等操作安装python 3.7.4,如何解决python编译过程中的错误,如何解决pip安装时的openssl问题,那笔者可以明确的说,不存在的。
因为AWS Marketplace中提供了很多集成django的AMI(Amazon系统镜像),我们只需要在选择AMI时搜索django,挑选一个自己喜(mian)欢(fei)的版本(笔者选择的是Bitnami的版本)。
然后再一路next,最后在审核和启动界面仔细检查配置,确认没问题后点击启动。等待几分钟之后,就可以继续了,完全不用再考虑安装编译等问题了。
2. 连接EC2并测试
通过ssh连接工具(笔者使用的MobaXterm),新建session,服务器地址填写刚刚启动的EC2的ip地址,用户名为 bitnami(不同AMI用户会不一样,需要查看EC2的使用说明标签),再选择用户的私钥,即可以连接到服务器上了。
确认连接没问题之后,就可以测试下环境是否已经搭建好了。打开浏览器,在地址栏输入EC2服务器的ip地址。如果显示Django欢迎界面,则表示环境已经运行成功。
总结
通过简单的几步操作,就可以搭建起django测试环境,这其中,AWS Marketplace帮我们解决了部署中最头疼的问题,我们只需要专注于自己应用的开发就可以了。
陈汉卿
云业务事业部 | 高级系统架构师
神州泰岳软件股份有限公司 · AWS战略合作伙伴
返回技术博客
What is Django?
There are many different web frameworks available for Python. Django is one of the most representative among the heavyweights. Many successful websites and apps are built on Django.
Django is an open-source web application framework written in Python. It is licensed under the BSD license, was first released in July 2005, and its first official version 1.0 was released in September 2008.
Django follows the MVC (Model-View-Controller) software design pattern.
1. Launch an EC2 Instance
If you're expecting this article to walk you through launching an Ubuntu 16.04 EC2 instance, installing Python 3.7.4 via ./configure make make install, troubleshooting Python compilation errors, or fixing OpenSSL issues during pip installation — the answer is: none of that is needed here.
AWS Marketplace provides many AMIs (Amazon Machine Images) with Django pre-integrated. All you need to do is search for "django" when selecting an AMI and pick a version you like (the author chose the Bitnami version).
Then click through the wizard, carefully review the configuration on the review and launch page, and click Launch. After waiting a few minutes, you're ready to go — no need to worry about installation or compilation at all.
2. Connect to EC2 and Test
Use an SSH client (the author used MobaXterm) to create a new session. Enter the IP address of the EC2 instance you just launched as the server address, set the username to bitnami (this may differ depending on the AMI — check the EC2 usage instructions tab), select your private key, and connect to the server.
Once the connection is confirmed, you can test whether the environment is set up correctly. Open a browser and enter the EC2 server's IP address in the address bar. If the Django welcome page is displayed, the environment is running successfully.
Summary
With just a few simple steps, you can set up a Django development environment. AWS Marketplace takes care of the most painful part of the deployment process, allowing you to focus entirely on developing your own application.
Chen Hanqing
Cloud Business Division | Senior Solutions Architect
Shenzhou Taiyue Software Co., Ltd. · AWS Strategic Partner
Back to Tech Blog