How to deployment flask cms on CentOS

Recently, learning python, but did not suffer any programming experience, there is no way the practice, so prepare yourself to fight a python framework of the site to play a game, to consolidate the consolidation of knowledge –
Reference to an online opinion beginner you to the final choice of the flask web framework more suitable for beginners
So I found this project: https: //github.com/quokkaproject/quokka
Well, to start building

1, the operating environment

My system environment

I download and install the new version of Python

ii Install python-pip and virtualenv

reference:https://pip.pypa.io/en/stable/installing/

iii Updated version of git

linux comes with the git version is too low, the command parameters used in the follow-up is not supported, so git commands update Click here

2、Install mongodb

Label: mongo database operation to write data both to create the database, so there is no need to create a separate database, as long as the program is written to the database, it will go to create a new database

3、Install quokka

Create an administrator and run quokka

i create a super administrator (Login Management Interface)

ii filled with sample data (optional, if you want to sample data)

credentials for /admin will be email: admin@example.com passwd: adminiii run test

  • Site on http://localhost:5000
  • Admin on http://localhost:5000/admin

 

4、Configure nginx + Gunicorn

Naked with a flask built web (on command) to run the web can be, but after all, not a professional web server, the proposal is still with the mainstream web server, I have here the choice is nginx.
For other deployment methods python can be found here: http: //lutaf.com/141.htm
i download and install configuration nginx

If you want to support Google nginx performance modules, you need to install google-perftools

download link:
http://download.savannah.gnu.org/releases/libunwind #libunwind library based on 64-bit CPU and operating system program provides the basic function call chain register functions and function calls
http: // https: //github.com/gperftools/gperftools/releases #google performance library

为google-perftools添加线程目录

安装nginx

nginx compiled Module Description:
–with-http_stub_status_module: provides the ability to view server statistics
–with-http_ssl_module: supports HTTPS / SSL
–with-http_gzip_static_module: providing a pre-compression of static files
–with-google_perftools_module: Support Google Performance Tools
–with-http_sub_module: You can replace the text in the page
Please refer to this blog: http: //www.zicheng.net/article/42.htm

Configure nginx

Installation and Configuration gunicorn
A python WSGI’s HTTP Server, specifically I do not know what to say. You can refer to the official network (quokka-env) [root @ linux2 quokka] # cd / data / www / quokka / (quokka-env) [root @ linux2 quokka] # vim start_gunicorn.sh # startup script #! / bin / bash NAME = ‘quokka’ directory SOCKFILE # application name FLASKDIR = / data / www / quokka #django item = / tmp / quokka.sock # use this sock to communicate uSER = www # run this application user NUM_WORKERS = 3 #gunicorn worker processes used DJANGO_WSGI_MODULE = wsgi #wsgi module echo “starting $ NAME as whoami “# activate python virtual operating environment cd $ FLASKDIR source / root / quokka-env / bin / activate # start flask exec / root / quokka-env / bin / gunicorn \ –workers $ NUM_WORKERS \ -u www \ –bind = unix: $ SOCKFILE \ wsgi

run


Problems encountered
1, the installation pip, after executing python get-pip.py success, but no pip command.
Repeatedly confirmed that the implementation of this installation command and no mistake, I think it might be Python version of the problem, because linux default python 2.6.6, and I want to use virtualenv so I do not bother to do the environment variables, and so I use absolute paths method specify the new version of python reinstall resolved.

2、mongodb遇到要删除数据库操作时,删除命令为下

3、当执行pip安装时报错“Could not find a version that satisfies the requirement …”时,使用-v参数查看详细原因并解决。例:

Through the above can be seen, for links to 404, so we have to verify that is true under 404 pip still have questions, you can directly access the web or use the curl to verify

Page 404 belongs to the project leader in the adjustment of the page or revoke problem.
If you want to resolve as soon as possible, search for the item in github, general README document how the installation will be local.

4, solve the error when starting nginx

nginx: error while loading shared libraries: libprofiler.so.0: cannot open shared object file: No such file or directory
nginx: error while loading shared libraries: libunwind.so.8: cannot open shared object file: No such file or directory

These two errors belong because there are 64 operating system cause, the solution is to find two lib file, they are soft link to / usr / lib64

5, designated gunicorn -u no authority to solve problems

According to the command and stack trace execution point of view, basically determine two error messages:

ImportError: No module named werkzeug.serving import module error, check if the module problems.

A large area of File “/ root …”, env folder under / root account to check www account is not a permissions problem.

Check the following two errors:

Not being given, it seems there is no problem module

Remove -u www starts correctly, then it seems that privilege provoked questions ~
Solution:

Why here to add execute permissions genus group because we execute permissions gunicorn command is the current user and the current user group (which may be changed by -g), and we changed the start of user www, so it will try to use the www user permissions, www Without this permission, it will try the current user group permissions (both root group), so give execute permissions to root group