System centos6.5
1, install the configuration nginx and Python
Yum Install Nginx
Python default installation is 2.6 need to upgrade to 2.7 see tutorial
2,django Installation
Download current Latest Version: Django-1.8.5.tar.gz
$ wget--no-check-certificate https://www.djangoproject.com/download/Django-1.8.5.tar.gz ( Note:--no-check-certificate certificate-free certification, otherwise can not download HTTPS resources) $ tar zxf django-1.8.5.tar.gz$ cd django-1.8.5$ python setup.py install[[ Email protected] dj17]# python python 2.7.3 (default, Jan 5, 10:09:00) [GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on Lin Ux2type "Help", "copyright", "credits" or "license" for more information.>>> import django>>> Django. VERSION (1, 8, 5, ' final ', 0)
Indicates that the Django installation was successful.
3, create a new Django project
[[email protected] nginx]# mkdir www[[email protected] nginx]# cd www[ [email protected] www]# django-admin startproject mysite[[email protected] www]# tree mysite/mysite/├── manage.py└── mysite ├── __init__. py ├── settings.py ├── urls.py └── wsgi.py1 directory, 5 files[[email protected] www]# cd mysite/[[ email protected] mysite]# python manage.py runserverperforming system Checks ... system check identified no issues (0 silenced). You have unapplied migrations; your app may not work properly until they are applied. run ' Python manage.py migrate ' to apply them. October 13, 2015 - 09:50:28django version 1.8.5, using settings ' mysite.settings ' Starting Development server at quit the server with control-c. [[Email protected] mysite]# python manage.py migrateoperations to perform: synchronize unmigrated apps: staticfiles, messages apply all migrations: admin, contenttypes, auth, sessionssynchronizing apps without migrations: creating tables... running deferred sql ... installing custom sql ... running migrations: rendering model states... done applying Contenttypes.0001_initial... ok applying auth.0001_initial... ok applying admin.0001_initial... ok applying contenttypes.0002_remove_content_type_name... ok applying auth.0002_alter_permission_name_max_length... ok applying auth.0003_alter_user_email_max_length... ok applying auth.0004_alter_user_username_ Opts... ok applying auth.0005_alter_user_last_login_null... ok applying auth.0006_require_contenttypes_0002... ok applying sessions.0001_initial... ok [[email protected] mysite]# python manage.py runserverperforming system Checks ... system check identified no issues (0 silenced). october 13, 2015 - 09:51:25django version 1.8.5, using settings ' Mysite.settings ' Starting development server at quit the server with control-c. [[email protected] dj17]# curl http://127.0.0.1:8000
Normal response
4, install Uwsgi
Http://uwsgi-docs.readthedocs.org/en/latest/Download.html
[Email protected] dj17]# wget http://projects.unbit.it/downloads/uwsgi-2.0.11.2.tar.gz
Support for Python/wsgi.
Installing the Uwsgi module
[[email protected] mysite]# pip install uwsgicollecting uwsgi/usr/lib/python2.7/ site-packages/pip-7.1.2-py2.7.egg/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: insecureplatformwarning: a true sslcontext object is not available. this prevents urllib3 from configuring ssl appropriately and may Cause certain ssl connections to fail. for more information, see insecureplatformwarning. InsecurePlatformWarning Downloading uwsgi-2.0.11.2.tar.gz (782kB) 100% |████████████████████████████████| 782kb 413kb/s installing collected packages: uwsgi running setup.py install for uwsgiSuccessfully installed uwsgi-2.0.11.2[[email protected] Mysite]# pip install collecting http://projects.unbit.it/downloads/uwsgi-lts.tar.gz downloading http:// projects.unbit.it/downloads/uwsgi-lts.tar.gz (782kB) 100% | ████████████████████████████████| 782kb 22kb/s requirement already satisfied (use --upgrade to upgrade): uwsgi==2.0.11.2 from http:// projects.unbit.it/downloads/uwsgi-lts.tar.gz in /usr/lib/python2.7/site-packages yum Install python-devel2.7[[email protected] .test]# tar zxf uwsgi-2.0.11.2.tar.gz [[email protected]linuxot-test-02 .test]# cd uwsgi-2.0.11.2[[email protected] uwsgi-2.0.11.2]# python uwsgiconfig.py --build[[email protected] uwsgi-2.0.11.2 ]# uwsgi --version2.0.11.2[[email protected] uwsgi-2.0.11.2]# cp uwsgi /usr /sbin/uwsgi
5, associating Django to Nginx
Vim/etc/nginx/conf.d/default.confserver {Listen default_server; server_name _; Location/{include uwsgi_params; Uwsgi_pass 127.0.0.1:9090; }}[[email protected] uwsgi-2.0.11.2]# service nginx Restart stop nginx: [OK] is starting Nginx: Determine [Email protected] mysite]# Uwsgi-s 127.0.0.1:9090-w Demo
Start Project
Visit Nginx's address to
This article is from the "Aolens blocks until those" blog, be sure to keep this source http://aolens.blog.51cto.com/7021142/1702735
Nginx+uwsgi+django+python Application Architecture Deployment