In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article focuses on "how to use flask+uwsgi+nginx to deploy the project to the server", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to deploy a project to a server with flask+uwsgi+nginx.
Server deployment generally uses nginx for load balancing and uses uwsgi to forward to the corresponding web project.
Install nginx (ubuntu is different from centos)
Sudo apt-get install nginx
Install uwsgi
Pip3 install uwsgi
# migrate the database to the server
Install the server
Sudo apt-get install mysql-server (ubuntu version)
# Open the database and create a database
Create database_shop
Import database files created locally
Source (file address)
Configure the uwsgi.ini file, which goes with uwsgi
[uwsgi]
# when using nginx connection, the server address where the Django program is located
; socket=127.0.0.1:8001
# use it directly as a web server, and the server address where the Django program resides
Http=0.0.0.0:8001
# Project directory (directory where manage.py is located)
Chdir=/home/ubuntu/apiwxcjsoft/apicjsoft
# the directory of the wsgi.py file in the project, relative to the project directory (the directory after writing the project directory chdir)
Wsgi-file=apicjsoft/wsgi.pycallable = app # flask_manager need to add this sentence
# number of processes
Processes=4
# number of threads
Threads=2
# role of uwsgi server
Master=True
# File that stores the process number
Pidfile=uwsgi.pid
# Log file, because uwsgi can run in the background without the terminal, and the log is not visible. Our previous runserver is terminal dependent (will be generated in a directory at the same level as uwsgi.ini)
Daemonize=uwsgi.log
# specify the dependent virtual environment
Virtualenv=/home/ubuntu/apiwxcjsoft/apicjsoft/env
Start the uwsgi command
Uwsgi-ini uwsgi.ini
Close the uwsgi command
Uwsgi-- stop uwsgi.pid shutdown
Configure nginx
Find the default file under / etc/nginx/sites-available under ubuntu
Server {listen 80; # listening port, which is usually 8 minutes 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 PHP index index.html index.htm index.nginx-debian.html
Server_name _; # configure the forwarding address, location / {include / etc/nginx/uwsgi_params; uwsgi_pass 127.0.0.1 include 8001position # write the address # First attempt to serve request as file, then # as directory, then fall back to displaying a 404 in uwsgi.ini. # try_files $uri $uri/ = 404;}
Restart nginx after modification
Service nginx restart
Stop command
Service nginx stop
Start command
Service nginx start so far, I believe you have a deeper understanding of "how to use flask+uwsgi+nginx to deploy the project to the server". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.