一、软件环境:

CentOS6.6_64bit

需要用到的软件:

  1. [root@django tools]# ll
  2. 总用量 33336
  3. -rw-r--r-- 1 root root 7497785 3 2 21:45 Django-1.9.12.tar.gz
  4. -rw-r--r-- 1 root root 911509 2 27 18:32 nginx-1.10.3.tar.gz
  5. -rw-r--r-- 1 root root 1197370 3 2 13:30 pip-9.0.1.tar.gz
  6. -rw-r--r-- 1 root root 20566643 6 26 2016 Python-3.5.2.tgz
  7. -rw-r--r-- 1 root root 641502 3 2 18:50 setuptools-19.6.tar.gz
  8. -rw-r--r-- 1 root root 2515143 3 2 13:33 sqlite-autoconf-3170000.tar.gz
  9. -rw-r--r-- 1 root root 788971 3 2 13:35 uwsgi-2.0.14.tar.gz

二、开始安装 Python+Django+Nginx+UWSGI

1、安装setuptools

不要问为什么安装这些包?不提前安装,你就等着后面报错吧! (-_-)

  1. [root@django tools]# yum install pcre pcre-devel openssl openssl-devel zlib -y
  2.  
  3. [root@django tools]# ll
  4. 628 -rw-r--r-- 1 root root 641502 3 2 18:50 setuptools-19.6.tar.gz
  5.  
  6. [root@django tools]# tar xf setuptools-19.6
  7.  
  8. [root@django tools]# cd setuptools-19.6
  9.  
  10. [root@django tools]#python setup.py install
  1. [root@django tools]#cd ..

如果出现错误:

  1. File "/usr/local/python3/lib/python3.5/distutils/dist.py", line 974, in run_command
  2. cmd_obj.run()
  3. File "/home/nulige/tools/setuptools-19.6/setuptools/command/bdist_egg.py", line 223, in run
  4. dry_run=self.dry_run, mode=self.gen_header())
  5. File "/home/nulige/tools/setuptools-19.6/setuptools/command/bdist_egg.py", line 464, in make_zipfile
  6. z = zipfile.ZipFile(zip_filename, mode, compression=compression)
  7. File "/usr/local/python3/lib/python3.5/zipfile.py", line 987, in __init__
  8. _check_compression(compression)
  9. File "/usr/local/python3/lib/python3.5/zipfile.py", line 611, in _check_compression
  10. "Compression requires the (missing) zlib module")
  11. RuntimeError: Compression requires the (missing) zlib module
  12.  
  13. 解决方法:

yum install zlib zlib-devel

安装完成后,重新编译 python3.X【不需要删除,只需要重新编译make && make install,安装就行了】

2、安装pip

  1. [root@django tools]# ll
  2. -rw-r--r-- 1 root root 1197370 3 2 13:30 pip-9.0.1.tar.gz
  3.  
  4. [root@django tools]# tar xf pip-9.0.1.tar.gz
  5.  
  6. [root@django tools]# cd pip-9.0.1
  7.  
  8. [root@django pip-9.0.1]# python setup.py install
  1. [root@django pip-9.0.1]# cd ..
  2.  
  3. #配置环境变量:
  4.  
  5. [root@django bin]# vi /etc/profile
    export PATH="/usr/local/python3/bin:$PATH"

[root@django bin]# tail -1 /etc/profile
  export PATH="/usr/local/python3/bin:$PATH"

[root@django bin]# source /etc/profile

#查看帮助

[root@django bin]# pip3  或 pip

3、安装sqlite3

http://www.sqlite.org

  1. yum install sqlite-devel

  1. [root@django tools]# ll
  2. -rw-r--r-- 1 root root 2515143 3 2 13:33 sqlite-autoconf-3170000.tar.gz
  3.  
  4. [root@django tools]# tar xf sqlite-autoconf-3170000.tar.gz
  5.  
  6. [root@django tools]# cd sqlite-autoconf-3170000
  7.  
  8. [root@django tools]# ./configure
  9.  
  10. [root@django tools]#make && make install

