Aliyun ECS currently has a new user free of charge for six months of activities, on the use of leisure time to apply for a specific application can be to Http://free.aliyun.com/?spm=5176.383518.1.28.OXp5YZ.
The configuration I chose is:
Cpu:1 Nuclear
Memory: 1GB
Data disk: 0G
Operating system: Ubuntu 12.04 64-bit
Current Usage Bandwidth: 0Mbps
Of course, because it is free, so the bandwidth is 0Mbps, so there is no extranet IP, can not be installed from the external network environment, preferably through the upgrade bandwidth of 1Mbps, my goal is to build flask environment ECS, so on the upgrade of the two-day 1Mbps, the cost is 0.36 yuan. This has an extranet IP, which can be remotely and managed via SSH.
The next step is to build the environment:
1. Install Pip
Pip is Python's package management tool, which can be used to find a mother.
Python code ~# sudo apt-get install Python-pip
2. Create a new user Bob
First follow zsh as Bob's default shell
Python code ~# sudo apt-get install zsh ~# wget--no-check-certificate Er/tools/install.sh-o-| SH ~# useradd bob-d/home/bob-m-s/bin/zsh ~# passwd Bob
3. Create an independent development environment for the application
Virtualenv is Python's environmental management tools, specific introduction can find Niang.
Python code ~# pip install virtualenv
Log in as Bob user via SSH
Python code iz28tu6p6vhz% virtualenv Dylan New python executable in Dylan/bin/python installing, Setuptools. iz28tu6p6vhz% CD Dylan iz28tu6p6vhz%. ./bin/activate (Dylan) iz28tu6p6vhz%
4, install flask, and write a HelloWorld service
Python code (Dylan) iz28tu6p6vhz% pip install flask (Dylan) iz28tu6p6vhz% vim runserver.py (Dylan) iz28tu6p6vhz% chmod a+x runserver.py
runserver.py content is:
Python code from flask import Flask app = Flask (__name__) @app. Route ('/") def Hello_world (): Return ' Hello world! ' if __name__ = = ' __main__ ': App.run ()
5, according to Gunicorn, and configure the application
Gunicorn is used to deploy WSGI applications, where UWSGI can also be used instead
Python code (Dylan) iz28tu6p6vhz% pip install Gunicorn
Gunicorn configuration for the Dylan site Python code (Dylan) iz28tu6p6vhz% vim gunicorn.conf
The contents of the gunicorn.conf file are: Python code #工作进程数为3 workers = 3 #绑定本地8000端口 bind = ' 127.0.0.1:8000 '
6, install supervisor, and configure
Use the root account to follow the Python code ~# useradd bob-d/home/bob-m-s/bin/zsh ~# sudo service supervisor stop stopping supervisor : Supervisord. ~# sudo service supervisor start starting Supervisor:supervisord.
Configure Supervisor Services for Dylan applications Python code ~# touch/etc/supervisor/conf.d/dylan.conf ~# vim/etc/supervisor/conf.d/dylan.conf
dylan.conf content is: Python code [program:dylan] command=/home/bob/ dylan/bin/gunicorn runserver:app -c /home/bob/dylan/gunicorn.conf directory=/home/ bob/dylan user=bob autostart=true