标签: centos

  • Centos7安装Python12

    centos7自带的gcc和openssl版本过低无法成功编译python3.12,所以需要另外安装gcc11和编译openssl1.11。

    yum install centos-release-scl
    yum install -y devtoolset-11-gcc devtoolset-11-gcc-c++
    scl enable devtoolset-11 bash
    echo /opt/rh/devtoolset-11/root/usr/bin/gcc>>~/.bashrc
    yum install -y wget make cmake gcc bzip2-devel libffi-devel zlib-devel
    yum groupinstall -y "Development Tools"
    wget https://www.openssl.org/source/old/1.1.1/openssl-1.1.1w.tar.gz
    tar -zxf openssl-1.1.1w.tar.gz
    cd openssl-1.1.1w
    ./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl
    make && make install_sw
    export PATH=/usr/local/openssl/bin:\PATH
    export LD_LIBRARY_PATH=/usr/local/openssl/lib:\$LD_LIBRARY_PATH
    cd ..
    wget https://www.python.org/ftp/python/3.12.3/Python-3.12.3.tgz
    tar -zxf Python-3.12.3.tgz
    cd Python-3.12.3
    ./configure --with-openssl=/usr/local/python3 --enable-shared --enable-optimizations
    CFLAGS=-Wno-coverage-mismatch make
    make install
    export PATH=/usr/local/python3/bin:PATH
    export LD_LIBRARY_PATH=/usr/local/python3/lib:$LD_LIBRARY_PATH
    echo /usr/local/python3/lib/ > /etc/ld.so.conf.d/python.conf
    ldconfig
    

    Views: 14