Pre-installed: Nginx, Django
Django Site Tree
| Site
|-----Blog (self-built project)
|-----manage.py
|-----Site (setting URL Wsgi ...)
| |-----wsgi.py
|-----static
| |-----JS
| |-----CSS
|-----uwsgi.log
|-----uwsgi-socket.xml
1. LIBXML2, Libxml2-devel, Uwsgi
1.1 Installation
Note: You must first install LIBXML2, Libxml2-devel, and then install Uwsgi
RPM–IVH libxml2*****
Pip:pip Install Uwsgi
Tar:python Setup.pu Install
1.2 Test Uwsgi
Vim testuwsgi.py
DEF application (env, Start_response):
Start_response (' K OK ', [(' Content-type ', ' text/html ')])
Return "Uwsgi ok!"
Command line execution:
Uwsgi--http:8001--wsgi-file testuwsgi.py
Browser test:127.0.0.1:8001
2. Configure site/wsgi.py
Import Sys
Import OS
Os.environ.setdefault ("Django_settings_module", "logsite.settings")
From Django.core.wsgi import get_wsgi_application
application = Get_wsgi_application ()
Sys.path.append ('/site ')
Sys.path.append ('/site/site ')
3. Test Uwsgi +django
Execute command:
uwsgi--http:8001--chdir/site/site--module wsgi
/site/site is the directory of wsgi.py
Wsgi as Module
Browser test: 127.0.0.1:8001
4. Nginx + Uwsgi + Django
4.1 Creating Nginx + UWSGI for socket connection XML file
Vim/site/uwsgi-socket.xml
<uwsgi>
<socket>:8001</socket> <!--do not use 8000 port, reserved 8000 convenient interpreter test--
<chdir>/Site/Site</chdir>
<module>wsgi</module>
<processes>4</processes><!--Process Number--
<daemonize>uwsgi.log</daemonize><!--Create a log file--
</uwsgi>
4.2 Modifying the nginx.conf configuration file
server {
listen 8080;
server_name www.site.com;
Access_log/logs/access.log;
Error_log/logs/error.log;
Location /{
Include Uwsgi_params;
Uwsgi_pass 127.0.0.1:8001;
Uwsgi_paramuwsgi_chdir/site/site;
Uwsgi_paramuwsgi_script Wsgi;
}
#静态文件路径
location/static {
alias/site/static;
}
}
4.3 Restart Nginx Service
Cd/usr/local/nginx/sbin
./nginx-s Reload
4.4 Starting the UWSGI server
Uwsgi-x Django-socket.xml
4.5 Access to services
ip:8080
Www.site.com
Nginx+uwsgi Deploying Django