(Python Flask 构建微电影视频网站)部署微电影网站

1、安装依赖包

2、关闭调试模式:app.debug = False

3、修改mysql数据库连接,导入数据

4、开启多个端口后台运行

5、配置nginx反向代理

5.1、流媒体访问限制

限制单个IP能发起的连接:limit_conn addr 1;
限制视频速率:limit_rate 1024k;
刷新nginx:nginx -s reload

 

 

# 导出依赖包、导出数据库文件
pip freeze > req.txt

# 上传项目到服务器
scp -r flask-movie root@192.168.0.95:/root/

# 上传依赖包和sql文件到服务器
scp req.txt flask_movie.sql root@192.168.0.95:/root/

cd ~
ls
cat req.txt

# 安装依赖包
pip install -r req.txt

# 导入数据库
mysql -uroot -proot
create database flask_movie;
use flask_movie;
source /root/flask_movie.sql
show tables;
select * from tag;
\q

# 部署代码
cp -r flask_movie /usr/local/nginx/html/
# 5、配置nginx反向代理 vim /usr/local/nginx/conf/nginx.conf [ worker_processes 4; events { worker_connections 262140; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; limit_conn_zone $binary_remote_addr zone=addr:5m; upstream movie { server 127.0.0.1:5001; server 127.0.0.1:5002; server 127.0.0.1:5003; server 127.0.0.1:5004; } server { listen 80; server_name localhost; location / { root html; index index.html index.htm; proxy_pass http://movie; } location ~ \.flv$ { flv; limit_conn addr 4; limit_rate 1024k; rewrite ^/static/uploads/(.+?).flv$ /movie_project/app/static/uploads/$1.flv permanent; } location ~ \.mp4$ { mp4; limit_conn addr 4; limit_rate 1024k; rewrite ^/static/uploads/(.+?).mp4$ /movie_project/app/static/uploads/$1.mp4 permanent; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } } ] nginx - s stop nginx netstat -anptu | grep nginx
# 4、开启多个端口后台运行 cd
/usr/local/nginx/html/flask_movie/ nohup python manage.py runserver -h 127.0.0.1 -p 5001 & nohup python manage.py runserver -h 127.0.0.1 -p 5002 & nohup python manage.py runserver -h 127.0.0.1 -p 5003 & nohup python manage.py runserver -h 127.0.0.1 -p 5004 & netstat -auptu | grep 500* 192.168.0.95

 

posted @ 2021-05-21 17:12  嘆世殘者——華帥  阅读(374)  评论(0编辑  收藏  举报