CentOS7通过yum方式安装mysql8

  • mysql8增加了许多新特性,比如支持JSON格式,密码认证方式改成了”caching-sha2-password”,不过很多客户端还不支持的,在将来肯定都会支持的。如果客户端不支持的话还是可以改成”mysql_native_password”方式。
#!/bin/bash
yum install wget -y
wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
rpm -Uvh mysql80-community-release-el7-1.noarch.rpm
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
yum install mysql-community-server -y
systemctl start mysqld.service
systemctl enable mysqld.service
systemctl status mysqld.service

#查看mysql自己生成的临时密码
grep 'temporary password' /var/log/mysqld.log

## 由于 default_password_lifetime 的存在,必须修改默认密码之后才能使用
alter user user() identified by "yourpassword";

CENTOS7通过YUM方式安装PHP7

  • CENTOS7.X自带源里面的PHP版本太老旧了,已经不适合大多数的场景。下面介绍的是通过YUM方式安装的PHP7,优点是缺少模块,可以很快的安装,不像通过源码按照的每次需要编译一下,比较繁琐。这种方式的缺点就是YUM源在国外,速度较慢。
#!/bin/bash 
yum remove php*
yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum -y install yum-utils
yum-config-manager --enable remi-php74
yum update
yum install php php-zip php-bcmath php-cli php-common php-dba php-devel \
    php-embedded php-enchant php-fpm php-gd php-imap php-interbase php-intl php-ldap php-xlswriter  \
    php-mbstring php-mysqlnd php-odbc php-opcache php-sodium \
    php-pdo php-pdo_dblib php-pear php-pecl-apcu php-pecl-imagick php-pecl-memcached \
    php-pecl-mongodb php-pecl-redis php-pgsql php-process \
    php-pspell php-recode php-snmp php-soap php-tidy php-xml php-xmlrpc -y
systemctl start  php-fpm
systemctl enable  php-fpm
systemctl status  php-fpm
php -v

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日(星期三)