操作系统

为什么操作系统重要?

操作系统帮我们调度计算机的硬件资源,让我们读写文件、建立网络连接、同时运行多个程序,没有操作系统,我们需要直接操作底层资源以访问CPU,内存,网络及各种硬件组件。

如果没有现有的操作系统像Linux,Mac OS X和Windows,你就不得不自己写一个操作系统来运行你的web应用。

幸运的是,开源社区提供了Linux作为Python web应用的操作系统。

推荐的操作系统

Python web部署推荐的操作系统是LinuxFreeBSD。Linux有多种发行版可以作为生产服务器。Ubuntu长期支持版Long Term Support (LTS),红帽企业版Red Hat Enterprise Linux,以及CentOS都可以作为选项。

Mac OS X和Windows作为开发环境没问题,但是不适合作为生产系统,除非你有特殊理由为什么不能使用Linux。

Ubuntu

Ubuntu是Canonical公司出品的Linux发行版。Ubuntu使用Debian发行版作为基础,包含了aptitude package manager包管理器。桌面版的Ubuntu使用GNOME或Unity作为图形用户界面。

Ubuntu长期支持版Long Term Support (LTS)建议作为部署服务器。LTS版有5年的维护周期。每隔两年,Canonical公司会发布一个新的LTS版本。到2016年4月,16.04 Xenial Xerus是最新的Ubuntu长期支持版。Xenial Xerus包含了Python 3.5作为默认Python版本,该版本是Python 2.7之后的一个主要升级。

Ubuntu Python包

有多种Linux系统上运行的Python包ptitude

Red Hat 和 CentOS

Red Hat Enterprise Linux (RHEL) 和 Community ENTerprise Operating System (CentOS) 是同一个发行版,主要区别是CentOS是开源软件,是RHEL的免费版。

RHEL 和 CentOS 使用不同的包管理器和命令行界面:RPM包管理器和YUM。RPM有一个.rpm后缀,YUM提供了命令行界面与RPM系统交互。

操作系统资源

  • Linux Performance
  • Lifehacker’s guide to choosing a Linux distro.
  • Linux Journey is a really well designed curriculum for learning Linux basics such as the command line, package management, text handling. There are also courses for more advanced topics such as how the kernel works, setting up logging and device management.
  • The Ops School curriculum is a comprehensive resource for learning about Linux fundamentals and how to perform the work that system administrators typically handle.
  • Since Linux is your go-to production operating system, it’s important to get comfortable with the Unix/Linux commands and philosophy. Study up on this introduction to Unix tutorial to become more familiar with the operating system.
  • First 5 Minutes on a Server shows the first several security steps that should be done manually or automatically on any server you stand up.
  • Digital Ocean has a detailed walkthrough for setting up Python web applications on Ubuntu.
  • linux-internals is a series of posts about how Linux works under the covers, starting from the low level booting process.
  • While not quite necessary to run your Python application, if you want to dig into how operating systems are built, check out this free book How to Make a Computer Operating System, which was originally written by a high school student and later updated as he became a professional software developer.

操作系统学习清单

  1. 选一个基于Debian的Linux发行版比如Ubuntu或基于Fedora的发行并比如CentOS。
  2. 通过一些步骤加强安全。安装基本的安全包,比如fail2ban 和 unattended-upgrades。用sudo创建一个新的用户账号,并禁止root登录。禁止仅凭密码登录,使用一个公私秘钥对代替。阅读关系系统安全方面的更多资料。
  3. 安装Python相关包,制作Python应用运行环境。安装哪些包取决于你选择的Linux发行版。