Deployed flaskblog on DigitalOcean, small project but learned a lot from the deployment.
The operating system chosen is Ubuntu14.04, the reason is usually their main use of this version, just smooth, so you can choose the appropriate version of linux according to the needs of your own.
Deployment program:
Virtualenv+Gunicorn+Nginx+Supervisor
Download the code for the project from hereflaskblogThe , project comes with a simple configuration file reference.
You can start by visiting theflaskblogTake a look.
take note of
In this article, we use an Ubuntu 14.04 64-bit host, create a user named xin, and deploy it.
This article focuses on deployment, all linux-related operations are not described in detail.
The deployment directory is (/home/xin/www/flaskblog), so note the directory in the configuration file.
matrix
System:Ubuntu 14.04 64
Web Server: Nginx
Virtual Environment: Virtualenv
WSGI Server: Gunicorn
Database: MySQL
Monitor: Supervisor
The main purpose of using supervisor is to monitor the operation of gunicorn to ensure that the server can continue to run.
mounting
Installing the software
$ 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
Download the project and turn on the virtual environment
Use git to download the code to (/home/xin/www/flaskblog)
$ git clone /defshine/ $ cd flaskblog
Start the virtual environment and install project dependencies
$ virtualenv venv $ source venv/bin/activate (venv)$ pip install -r
How to exit a virtual environment
(venv)$ deactivate
comprehensive database
Create a database (flaskblog) in a MySQL database and modify the configuration of the database in the
Initialize the database and create an administrator user
(venv)$ python create_db (venv)$ python create_user -u admin -p 123456
Turn on monitoring
Edit the supervisor configuration file () under the project as you see fit and copy it to the system directory
$ sudo cp /etc/supervisor//
Reload the configuration file and start flaskblog
$ sudo supervisorctl reload $ sudo supervisorctl start flaskblog
View Operational Status
$ sudo supervisorctl status
Nginx
Modify the nginx configuration file (flaskblog) and copy it to the system directory and create soft links. Restart 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
Checking the status of nginx
$ sudo service nginx status
Then, it can be accessed via ip address. Of course, configure the domain name for better access.
flaskblog this small project, just have a small prototype, the follow-up can also develop some small features.