In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Nginx+uwsgi+Django deployment code how to write, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
Nginx+uwsgi+Django deployment code installs uwsgi1. Install pip2. Install uwsgi3 Test uwsgi
Write a test.py on your machine
# test.py
Def application (env, start_response):
Start_response ('200OK', [(' Content-Type','text/html')])
Return "Hello World"
Then execute the shell command:
Uwsgi-http: 8001-wsgi-file test.py
Visit the web page:
Http://127.0.0.1:8001/
See if there is a Hello World on the web page.
4. Write uwsgi startup configuration file
[root@host-192-168-1-56 devops] # more my.ini
[uwsgi]
Socket=:8001
Chdir=/svn/devops/devops # Project Directory
Pythonapth=/usr/bin/python
Processes=4
Env=DJANGO_SETTINGS_MODULE=devops.settings # specify the project name. Setting
Module=devops.wsgi # specify the wsgi.py configuration file, which is in the same directory as setting
Threads=0
Master=true
Daemonize=/tmp/uwsgi.log
Pidfile=/tmp/uwsgi.pid
Python-autoreload=true
Buffer-size=51200
5. Write wsgi configuration file
[root@host-192-168-1-56 devops] # more devops/wsgi.py
"
WSGI config for devops project.
It exposes the WSGI callable as a module-level variable named ``application`.
For more information on this file, see
Https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/
"
Import os
From django.core.wsgi import get_wsgi_application
Os.environ.setdefault ("DJANGO_SETTINGS_MODULE", "devops.settings")
Application = get_wsgi_application ()
6. Configure nginx
Configuration file
[root@host-192-168-1-56 devops] # more / usr/local/nginx/conf/vhost/blog.haodai.com.conf
Upstream django {
Server 127.0.0.1 we'll use this first 8001; # for a web port socket (we'll use this first)
}
Server {
Listen 8099
Server_name devops.XXX.net
Charset utf-8
Root / svn/devops/devops
Client_max_body_size 75M; # adjust to taste
Location / static {
Alias / svn/devops/devops/static;-nginx calls the static file of the project
Expires 20d
}
Location / {
Uwsgi_pass django;-reverse proxy, simply write it as uwsgi_pass 127.0.0.1 8001.
Include uwsgi_params
}
Access_log / home/wwwlogs/devops.log access
}
7 start, test
Start uwsgi and nginx
[root@host-192-168-1-56 devops] # / usr/local/python/bin/uwsgi my.ini
[root@host-192-168-1-56 devops] # nginx-s reload
Test:
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
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.