Centos6.x/7.x下面安装特定的python版本

  • 由于openssl出现问题,在源码编译安装python3的时候,会一直不成功,我测试了几个openssl的版本最后编译的时候都不能通过,最后根据python3给出的提示,安装了LibreSSL来代替openssl,LibreSSL是在看到openssl有问题的基础上开发出来的用来替代openssl的
#!/bin/bash
WORK_DIR=`mktemp -d`

#some Dependency software
yum install gcc make wget libffi-devel unzip zlib zlib-devel bzip2 bzip2-devel ncurses ncurses-devel readline readline-devel openssl  -y
yum install openssl-devel openssl-static xz lzma xz-devel sqlite sqlite-devel gdbm gdbm-devel tk tk-devel git -y

downloadPip(){
    curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
}

downloadSetuptools(){
    wget https://files.pythonhosted.org/packages/b0/d1/8acb42f391cba52e35b131e442e80deffbb8d0676b93261d761b1f0ef8fb/setuptools-40.6.2.zip
}

installLibreSSL(){
    cd $WORK_DIR && [ ! -f $WORK_DIR/libressl-2.8.1.tar.gz ] && wget https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-2.8.1.tar.gz
    tar zxvf libressl-2.8.1.tar.gz && cd libressl-2.8.1
    ./configure --prefix=/opt/libressl && make install
    mv /usr/bin/openssl /usr/bin/openssl.bak 
    mv /usr/include/openssl /usr/include/openssl.bak 
    ln -s /opt/libressl/bin/openssl /usr/bin/openssl 
    ln -s /opt/libressl//include/openssl /usr/include/openssl
    echo "/opt/libressl/lib" > /etc/ld.so.conf.d/libressl.conf
    ldconfig 
}

installPython2(){
    #get python2 and install python2
    cd $WORK_DIR && [ ! -f $WORK_DIR/Python-2.7.15.tar.xz ] && wget https://www.python.org/ftp/python/2.7.15/Python-2.7.15.tar.xz
    xz -d Python-2.7.15.tar.xz && tar -xvf  Python-2.7.15.tar && cd Python-2.7.15
    ./configure --prefix=/opt/python2
    make  && make install  && make clean  && make distclean

    #install setuptools
    cd $WORK_DIR && [ ! -f $WORK_DIR/setuptools-40.6.2.zip ] && downloadSetuptools
    unzip setuptools-40.6.2.zip && cd setuptools-40.6.2
    /opt/python2/bin/python2 ./setup.py install

    #install pip
    cd $WORK_DIR && [ ! -f $WORK_DIR/get-pip.py ] && downloadPip
    /opt/python2/bin/python2 $WORK_DIR/get-pip.py
}

installPython3(){
    installLibreSSL
    cd $WORK_DIR && [  ! -f $WORK_DIR/Python-3.7.1.tar.xz ] && 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 && cd Python-3.7.1
    export LDFLAGS="-L /opt/libressl/lib"
    export CPPFLAGS="-I /opt/libressl/include"
    export PKG_CONFIG_PATH="/opt/libressl/lib/pkgconfig"
    ./configure --prefix=/opt/python3 --enable-shared  CFLAGS=-fPIC ##--enable-optimizations 是优化选项(LTO,PGO 等)加上这个 flag 编译后,性能有 10% 左右的优化,但会花更多的时间
    make  && make install  && make clean && make distclean
    echo "/opt/python3/lib" > /etc/ld.so.conf.d/python3.conf
    ldconfig
    /opt/python3/bin/pip3 install --upgrade pip
}

echo -e "\033[31m Which python version do you want to install  :  \033[0m"
select var in "Python2" "Python3" "Python2andPython3" "Exit"
do
    case $var in
        "Python2")
            installPython2
            exit
            ;;
        "Python3")
            installPython3
            exit
            ;;
        "Python2andPython3")
            installPython2
            installPython3
            exit
            ;;
        "Exit")
            exit
            ;;
        *)
            echo "Please chose 1 || 2 || 3 || 4"
            ;;
    esac
done

#clear
cd  && [ -d $WORK_DIR ] && rm $WORK_DIR -rf

Nginx 源码安装脚本(centos版本)

#!/bin/bash
## install nginx
WORK_DIR=`mktemp -d`
yum install wget gcc gcc-c++ automake pcre pcre-devel zlib-devel openssl openssl-devel  git libxml2-devel libxslt-devel perl-devel perl-ExtUtils-Embed -y
cd $WORK_DIR
wget http://nginx.org/download/nginx-1.20.1.tar.gz
tar zxvf nginx-1.20.1.tar.gz && cd nginx-1.20.1
./configure --prefix=/opt/nginx --user=apache --group=apache --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-http_v2_module --with-http_dav_module --with-http_flv_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_sub_module --with-http_random_index_module --with-http_degradation_module --with-http_secure_link_module --with-http_perl_module --with-debug --with-file-aio --with-stream --with-ld-opt=-Wl,-E
make && make install
[ -d $WORK_DIR ] && rm $WORK_DIR -rf
## 添加nginx运行账户
groupadd apache
useradd -g apache -s /sbin/nologin -c "apache" apache

寻觅

风儿啊!你要把我推到哪里去呀!
这里可全都是黑暗啊
我什么都看不见了!


风儿啊!你要把我推到哪里去啊!
这里可全都是山呀!
我都找不到回家的路了!


风儿啊!你到底要把我推到哪里去呀!
我的眼里可全都是泪水啊!

2009年4月15日(星期三)

无言的悸动

是谁在那个山坡上翘首以望
心儿似泉水下落 叮咚作响
我要用桃花编织一张画卷
一笔一画描绘出我心中出现的悸动
弱柳禁不住你微笑的双靥
在微风中摇曳停留
而你短暂的驻足
换我无数个相思的梦
我等来了前世人面桃花的笑脸
但却不是为我而开
东风夜放只剩下不堪寂寞的响动
满池的花瓣
只剩下了命运的不公

10.4.6

我的土地

我愿伏在你的身上

亲吻着你的冰冷

我愿在你的身上

痛哭一场

为我那无望的幻想

然后抚摸着你

感受你才会给我的温暖

天真浪漫的人

注定是一个悲伤的人生

所以 我的土地

我愿把我所有的一切都献给你

时间的情对我来说

只是一场

带着浪漫的戏剧

我求的只是

土地的慰藉

2009年4月10日