4、安装Python3

  1. 升级为python3.5版本步骤
  2. root@template ~]# cd /home/oldboy/tools/
  3.  
  4. #下载python-3.5.2
  5. [root@template tools]# wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz
  6.  
  7. [root@template tools]# ll
  8. 总用量 20104
  9. -rw-r--r-- 1 root root 20566643 6 26 05:47 Python-3.5.2.tgz
  10.  
  11. #解压到下载目录
  12. [root@template tools]# tar zxvf Python-3.5.2.tgz
  13.  
  14. #进入解压后的文件夹
  15. [root@template tools]# cd Python-3.5.2
  16.  
  17. #在编译前先在/usr/local建一个文件夹python3(作为python的安装路径,以免覆盖老的版本)
  18. [root@template Python-3.5.2]# mkdir /usr/local/python3
  19.  
  20. #开始编译安装
  21. [root@template Python-3.5.2]# ./configure --prefix=/usr/local/python3
  22.  
  23. [root@template Python-3.5.2]# make && make install
  24.  
  25. 此时没有覆盖老版本,再将原来/usr/bin/python链接改为别的名字
  26. [root@template Python-3.5.2]# mv /usr/bin/python /usr/bin/python_old
  27.  
  28. #再建立新版本python的软链接
  29. [root@template Python-3.5.2]# ln -s /usr/local/python3/bin/python3 /usr/bin/python
  30.  
  31. #就会显示出python的新版本信息
  32. [root@template Python-3.5.2]# python
  33. Python 3.5.2 (default, Aug 2 2016, 11:35:06)
  34. [GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux
  35. Type "help", "copyright", "credits" or "license" for more information.
  36. >>> exit() #<----退出python
  37.  
  38. PS:如果不建立新安装路径python3,而是直接默认安装,则安装后的新python应该会覆盖linux下自带的老版本,也有可能不覆盖,具体看安装过程了,这个大家可以自己试验下,当然如果还想保留原来的版本,那么这种方法最好不过了。
  39.  
  40. 注意事项:
  41. 这种方法虽然能安装成功,但会导致yum不能正常使用。
  42.  
  43. 解决方法:
  44. [root@template tools]# cp /usr/bin/yum /usr/bin/yum.backup_2016-08-02
  45.  
  46. 修改第一行参数
  47. vi /usr/bin/yum
  48. #!/usr/bin/python 修改为:/usr/bin/python_old

  49. #!/usr/bin/python 修改为:/usr/bin/python2.6
  50.  
  51. #查看版本
  52. [root@template Python-3.5.2]# python --version
  53. Python 3.5.2

5.安装Django框架

软件下载地址:https://www.djangoproject.com/

方式一:pip3

  1. pip3 install django

升级方法:

  1. pip3 install django --upgrade

方式二:编译安装

  1. [root@django tools]# ll
  2. -rw-r--r-- 1 root root 7497785 3 2 21:45 Django-1.9.12.tar.gz
  3.  
  4. [root@django tools]# tar xf Django-1.9.12.tar.gz
  5.  
  6. [root@django tools]# cd Django-1.9.12
  7.  
  8. [root@django Django-1.9.12]# python setup.py install
  9.  
  10. [root@django Django-1.9.12]# cd ..
  11.  
  12. Django的默认安装路径:
  1. [root@django tools]#ll -ld /usr/local/python3/lib/python3.5/site-packages/Django-1.9.12-py3.5
  1. [root@django tools]#cd /usr/local/python3/lib/python3.5/site-packages/

[root@django site-packages]# ll
总用量 428
drwxr-xr-x 4 root root 4096 3月 2 21:49 Django-1.9.12-py3.5.egg
-rw-r--r-- 1 root root 271 3月 2 21:50 easy-install.pth
-rw-r--r-- 1 root root 126 3月 2 21:04 easy_install.py
drwxr-xr-x 11 root root 4096 3月 2 21:04 pip
drwxr-xr-x 2 root root 4096 3月 2 21:04 pip-8.1.1.dist-info
drwxr-xr-x 4 root root 4096 3月 2 21:09 pip-9.0.1-py3.5.egg
drwxr-xr-x 5 root root 4096 3月 2 21:04 pkg_resources
drwxr-xr-x 2 root root 4096 3月 2 21:04 __pycache__
-rw-r--r-- 1 root root 119 3月 2 21:03 README
drwxr-xr-x 5 root root 4096 3月 2 21:04 setuptools
-rw-r--r-- 1 root root 386241 3月 2 21:05 setuptools-19.6-py3.5.egg
drwxr-xr-x 2 root root 4096 3月 2 21:04 setuptools-20.10.1.dist-info
-rw-r--r-- 1 root root 28 3月 2 21:05 setuptools.pth

  1. 如要卸载django,如不知道Python3的安装目录,则使用如下命令确定site-packages的位置
    python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
    进入site-packages目录直接删除django目录
  2.  
  3. 运行django项目命令(备注:其它settings连接数据库方法跟window一样的)
  4.  
  5. python manage.py runserver 0.0.0.0:80&

安装paramiko(python3)

  1. apython3的时候,记得升级pip3,再安装就不会报错啦!(python2不需要升级)
  2.  
  3. [root@paramiko-server tools]# pip3 install --upgrade pip
  4. Collecting pip
  5. Downloading pip-9.0.-py2.py3-none-any.whl (.3MB)
  6. % |████████████████████████████████| .3MB 471kB/s
  7.  
  8. b、通过pip安装常用模块
  9. [root@paramiko-server tools]# pip3 install paramiko

6、安装PyMysql

  1. pip3 install PyMySQL

7、安装nginx

http://nginx.org/

  1. CentOS6.6_64bit
  2.  
  3. 软件版本:nginx-1.10.3.tar.gz
  4.  
  5. 一、安装nginx
  6.  
  7. 1、国内云服务器,请自行检查gcc
  8.  
  9. rpm -qa gcc*
  10.  
  11. 如果没有安装,执行下面安装命令
  12.  
  13. yum -y install gcc gcc-c++
  14.  
  15. 2create nginx username
  16.  
  17. useradd nginx -s /sbin/nologin -M
  18.  
  19. #检查nginx用户与用户组
  20. id nginx
  21.  
  22. 3、开始安装nginx
  23.  
  24. mkdir -p /home/nulige/tools
  25. cd /home/nulige/tools
  26. wget -q http://nginx.org/download/nginx-1.10.3.tar.gz
  27. tar xf nginx-1.10.3.tar.gz
  28. cd nginx-1.10.3
  29. ./configure --prefix=/application/nginx-1.10.3 --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module
  30. make && make install
  31.  
  32. #创建软链接
  33. ls -ld /application/nginx-1.10.3/
  34. ln -s /application/nginx-1.10.3/ /application/nginx
  35. ls -l /application/nginx
  36.  
  37. 4、启动nginx
  38.  
  39. 检查nginx语法
  40. /application/nginx/sbin/nginx -t
  41.  
  42. 启动nginx
  43. /application/nginx/sbin/nginx
  44.  
  45. 5、查看启动端口
  46.  
  47. [root@web01 nginx-1.10.3]# ps -ef|grep nginx|grep -v grep
  48. root 3576 1 0 21:48 ? 00:00:00 nginx: master process /application/nginx/sbin/nginx
  49. nginx 3577 3576 0 21:48 ? 00:00:00 nginx: worker process
  50.  
  51. 6、访问nginx主页(测试成功)

8.安装uWSGI

https://uwsgi-docs.readthedocs.io/en/latest/Download.htm

方式一:pip安装

  1. pip install uwsgi

方式二:编译安装

[root@django tools]# ll

  1. -rw-r--r-- 1 root root 788971 3 2 13:35 uwsgi-2.0.14.tar.gz
  2. [root@django tools]# tar xf uwsgi-2.0.14.tar.gz
  3. [root@django tools]# cd uwsgi-2.0.14
  4. [root@django uwsgi-2.0.14]# python uwsgiconfig.py --build
  5. [root@django uwsgi-2.0.14]# python setup.py install

writing dependency_links to uWSGI.egg-info/dependency_links.txt
  writing manifest file 'uWSGI.egg-info/SOURCES.txt'
  reading manifest file 'uWSGI.egg-info/SOURCES.txt'
  writing manifest file 'uWSGI.egg-info/SOURCES.txt'
  Copying uWSGI.egg-info to /usr/local/python3/lib/python3.5/site-packages/uWSGI-2.0.14-py3.5.egg-info
  running install_scripts

启动uWSGI

参考:http://blog.csdn.net/chenggong2dm/article/details/43937433

参考:http://www.cnblogs.com/alex3714/p/6538374.html

9.设置Django+nginx+uWSGI

pass

Install Python+Django+Nginx+UWSGI的更多相关文章

  1. CentOS 6.5下安装Python+Django+Nginx+uWSGI

    1.安装Python31.1先安装zlib库及其他三方库安装uWSGI时需要使用zlib,否则执行python uwsgiconfig.py --build时会报ImportError,就是因为在安装 ...

  2. python Django Nginx+ uWSGI 安装配置

    环境: CentOS7.python-3.5.3.Nignx 1.10.3 .Django 1.10.6.uWSGI 2.0.14 django项目目录:/var/webRoot/p1 项目结构: 基 ...

  3. CentOS上部署Django+Nginx+Uwsgi环境

    在CentOS上部署Django+Nginx+Uwsgi环境 奇谭  2016-09-01 评论  Linux  python django nginx uwsgi VirtualEnv的作用:创建隔 ...

  4. Ubuntu+Django+Nginx+uWSGI+Mysql搭建Python Web服务器

    Ubuntu+Django+Nginx+uWSGI+Mysql搭建Python Web服务器 闲着无聊的时候部署了一个Django项目玩,用vm虚拟机部署的. 准备工作 我使用的系统是Ubuntu16 ...

  5. Linux - 搭建Web项目(Django + nginx + uwsgi)

    工作中碰到需要使用Django + nginx + uwsgi 搭建项目环境 1. 搭建基本环境 需要有python环境,不多做说明 需要安装nginx,不多做说明 需要安装uwsgi: yum in ...

  6. 吴裕雄--天生自然Django框架开发笔记:Django Nginx+uwsgi 安装配置

    Django Nginx+uwsgi 安装配置 使用 python manage.py runserver 来运行服务器.这只适用测试环境中使用. 正式发布的服务,需要一个可以稳定而持续的服务器,比如 ...

  7. ubuntu+Django + nginx + uwsgi 部署

    ubuntu+Django + nginx + uwsgi 部署 0.前期准备 注意:以下几件事都必须在激活虚拟环境下完成 运行以下命令生成项目所需的依赖列表,会在项目根目录生成一个requireme ...

  8. 第一篇:Win10系统搭建Python+Django+Nginx+MySQL 开发环境详解(完美版)

    Win10+Python+Django+Nginx+MySQL 开发环境搭建详解 PaulTsao 说明:本文由作者原创,仅供内部参考学习与交流,转载引用请注明出处,用于商业目的请联系作者本人. Wi ...

  9. Django Nginx+uwsgi 安装配置

    使用 python manage.py runserver 来运行服务器.这只适用测试环境中使用. 正式发布的服务,我们需要一个可以稳定而持续的服务器,比如apache, Nginx, lighttp ...

随机推荐

  1. Scrollify – jQuery全屏滚动插件

    和 fullPage.js 一样,Scrollify 也是一款基于 jQuery 的全屏滚动插件.跟 fullPage.js 相比,Scrollify 更加小巧,压缩后不足 4KB.但功能上不如 fu ...

  2. CodeForcs 797E Array Queries

    $dp$预处理,暴力. 如果$k > sqrt(n)$,那么答案不会超过$sqrt(n)$,暴力模拟即可.如果$k <= sqrt(n)$,那么可以$dp$预处理打表. #include ...

  3. react篇章-React 组件-向组件传递参数

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title&g ...

  4. 网页后门工具laudanum

     网页后门工具laudanum laudanum是Kali Linux预先安装的Web Shell工具.它支持多种Web后台技术,如ASP.ASP.net .JSP.PHP.Coldfusion.它提 ...

  5. Hibernate 组合主键映射

    在开发过程中创建数据库表时,有时候会发现单纯的创建一个主键是不可行的,有时候就需要多个字段联合保持唯一,本文讲述如何创建组合主键的映射. 例如:记录一个班的考试成绩.学生跟科目是多对多的关系,只有一个 ...

  6. BZOJ1935 园丁的烦恼

    一个二维偏序的问题,学过了三维偏序cdq分治之后觉得这个题非常的水.只需按一维排序之后再用树状数组操作即可.——by VANE #include<bits/stdc++.h> using ...

  7. Codeforces 622 F. The Sum of the k-th Powers

    \(>Codeforces \space 622\ F. The\ Sum\ of\ the\ k-th\ Powers<\) 题目大意 : 给出 \(n, k\),求 \(\sum_{i ...

  8. [P1768]天路(分数规划+SPFA判负环)

    题目描述 “那是一条神奇的天路诶~,把第一个神犇送上天堂~”,XDM先生唱着这首“亲切”的歌曲,一道猥琐题目的灵感在脑中出现了. 和C_SUNSHINE大神商量后,这道猥琐的题目终于出现在本次试题上了 ...

  9. 【插头DP】BZOJ1814-Formula

    [题目大意] 给出一个m*n的矩阵里面有一些格子为障碍物,求经过所有非障碍格子的哈密顿回路个数. [思路] 最典型的插头DP.分为三种情况: (1)当前格子既没有上插头也没有左插头. 如果下边和右边都 ...

  10. --whole-archive和--no-whole-archive

    --whole-archive选项解决的是编译中常遇到的问题.在代码中定义的符号(如函数名)还未使用到之前,链接器并不会把它加入到连接表中. 如下面这个例子: a.cpp: void func(){p ...