Install Python+Django+Nginx+UWSGI
一、软件环境:
CentOS6.6_64bit
需要用到的软件:
- [root@django tools]# ll
- 总用量 33336
- -rw-r--r-- 1 root root 7497785 3月 2 21:45 Django-1.9.12.tar.gz
- -rw-r--r-- 1 root root 911509 2月 27 18:32 nginx-1.10.3.tar.gz
- -rw-r--r-- 1 root root 1197370 3月 2 13:30 pip-9.0.1.tar.gz
- -rw-r--r-- 1 root root 20566643 6月 26 2016 Python-3.5.2.tgz
- -rw-r--r-- 1 root root 641502 3月 2 18:50 setuptools-19.6.tar.gz
- -rw-r--r-- 1 root root 2515143 3月 2 13:33 sqlite-autoconf-3170000.tar.gz
- -rw-r--r-- 1 root root 788971 3月 2 13:35 uwsgi-2.0.14.tar.gz
二、开始安装 Python+Django+Nginx+UWSGI
1、安装setuptools
不要问为什么安装这些包?不提前安装,你就等着后面报错吧! (-_-)
- [root@django tools]# yum install pcre pcre-devel openssl openssl-devel zlib -y
- [root@django tools]# ll
- 628 -rw-r--r-- 1 root root 641502 3月 2 18:50 setuptools-19.6.tar.gz
- [root@django tools]# tar xf setuptools-19.6
- [root@django tools]# cd setuptools-19.6
- [root@django tools]#python setup.py install
- [root@django tools]#cd ..
如果出现错误:
- File "/usr/local/python3/lib/python3.5/distutils/dist.py", line 974, in run_command
- cmd_obj.run()
- File "/home/nulige/tools/setuptools-19.6/setuptools/command/bdist_egg.py", line 223, in run
- dry_run=self.dry_run, mode=self.gen_header())
- File "/home/nulige/tools/setuptools-19.6/setuptools/command/bdist_egg.py", line 464, in make_zipfile
- z = zipfile.ZipFile(zip_filename, mode, compression=compression)
- File "/usr/local/python3/lib/python3.5/zipfile.py", line 987, in __init__
- _check_compression(compression)
- File "/usr/local/python3/lib/python3.5/zipfile.py", line 611, in _check_compression
- "Compression requires the (missing) zlib module")
- RuntimeError: Compression requires the (missing) zlib module
- 解决方法:
yum install zlib zlib-devel
安装完成后,重新编译 python3.X【不需要删除,只需要重新编译make && make install,安装就行了】
2、安装pip
- [root@django tools]# ll
- -rw-r--r-- 1 root root 1197370 3月 2 13:30 pip-9.0.1.tar.gz
- [root@django tools]# tar xf pip-9.0.1.tar.gz
- [root@django tools]# cd pip-9.0.1
- [root@django pip-9.0.1]# python setup.py install
- [root@django pip-9.0.1]# cd ..
- #配置环境变量:
- [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
- yum install sqlite-devel
或
- [root@django tools]# ll
- -rw-r--r-- 1 root root 2515143 3月 2 13:33 sqlite-autoconf-3170000.tar.gz
- [root@django tools]# tar xf sqlite-autoconf-3170000.tar.gz
- [root@django tools]# cd sqlite-autoconf-3170000
- [root@django tools]# ./configure
- [root@django tools]#make && make install
4、安装Python3
- 升级为python3.5版本步骤
- root@template ~]# cd /home/oldboy/tools/
- #下载python-3.5.2
- [root@template tools]# wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz
- [root@template tools]# ll
- 总用量 20104
- -rw-r--r-- 1 root root 20566643 6月 26 05:47 Python-3.5.2.tgz
- #解压到下载目录
- [root@template tools]# tar zxvf Python-3.5.2.tgz
- #进入解压后的文件夹
- [root@template tools]# cd Python-3.5.2
- #在编译前先在/usr/local建一个文件夹python3(作为python的安装路径,以免覆盖老的版本)
- [root@template Python-3.5.2]# mkdir /usr/local/python3
- #开始编译安装
- [root@template Python-3.5.2]# ./configure --prefix=/usr/local/python3
- [root@template Python-3.5.2]# make && make install
- 此时没有覆盖老版本,再将原来/usr/bin/python链接改为别的名字
- [root@template Python-3.5.2]# mv /usr/bin/python /usr/bin/python_old
- #再建立新版本python的软链接
- [root@template Python-3.5.2]# ln -s /usr/local/python3/bin/python3 /usr/bin/python
- #就会显示出python的新版本信息
- [root@template Python-3.5.2]# python
- Python 3.5.2 (default, Aug 2 2016, 11:35:06)
- [GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux
- Type "help", "copyright", "credits" or "license" for more information.
- >>> exit() #<----退出python
- PS:如果不建立新安装路径python3,而是直接默认安装,则安装后的新python应该会覆盖linux下自带的老版本,也有可能不覆盖,具体看安装过程了,这个大家可以自己试验下,当然如果还想保留原来的版本,那么这种方法最好不过了。
- 注意事项:
- 这种方法虽然能安装成功,但会导致yum不能正常使用。
- 解决方法:
- [root@template tools]# cp /usr/bin/yum /usr/bin/yum.backup_2016-08-02
- 修改第一行参数
- vi /usr/bin/yum
- 把 #!/usr/bin/python 修改为:/usr/bin/python_old
- 或
- 把 #!/usr/bin/python 修改为:/usr/bin/python2.6
- #查看版本
- [root@template Python-3.5.2]# python --version
- Python 3.5.2
5.安装Django框架
软件下载地址:https://www.djangoproject.com/
方式一:pip3
- pip3 install django
升级方法:
- pip3 install django --upgrade
方式二:编译安装
- [root@django tools]# ll
- -rw-r--r-- 1 root root 7497785 3月 2 21:45 Django-1.9.12.tar.gz
- [root@django tools]# tar xf Django-1.9.12.tar.gz
- [root@django tools]# cd Django-1.9.12
- [root@django Django-1.9.12]# python setup.py install
- [root@django Django-1.9.12]# cd ..
- Django的默认安装路径:
- [root@django tools]#ll -ld /usr/local/python3/lib/python3.5/site-packages/Django-1.9.12-py3.5
- [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
- 如要卸载django,如不知道Python3的安装目录,则使用如下命令确定site-packages的位置
python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
进入site-packages目录直接删除django目录- 运行django项目命令(备注:其它settings连接数据库方法跟window一样的)
- python manage.py runserver 0.0.0.0:80&
安装paramiko(python3)
- a、python3的时候,记得升级pip3,再安装就不会报错啦!(python2不需要升级)
- [root@paramiko-server tools]# pip3 install --upgrade pip
- Collecting pip
- Downloading pip-9.0.-py2.py3-none-any.whl (.3MB)
- % |████████████████████████████████| .3MB 471kB/s
- b、通过pip安装常用模块
- [root@paramiko-server tools]# pip3 install paramiko
6、安装PyMysql
- pip3 install PyMySQL
7、安装nginx
http://nginx.org/
- CentOS6.6_64bit
- 软件版本:nginx-1.10.3.tar.gz
- 一、安装nginx
- 1、国内云服务器,请自行检查gcc
- rpm -qa gcc*
- 如果没有安装,执行下面安装命令
- yum -y install gcc gcc-c++
- 2、create nginx username
- useradd nginx -s /sbin/nologin -M
- #检查nginx用户与用户组
- id nginx
- 3、开始安装nginx
- mkdir -p /home/nulige/tools
- cd /home/nulige/tools
- wget -q http://nginx.org/download/nginx-1.10.3.tar.gz
- tar xf nginx-1.10.3.tar.gz
- cd nginx-1.10.3
- ./configure --prefix=/application/nginx-1.10.3 --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module
- make && make install
- #创建软链接
- ls -ld /application/nginx-1.10.3/
- ln -s /application/nginx-1.10.3/ /application/nginx
- ls -l /application/nginx
- 4、启动nginx
- 检查nginx语法
- /application/nginx/sbin/nginx -t
- 启动nginx
- /application/nginx/sbin/nginx
- 5、查看启动端口
- [root@web01 nginx-1.10.3]# ps -ef|grep nginx|grep -v grep
- root 3576 1 0 21:48 ? 00:00:00 nginx: master process /application/nginx/sbin/nginx
- nginx 3577 3576 0 21:48 ? 00:00:00 nginx: worker process
- 6、访问nginx主页(测试成功)
8.安装uWSGI
https://uwsgi-docs.readthedocs.io/en/latest/Download.htm
方式一:pip安装
- pip install uwsgi
方式二:编译安装
[root@django tools]# ll
- -rw-r--r-- 1 root root 788971 3月 2 13:35 uwsgi-2.0.14.tar.gz
- [root@django tools]# tar xf uwsgi-2.0.14.tar.gz
- [root@django tools]# cd uwsgi-2.0.14
- [root@django uwsgi-2.0.14]# python uwsgiconfig.py --build
- [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的更多相关文章
- CentOS 6.5下安装Python+Django+Nginx+uWSGI
1.安装Python31.1先安装zlib库及其他三方库安装uWSGI时需要使用zlib,否则执行python uwsgiconfig.py --build时会报ImportError,就是因为在安装 ...
- 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 项目结构: 基 ...
- CentOS上部署Django+Nginx+Uwsgi环境
在CentOS上部署Django+Nginx+Uwsgi环境 奇谭 2016-09-01 评论 Linux python django nginx uwsgi VirtualEnv的作用:创建隔 ...
- Ubuntu+Django+Nginx+uWSGI+Mysql搭建Python Web服务器
Ubuntu+Django+Nginx+uWSGI+Mysql搭建Python Web服务器 闲着无聊的时候部署了一个Django项目玩,用vm虚拟机部署的. 准备工作 我使用的系统是Ubuntu16 ...
- Linux - 搭建Web项目(Django + nginx + uwsgi)
工作中碰到需要使用Django + nginx + uwsgi 搭建项目环境 1. 搭建基本环境 需要有python环境,不多做说明 需要安装nginx,不多做说明 需要安装uwsgi: yum in ...
- 吴裕雄--天生自然Django框架开发笔记:Django Nginx+uwsgi 安装配置
Django Nginx+uwsgi 安装配置 使用 python manage.py runserver 来运行服务器.这只适用测试环境中使用. 正式发布的服务,需要一个可以稳定而持续的服务器,比如 ...
- ubuntu+Django + nginx + uwsgi 部署
ubuntu+Django + nginx + uwsgi 部署 0.前期准备 注意:以下几件事都必须在激活虚拟环境下完成 运行以下命令生成项目所需的依赖列表,会在项目根目录生成一个requireme ...
- 第一篇:Win10系统搭建Python+Django+Nginx+MySQL 开发环境详解(完美版)
Win10+Python+Django+Nginx+MySQL 开发环境搭建详解 PaulTsao 说明:本文由作者原创,仅供内部参考学习与交流,转载引用请注明出处,用于商业目的请联系作者本人. Wi ...
- Django Nginx+uwsgi 安装配置
使用 python manage.py runserver 来运行服务器.这只适用测试环境中使用. 正式发布的服务,我们需要一个可以稳定而持续的服务器,比如apache, Nginx, lighttp ...
随机推荐
- Scrollify – jQuery全屏滚动插件
和 fullPage.js 一样,Scrollify 也是一款基于 jQuery 的全屏滚动插件.跟 fullPage.js 相比,Scrollify 更加小巧,压缩后不足 4KB.但功能上不如 fu ...
- CodeForcs 797E Array Queries
$dp$预处理,暴力. 如果$k > sqrt(n)$,那么答案不会超过$sqrt(n)$,暴力模拟即可.如果$k <= sqrt(n)$,那么可以$dp$预处理打表. #include ...
- react篇章-React 组件-向组件传递参数
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title&g ...
- 网页后门工具laudanum
网页后门工具laudanum laudanum是Kali Linux预先安装的Web Shell工具.它支持多种Web后台技术,如ASP.ASP.net .JSP.PHP.Coldfusion.它提 ...
- Hibernate 组合主键映射
在开发过程中创建数据库表时,有时候会发现单纯的创建一个主键是不可行的,有时候就需要多个字段联合保持唯一,本文讲述如何创建组合主键的映射. 例如:记录一个班的考试成绩.学生跟科目是多对多的关系,只有一个 ...
- BZOJ1935 园丁的烦恼
一个二维偏序的问题,学过了三维偏序cdq分治之后觉得这个题非常的水.只需按一维排序之后再用树状数组操作即可.——by VANE #include<bits/stdc++.h> using ...
- 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 ...
- [P1768]天路(分数规划+SPFA判负环)
题目描述 “那是一条神奇的天路诶~,把第一个神犇送上天堂~”,XDM先生唱着这首“亲切”的歌曲,一道猥琐题目的灵感在脑中出现了. 和C_SUNSHINE大神商量后,这道猥琐的题目终于出现在本次试题上了 ...
- 【插头DP】BZOJ1814-Formula
[题目大意] 给出一个m*n的矩阵里面有一些格子为障碍物,求经过所有非障碍格子的哈密顿回路个数. [思路] 最典型的插头DP.分为三种情况: (1)当前格子既没有上插头也没有左插头. 如果下边和右边都 ...
- --whole-archive和--no-whole-archive
--whole-archive选项解决的是编译中常遇到的问题.在代码中定义的符号(如函数名)还未使用到之前,链接器并不会把它加入到连接表中. 如下面这个例子: a.cpp: void func(){p ...