Centos7搭建Django1.9.11+nginx+MySQL5.7

Centos7搭建Django1.9.11+nginx+MySQL5.7

1. Centos7 修改yum源

为提高下载速度,将Centos的默认源修改为阿里镜像:

过程

在创建缓存过程中如果遇到:

failure: repodata/repomd.xml from epel: [Errno 256] No more mirrors to try.

需要把/etc/yum.repos.d/目录下的文件全删了,重新更新Base源

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
yum clean all
yum makecache #生成缓存

参照:

https://www.jianshu.com/p/7cbd1d6b76a2

2. 安装Python3+pip

参照:

https://blog.51cto.com/9393764/2167559

1.执行:yum install python-pip

若没有python-pip包,先执行:yum -y install epel-release,再执行yum install python-pip

2.pip install --upgrade pip

centos默认安装了python2.7

mkdir /usr/local/python3

3.安装依赖包:

yum -y groupinstall "Development tools"

安装的时候可能安装不上,或者其他什么问题,可以通过更换源来解决
Linux(CentOS7.1)修改默认yum源为国内的阿里云yum源
下载wget
yum install wget -y
echo 备份当前的yum源
mv /etc/yum.repos.d /etc/yum.repos.d.backup4comex
echo 新建空的yum源设置目录
mkdir /etc/yum.repos.d
echo 下载阿里云的yum源配置
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
然后重建缓存:
yum clean all
yum makecache

yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

4.在/usr/local/python3目录下

wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz
tar -xvf  Python-3.6.2.tar.xz
cd Python-3.6.2
./configure --prefix=/usr/local/python3
make && make install

5.切换到/usr/bin/目录下

mv python python.bak
mv pip pip.bak
ln -s /usr/local/python3/bin/python3 /usr/bin/python
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip

6.防止以后用yum源安装软件时报错,修改以下两项
修改 /usr/bin/yum 的第一行

#!/usr/bin/python改成#!/usr/bin/python2.7

修改 /usr/libexec/urlgrabber-ext-down的第一行

#!/usr/bin/python改成#!/usr/bin/python2.7

7.验证

输入python,进入python3.6.2

输入python2,进入python2.7

8、这里还有一个问题是在使用pip安装模块的时候经常会报错

[root@localhost Python-3.6.2]# pip install ipython==1.2.1
Collecting ipython==1.2.1
Could not fetch URL https://pypi.python.org/simple/ipython/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748) – skipping
Could not find a version that satisfies the requirement ipython==1.2.1 (from versions: )
No matching distribution found for ipython==1.2.1

这是因为ssl证书没有认证,可以使用国内的镜像

pip install ipython==1.2.1 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

其中ipython是包的名字,这样即可解决。

其他参考:

https://www.cnblogs.com/badseal/p/8445096.html

安装过程一些问题解决:

  1. Linux设置默认Python版本
  2. Linux中python3安装pip
  3. yum except KeyboardInterrupt, e: 错误
  4. 使用yum命令报错File “/usr/bin/yum”, line 30 except KeyboardInterrupt, e:
  5. 使用yum命令报错File “/usr/bin/yum”, line 30 except KeyboardInterrupt, e:

3. 安装Django+MySQL+Nginx

参照:

Linux下Django+MySQL+Nginx

补充:

CentOS6.8编译安装Python3.6 + pip + Nginx

【CentOS-7.4】Django+Nginx+MySQL

手动搭建 LNMP 环境(CentOS 7)在原教程安装nginx时会报错,请参照这个步骤

其中MySQL的安装要参照这个:

CentOS7 yum方式安装MySQL5.7

再安装Sublime Text:

CentOS 7.x 安装Sublime Text 3.0正式版

其中安装python-devel,参考下面的教程:

安装python-devel开发包

赞赏
Nemo版权所有丨如未注明,均为原创丨本网站采用BY-NC-SA协议进行授权,转载请注明转自:https://nemo.cool/580.html
没有标签
首页      Dev      Python      Centos7搭建Django1.9.11+nginx+MySQL5.7

Nemo

文章作者

发表回复

textsms
account_circle
email

Centos7搭建Django1.9.11+nginx+MySQL5.7
1. Centos7 修改yum源 为提高下载速度,将Centos的默认源修改为阿里镜像: 过程 在创建缓存过程中如果遇到: failure: repodata/repomd.xml from epel: [Errno 256] No more mirrors …
扫描二维码继续阅读
2020-07-16