系统中心6.5
1.安装nginx和Python。
yum install nginxPython默认随2.6安装,必须升级到2.7。请参见示例教程。
2.django装置
下载今天的全新版本:Django-1.8.5.tar.gz
$ wget --no-check-certificate https://www.djangoproject.com/download/Django-1.8.5.tar.gz (备注名称:--no-check-certificate 免资格证书验证,要不然下载不了https資源) $ tar zxf Django-1.8.5.tar.gz $ cd Django-1.8.5 $ python setup.py install [root@LinuxOT-Test-02 dj17]# python Python 2.7.3 (default, Jan 5 2013, 10:09:00) [GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> import django>>> django.VERSION(1, 8, 5, 'final', 0)它表明django已成功安装。
3.创建新的django项目
[root@LinuxOT-Test-02 nginx]# mkdir www [root@LinuxOT-Test-02 nginx]# cd www [root@LinuxOT-Test-02 www]# django-admin startproject mysite [root@LinuxOT-Test-02 www]# tree mysite /mysite/ ├── manage.py └── mysite ├── __init__.py ├── settings.py ├── urls.py └── wsgi.py1 directory, 5 files [root@LinuxOT-Test-02 www]# cd mysite/ [root@LinuxOT-Test-02 mysite]# python manage.py runserver Performing 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:28 Django version 1.8.5, using settings 'mysite.settings'Starting development server at Quit the server with CONTROL-C. [root@LinuxOT-Test-02 mysite]# python manage.py migrate Operations 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 [root@LinuxOT-Test-02 mysite]# python manage.py runserver Performing 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. [root@LinuxOT-Test-02 dj17]# curl http://127.0.0.1:8000反应很正常。
4.安装uwsgi
下载详细地址http://uwsgi-docs.readthedocs.org/en/latest/Download.html
[ root@LinuxOT-Test-02 dj17]# wget http://projects.unbit.it/downloads/uwsgi-2.0.11.2.tar.gz适用于Python/wsgi。
安装uwsgi控制模块
[root@LinuxOT-Test-02 mysite]# pip install uwsgi Collecting 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 415kB/s Installing collected packages: uwsgi Running setup.py install for uwsgi Successfully installed uwsgi-2.0.11.2 [root@LinuxOT-Test-02 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 [root@LinuxOT-Test-02 .test]# tar zxf uwsgi-2.0.11.2.tar.gz [root@LinuxOT-Test-02 .test]# cd uwsgi-2.0.11.2 [root@LinuxOT-Test-02 uwsgi-2.0.11.2]# python uwsgiconfig.py --build [root@LinuxOT-Test-02 uwsgi-2.0.11.2]# uwsgi --version2.0.11.2 [root@LinuxOT-Test-02 uwsgi-2.0.11.2]# cp uwsgi /usr/sbin/uwsgi5、django和nginx的关系
vim /etc/nginx/conf.d/default.conf server { listen 80 default_server; server_name _; location / { include uwsgi_params; uwsgi_pass 127.0.0.1:9090; } } [root@LinuxOT-Test-02 uwsgi-2.0.11.2]# service nginx restart 终止 nginx: [明确] 已经起动 nginx: [明确] [root@LinuxOT-Test-02 mysite]# uwsgi -s 127.0.0.1:9090 -w demo开始新项目
只需浏览nginx的详细地址。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)