centos部署flask应用
pip install gunicorn
gunicorn -b localhost:8000 -w 4 microblog:app
启动nginx
service nginx start
centos7网络配置,注意选择桥接模式
cd /etc/sysconfig/network-scripts
vim ifcfg-ens33
DEVICE=ens33
ONBOOT=yes
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NETMASK=255.255.255.0
DNS1=114.114.114.114
DNS2=8.8.8.8
ZONE=public
nginx配置
vim /etc/nginx/nginx.conf
[root@localhost ~]# service nginx start
Starting nginx (via systemctl): [ 确定 ]
[root@localhost ~]# vim /etc/nginx/nginx.conf
#user nobody;
worker_processes 4;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
"/etc/nginx/nginx.conf" 121L, 2885C
成功访问后: