怎么用flask+uwsgi+nginx把项目部署到服务器上
                                            本篇内容主要讲解“怎么用flask+uwsgi+nginx把项目部署到服务器上”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“怎么用flask+uwsgi+nginx把项目部署到服务器上”吧!

公司主营业务:成都网站设计、成都网站建设、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。创新互联是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。创新互联推出杭州免费做网站回馈大家。
服务器部署一般是用nginx做负载均衡,用uwsgi转发到相应的web项目中去
安装 nginx(ubuntu和centos有区别)
sudo apt-get install nginx
安装uwsgi
pip3 install uwsgi
#将数据库迁移到服务器上
安装服务器
sudo apt-get install MySQL-server (ubuntu版)
#打开数据库,创建一个数据库
create database_shop
导入本地创建的数据库文件
source (文件地址)
配置uwsgi.ini文件,这个文件跟uwsgi同行
[uwsgi]#使用nginx连接时使用,Django程序所在服务器地址;socket=127.0.0.1:8001#直接做web服务器使用,Django程序所在服务器地址http=0.0.0.0:8001#项目目录(manage.py所在目录)chdir=/home/ubuntu/apiwxcjsoft/apicjsoft#项目中wsgi.py文件的目录,相对于项目目录(写项目目录chdir之后的目录)wsgi-file=apicjsoft/wsgi.pycallable = app #flask_manager 需要加上这句话# 进程数processes=4# 线程数threads=2# uwsgi服务器的角色master=True# 存放进程编号的文件pidfile=uwsgi.pid# 日志文件,因为uwsgi可以脱离终端在后台运行,日志看不见。我们以前的runserver是依赖终端的(会生成在与uwsgi.ini平级目录中)daemonize=uwsgi.log# 指定依赖的虚拟环境virtualenv=/home/ubuntu/apiwxcjsoft/apicjsoft/env
启动uwsgi命令
uwsgi --ini uwsgi.ini
关闭uwsgi命令
uwsgi --stop uwsgi.pid 关闭
配置nginx
ubuntu下找到/etc/nginx/sites-available下的default文件
server {listen 80; #监听端口,一般为80# listen [::]:80 default_server;# SSL configuration## listen 443 ssl default_server;# listen [::]:443 ssl default_server;## Note: You should disable gzip for SSL traffic.# See: https://bugs.debian.org/773332## Read up on ssl_ciphers to ensure a secure configuration.# See: https://bugs.debian.org/765782## Self signed certs generated by the ssl-cert package# Don't use them in a production server!## include snippets/snakeoil.conf;root /var/www/html;# Add index.php to the list if you are using PHPindex index.html index.htm index.nginx-debian.html;server_name _;#配置转发地址,location / {include /etc/nginx/uwsgi_params;uwsgi_pass 127.0.0.1:8001;#写在uwsgi.ini中得地址# First attempt to serve request as file, then# as directory, then fall back to displaying a 404.# try_files $uri $uri/ =404;}
修改完后重新启动nginx
service nginx restart
停止命令
service nginx stop
启动命令
service nginx start
到此,相信大家对“怎么用flask+uwsgi+nginx把项目部署到服务器上”有了更深的了解,不妨来实际操作一番吧!这里是创新互联网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
当前文章:怎么用flask+uwsgi+nginx把项目部署到服务器上
网页URL:http://www.scyingshan.cn/article/gddiip.html

 建站
建站
 咨询
咨询 售后
售后
 建站咨询
建站咨询 
 