在DigitalOcean上部署了flaskblog,项目虽小,部署中也学到了很多东西。
操作系统选择的是Ubuntu14.04,原因就是平时自己主要使用这个版本,顺手而已,所以你自己可以根据需要选择合适的linux版本。
部署方案:
Virtualenv+Gunicorn+Nginx+Supervisor
从这里下载项目的代码flaskblog, 工程中带有简单的配置文件参考。
可以先访问flaskblog看一下。
注意
本文中使用Ubuntu14.04 64位主机, 创建一个名为xin的用户,进行部署。
本文重点部署,所有linux的相关操作不做详细介绍。
部署目录是(/home/xin/www/flaskblog),所以请注意配置文件中的目录。
环境
系统:Ubuntu 14.04 64
Web Server: Nginx
虚拟环境: Virtualenv
WSGI Server: Gunicorn
数据库: MySQL
Monitor: Supervisor
使用supervisor主要是监控gunicorn的运行,保证服务器的可以持续运行。
安装
安装软件
$ sudo apt-get install python-pip $ sudo apt-get install python-dev $ sudo pip install virtualenv $ sudo apt-get install mysql-server $ sudo apt-get install libmysqlclient-dev $ sudo apt-get install nginx $ sudo apt-get install supervisor
下载工程并开启虚拟环境
使用git下载代码到(/home/xin/www/flaskblog)
$ git clone https://github.com/defshine/flaskblog.git $ cd flaskblog
启动虚拟环境,安装工程依赖
$ virtualenv venv $ source venv/bin/activate (venv)$ pip install -r requirements.txt
如何退出虚拟环境
(venv)$ deactivate
数据库
在MySQL数据库中创建数据库(flaskblog),修改 config.py中的数据库的配置
初始化数据库并创建管理员用户
(venv)$ python manage.py create_db (venv)$ python manage.py create_user -u admin -p 123456
开启监控
根据自己的情况,编辑工程下的supervisor配置文件(flaskblog.conf),然后复制到系统目录中
$ sudo cp flaskblog.conf /etc/supervisor/conf.d/
重新载入配置文件,并启动flaskblog
$ sudo supervisorctl reload $ sudo supervisorctl start flaskblog
查看运行状态
$ sudo supervisorctl status
Nginx
修改nginx的配置文件(flaskblog),然后复制到系统目录中去,并创建软链接。重启nignx。
$ sudo cp flaskblog /etc/nginx/site-available/ $ cd /etc/nginx/site-enabled $ sudo ln -s /etc/nginx/site-avalaible/flaskblog . $ sudo service nginx reload $ sudo service nginx restart
查看nginx状态
$ sudo service nginx status
然后,就可以通过ip地址访问了。当然,配置好域名,访问起来更好。
flaskblog这个小项目,刚刚有个小雏形,后续还可以开发一些小特性。

Python and C each have their own advantages, and the choice should be based on project requirements. 1) Python is suitable for rapid development and data processing due to its concise syntax and dynamic typing. 2)C is suitable for high performance and system programming due to its static typing and manual memory management.

Choosing Python or C depends on project requirements: 1) If you need rapid development, data processing and prototype design, choose Python; 2) If you need high performance, low latency and close hardware control, choose C.

By investing 2 hours of Python learning every day, you can effectively improve your programming skills. 1. Learn new knowledge: read documents or watch tutorials. 2. Practice: Write code and complete exercises. 3. Review: Consolidate the content you have learned. 4. Project practice: Apply what you have learned in actual projects. Such a structured learning plan can help you systematically master Python and achieve career goals.

Methods to learn Python efficiently within two hours include: 1. Review the basic knowledge and ensure that you are familiar with Python installation and basic syntax; 2. Understand the core concepts of Python, such as variables, lists, functions, etc.; 3. Master basic and advanced usage by using examples; 4. Learn common errors and debugging techniques; 5. Apply performance optimization and best practices, such as using list comprehensions and following the PEP8 style guide.

Python is suitable for beginners and data science, and C is suitable for system programming and game development. 1. Python is simple and easy to use, suitable for data science and web development. 2.C provides high performance and control, suitable for game development and system programming. The choice should be based on project needs and personal interests.

Python is more suitable for data science and rapid development, while C is more suitable for high performance and system programming. 1. Python syntax is concise and easy to learn, suitable for data processing and scientific computing. 2.C has complex syntax but excellent performance and is often used in game development and system programming.

It is feasible to invest two hours a day to learn Python. 1. Learn new knowledge: Learn new concepts in one hour, such as lists and dictionaries. 2. Practice and exercises: Use one hour to perform programming exercises, such as writing small programs. Through reasonable planning and perseverance, you can master the core concepts of Python in a short time.

Python is easier to learn and use, while C is more powerful but complex. 1. Python syntax is concise and suitable for beginners. Dynamic typing and automatic memory management make it easy to use, but may cause runtime errors. 2.C provides low-level control and advanced features, suitable for high-performance applications, but has a high learning threshold and requires manual memory and type safety management.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft