美文网首页码英客栈
CentOS 安装 Python3.7+OpenSSL1.1.1

CentOS 安装 Python3.7+OpenSSL1.1.1

作者: 七哥inn | 来源:发表于2018-12-05 08:31 被阅读0次

    序:
    本文主要讲述基于Scrapy的爬虫环境安装操作。包括安装Python3.7,安装OpenSSL1.1.1,安装MongoDB4.0及配置防火墙。
    根据本文安装后,基本上可以开始Scrapy爬虫的编写了。
    本文编撰于2018.12.05。

    本实例是编写爬虫的基础环境搭建。CentOS7.5+Python3.7+OpenSSL1.1.1+Scrapy

    基本安装

    CentOS的基本配置

    请看文章阿里云CentOS7.4基础操作

    安装Python 3.7

    • 本地安装Python3.7 环境。
    https://www.python.org/ftp/python/3.7.1/python-3.7.1-amd64.exe  (win10)
    
    https://www.python.org/ftp/python/3.7.1/python-3.7.1-macosx10.9.pkg (Mac)
    
    • PyCharm 会报R错误,可选安装R语言
    https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/base/R-3.5.1-win.exe
    
    • CentOS下安装
    wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tar.xz
    xz -d Python-3.7.1.tar.xz
    tar xvf Python-3.7.1.tar.xz
    解压到 python371
    
    wget https://www.openssl.org/source/openssl-1.1.1.tar.gz
    tar zxvf openssl-1.1.1.tar.gz
    解压到 openss-1.1.1
    
    • 安装编译环境 gcc-c++等
    yum install -y  libffi-devel  gcc-c++  zlib*  bzip2  sqlite*
    
    • 安装ssl
    cd openssl-1.1.1/
    
    ./config --prefix=/usr/local/openssl
    
    make
    make install
    
    cd /usr/local
    ldd /usr/local/openssl/bin/openssl
    会有not found
    
    mv /usr/bin/openssl /usr/bin/openssl.old
    ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
    echo "/usr/local/openssl/lib/" >> /etc/ld.so.conf
    ldconfig -v
    
    reboot 
    

    重启之后

    ldd /usr/local/openssl/bin/openssl
    
    openssl version -a
    

    查看版本,显示
    OpenSSL 1.1.1 11 Sep 2018

    • 安装Python3.7
    目标安装在我的用户名下的目录python3
    cd 
    mkdir python3
    我的路径:/home/seven/python3
    ./configure --prefix='/home/seven/python3' --with-openssl=/usr/local/openssl/
    make
    make install
    
    • 配置环境变量
    vim .bashrc
    
    最后添加两行
    alias python3=/home/seven/python3/bin/python3.7
    alias pip3=/home/seven/python3/bin/pip3
    

    安装Scrapy

    • 先安装 Twisted
    https://files.pythonhosted.org/packages/5d/0e/a72d85a55761c2c3ff1cb968143a2fd5f360220779ed90e0fadf4106d4f2/Twisted-18.9.0.tar.bz2
    
    

    再安装 Scrapy

    pip3 install scrapy
    
    vim .bashrc
    
    alias scrapy=/root/python3/bin/scrapy
    

    安装mongodb

    touch /etc/yum.repos.d/mongodb-org-4.0.repo 
    

    文件内容

    [mongodb-org-4.0]
    name=MongoDB Repository
    baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/
    gpgcheck=1
    enabled=1
    gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
    
    yum install -y mongodb-org
    
    vim /etc/mongod.conf
    修改 bindIP
    0.0.0.1
    

    开启防火墙端口

    firewall-cmd --zone=public --add-port=27017/tcp --permanent
    firewall-cmd --reload
    systemctl restart firewalld
    

    安装支持

    pip3 install pymongo
    

    相关文章

      网友评论

        本文标题:CentOS 安装 Python3.7+OpenSSL1.1.1

        本文链接:https://www.haomeiwen.com/subject/vnabcqtx.html