数据库中间件
@credit Yan Zhu (https://github.com/nina-zhu)
Flask is a microframework for Python based on Werkzeug, Jinja 2 and good intentions, it can help you get your Python application or website off the ground. Flask includes a simplified development server for testing your code locally, but for anything even slightly production related, a more secure and powerful web server is required.
In this guide, we will demonstrate how to install and configure some components on Ubuntu 14.04 to support and serve Flask applications. We will configure the uWSGI application container server to interface with our applications. We will then set up Nginx to reverse proxy to uWSGI, giving us access to its security and performance features to serve our apps.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # source: https://trac.ffmpeg.org/wiki/CentosCompilationGuide | |
| yum -y install autoconf automake gcc gcc-c++ git libtool make nasm pkgconfig zlib-devel | |
| mkdir ~/ffmpeg_sources | |
| cd ~/ffmpeg_sources | |
| curl -O http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz | |
| tar xzvf yasm-1.2.0.tar.gz | |
| cd yasm-1.2.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # source: https://trac.ffmpeg.org/wiki/CentosCompilationGuide | |
| yum install autoconf automake gcc gcc-c++ git libtool make nasm pkgconfig zlib-devel | |
| mkdir ~/ffmpeg_sources | |
| cd ~/ffmpeg_sources | |
| curl -O http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz | |
| tar xzvf yasm-1.2.0.tar.gz | |
| cd yasm-1.2.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /var/log/nginx_*.log { | |
| daily | |
| compress | |
| delaycompress | |
| rotate 2 | |
| missingok | |
| nocreate | |
| sharedscripts | |
| postrotate | |
| test ! -f /var/run/nginx.pid || kill -USR1 `cat /var/run/nginx.pid` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| UP=$(pgrep mysql | wc -l); | |
| if [ "$UP" -ne 1 ]; | |
| then | |
| echo "MySQL is down."; | |
| sudo service mysql start | |
| else | |
| echo "All is well."; | |
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| stream { | |
| log_format basic '$remote_addr [$time_local] ' | |
| '$protocol $status $bytes_sent $bytes_received ' | |
| '$session_time'; | |
| access_log /var/log/nginx/access.log basic; | |
| error_log /var/log/nginx/error.log debug; | |
| include /etc/nginx/stream.conf.d/*.conf; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## Block by user agent | |
| if ($http_user_agent ~ (Purebot|Lipperhey|MaMa CaSpEr|libwww-perl|Mail.Ru|gold crawler)) { | |
| return 403; | |
| } | |
| ## Block by referrer keywords | |
| if ($http_referer ~* (viagra|cialis|levitra) ) { | |
| return 403; | |
| } |