CentOS7 更换官方yum源为国内镜像yum源

oh my zsh安装和配置

安装vim

安装依赖项目

yum install -y wget ncurses-devel gcc gcc-c++ ctags

编译安装vim

# 从github克隆,速度贼慢,推荐直接去官网下载
# 我是直接在我的阿里云主机上git下来,再下载下来的
git clone https://github.com/vim/vim.git
wget ftp://ftp.vim.org/pub/vim/unix/vim-8.1.tar.bz2

# 清除configure产生的文件
cd vim
make distclean

# 生成Makefile文件
./configure \
--prefix=/apps/darren \
--with-modified-by=Darren \
--with-compiledby=Darren

# 安装(可能会报错)
make && make install

vim配置

git clone https://github.com/sylar-yin/myvim.git
cp myvim/.vim ~/ -rf
cp myvim/.vimrc ~/

alias vctags="ctags -R --c++-kinds=+p --fields=+iaS --extra=+q"
#添加到/etc/profile末尾

安装GCC

依赖项目安装

yum groupinstall -y 'Development Tools'
# 安装bison,解决编译中会提示 “WARNING: ‘bison’ is missing on your system.”
# 安装texinfo,解决编译中会提示“WARNING: ‘makeinfo’ is missing on your system”
# 安装i686的包是为了安装32位的头文件和库,如果不安装i686的包,请在configure时加入--disable-multilib,取消对32位的支持。
yum install -y texinfo bison flex gcc-gnat glibc-devel.i686 libgcc.i686

安装安装perl,老版本perl缺少none,导致automake运行报错

wget https://www.cpan.org/src/5.0/perl-5.34.0.tar.gz
tar xvf perl-5.34.0.tar.gz
cd perl-5.34.0
./Configure -des -Dprefix=/apps/darren
make
make test
make install

安装autoconf

# 下载autoconf
wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.71.tar.xz
tar xvf autoconf-2.71.tar.xz
cd autoconf-2.71
./configure --prefix=/apps/darren
make && make install

安装automake

# 首先需要安装perl环境
yum install -y perl perl-devel
yum install -y perl-Module-Install.noarch
# 安装包解决:找不到EXTERN.h文件的问题
yum install -y perl-ExtUtils-Embed
yum install -y perl-Thread-Queue

wget http://ftp.gnu.org/gnu/automake/automake-1.16.5.tar.xz
tar xvf automake-1.16.5.tar.xz
cd automake-1.16.5
./configure --prefix=/apps/darren
#修改Makefile 查找 /doc\/automake\-$(APIVERSION)
#doc/automake-$(APIVERSION).1: $(automake_script) lib/Automake/Config.pm
#    $(update_mans) automake-$(APIVERSION) --no-discard-stderr
#(automake-1.15版本 3686行)加上--no-discard-stderr
#(automake-1.16版本 3694行)加上--no-discard-stderr
make && make install

安装gmp mpfr mpc

# https://gcc.gnu.org/pub/gcc/infrastructure
wget http://ftp.gnu.org/gnu/gmp/gmp-6.1.0.tar.bz2
wget http://ftp.gnu.org/gnu/mpfr/mpfr-3.1.6.tar.bz2
wget http://ftp.gnu.org/gnu/mpc/mpc-1.0.3.tar.gz
wget https://gcc.gnu.org/pub/gcc/infrastructure/isl-0.18.tar.bz2
# 这三个按照顺序安装
tar xvf gmp-6.1.0.tar.bz2
cd gmp-6.1.0
./configure --prefix=/apps/darren
make && make install

tar xvf mpfr-3.1.6.tar.bz2
cd mpfr-3.1.6
./configure --prefix=/apps/darren
make && make install

tar xvf mpc-1.0.3.tar.gz
cd mpc-1.0.3
./configure --prefix=/apps/darren
make && make install

tar xvf isl-0.18.tar.bz2
cd isl-0.18
./configure --prefix=/apps/darren
make && make install

设置临时环境变量,编译gcc需要用到

export C_INCLUDE_PATH=/apps/darren/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=/apps/darren/include:$CPLUS_INCLUDE_PATH
export LD_LIBRARY_PATH=/apps/darren/lib:/apps/darren/lib64:$LD_LIBRARY_PATH
export LIBRARY_PATH=/apps/darren/lib:/apps/darren/lib64:$LIBRARY_PATH:

安装gcc

# 下载gcc9.2
wget http://ftp.gnu.org/gnu/gcc/gcc-11.2.0/gcc-11.2.0.tar.xz
tar -xvf gcc-11.2.0.tar.xz
cd gcc-11.2.0
sh contrib/download_prerequisites
mkdir build && cd build
# 考虑到默认版本为4.8,可能遇到兼容性问题,所以9.2的安装目录自己换一个目录
# ../configure --enable-checking=release --enable-languages=c,c++ --disable-multilib --prefix=/apps/darren
../configure \
--prefix=/apps/darren \
--mandir=/apps/darren/share/man \
--infodir=/apps/darren/share/info \
--enable-bootstrap \
--enable-languages=c,c++,objc,obj-c++,fortran,ada,go,lto \
--enable-shared \
--enable-threads=posix \
--enable-checking=release \
--enable-multilib \
--enable-cet=auto \
--enable-__cxa_atexit \
--enable-gnu-unique-object \
--enable-linker-build-id \
--enable-plugin \
--enable-initfini-array \
--enable-libmpx \
--enable-offload-targets=nvptx-none \
--enable-gnu-indirect-function \
--disable-libgcj \
--disable-multilib \
--disable-libunwind-exceptions \
--with-system-zlib \
--with-gcc-major-version-only \
--with-linker-hash-style=gnu \
--with-isl \
--with-cloog \
--without-cuda-driver \
--with-tune=generic \
--with-arch_32=x86-64 \
--build=x86_64-redhat-linux \

# 编译安装
make && make install

安装gdb

wget http://ftp.gnu.org/gnu/gdb/gdb-11.1.tar.xz
tar xvf gdb-11.1.tar.xz
cd gdb-11.1
./configure --prefix=/apps/darren
make && make install

# 我在安装gdb9.1很多文件报错,解决办法是,先升级到gdb8.3,在升级gdb9.1,并且gdb9.1不能直接使用configure文件配置了
mkdir build && cd build
当前路径的绝对路径/configure  --prefix=/data/app/

安装cmake

openssl依赖安装

wget https://www.openssl.org/source/openssl-3.0.0.tar.gz
tar xvf openssl-3.0.0.tar.gz
cd openssl-3.0.0
yum install -y zlib-devel pam-devel tcp_wrappers-devel
./Configure --prefix=/apps/darren
make && make install

CMake安装

git clone https://github.com/Kitware/CMake.git
cd Cmake
git tag -l
git checkout v3.21.4
./configure --prefix=/data/app
gmake && make install

安装ragel

colm依赖安装

git clone https://github.com/adrian-thurston/colm.git
cd colm
git tag -l
git checkout 0.14.7
./autogen.sh
# 提示You should run autoupdate
autoupdate
./configure --prefix=/apps/darren
make && make install

安装ragel

wget http://www.colm.net/files/ragel/ragel-6.10.tar.gz
tar xvf ragel-6.10.tar.gz
cd cd ragel-6.10
./configure --prefix=/apps/darren
make && make install

安装protobuf

安装依赖

yum install -y autoconf automake libtool libsysfs make g++ unzip

编译安装protobuf

git clone https://github.com/protocolbuffers/protobuf.git
cd protobuf
git submodule update --init --recursive
./autogen.sh
./configure --prefix=/apps/darren
make && make install

# 会报如下错误,需要编译安装libtool
+ mkdir -p third_party/googletest/m4
+ autoreconf -f -i -Wall,no-obsolete
configure.ac:30: error: possibly undefined macro: AC_PROG_LIBTOOL
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
autoreconf: /data/app/bin/autoconf failed with exit status: 1
# 
wget http://ftp.gnu.org/gnu/libtool/libtool-2.4.6.tar.gz
tar xvf libtool-2.4.6.tar.gz
cd libtool-2.4.6
./configure --prefix=/apps/darren
make && make install

安装boost库

安装icu4c库

git clone https://github.com/unicode-org/icu.git
cd icu/icu4c/source
./configure --prefix=/apps/darren
make -j2 && make install

安装boost库

wget https://nchc.dl.sourceforge.net/project/boost/boost/1.78.0/boost_1_78_0.tar.gz
tar xvf boost_1_78_0.tar.gz
cd boost_1_78_0
./bootstrap.sh --prefix=/apps/darren \
--with-icu \
--with-toolset=gcc \
--with-libraries=all \
--with-icu=/apps/darren/lib \
# b2配置参数在文件project-config.jam文件,使用帮助./b2 --help
![b2](https://www.bestdarren.top/upload/2020/04/b2-d43c02aefa5042608b147549fc2708bf.png)
./b2 --prefix=/apps/darren
./b2 --prefix=/apps/darren install

安装vcpkg

  vcpkg可帮助您在 Windows、Linux 和 MacOS 上管理 C 和 C++ 库。这个工具和生态系统正在不断发展,您的参与对它的成功至关重要!
  如需获取有关可用命令的简短描述,请执行 vcpkg help。

# 下载
wget https://codeload.github.com/git/git/tar.gz/v2.26.0
tar xvf git-2.26.0.tar.gz
cd  git-2.26.0
make prefix=/app all
make prefix=/app install
# 设置全局环境变量
echo "export PATH=$PATH:/app/bin" >>/etc/profile
source /etc/profile
# 查看版本
git --version
# git version 2.26.0

  如果之前用yum安装过需要现移除git

yum remove git

安装jsoncpp

wget  https://codeload.github.com/open-source-parsers/jsoncpp/tar.gz/refs/tags/1.9.5
mv 1.9.5.tar.gz jsoncpp-1.9.5.tar.gz
tar xvf jsoncpp-1.9.5.tar.gz
cd jsoncpp-1.9.5
mkdir -p build/release
cd build/release
cmake -DCMAKE_BUILD_TYPE=release \
-DCMAKE_INSTALL_PREFIX=/apps/darren \
-DBUILD_STATIC_LIBS=ON \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_INSTALL_INCLUDEDIR=include/jsoncpp \
-G "Unix Makefiles" ../..
make && make install

安装yaml-cpp库

wget https://codeload.github.com/jbeder/yaml-cpp/tar.gz/refs/tags/yaml-cpp-0.7.0
tar xvf yaml-cpp-0.7.0.tar.gz
cd yaml-cpp-yaml-cpp-0.7.0
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=release \
-DCMAKE_INSTALL_PREFIX=/apps/darren \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_INSTALL_INCLUDEDIR=include/yaml-cpp \
-G "Unix Makefiles" ../
make && make install

安装libevent库

wget https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz
tar xvf libevent-2.1.12-stable.tar.gz
cd libevent-2.1.12-stable
./configure --prefix=/apps/darren
make && make install

安装hiredis-vip库

wget https://codeload.github.com/vipshop/hiredis-vip/tar.gz/refs/tags/0.3.0
mv 0.3.0 hiredis-vip-0.3.0.tar.gz
tar xvf hiredis-vip-0.3.0.tar.gz
cd hiredis-vip-0.3.0
make
make install DESTDIR=/apps/darren

安装apache-zookeeper库

# maven依赖于java
# 查询本机已经安装的java发行版本
yum list installed | grep "java"
rpm -qa|grep java
# 查询仓库中的java发行版本
yum list |grep "java"
# 安装java 11
yum install java-11-openjdk.x86_64 \
java-11-openjdk-demo.x86_64 \
java-11-openjdk-devel.x86_64 \
java-11-openjdk-headless.x86_64 \
java-11-openjdk-javadoc.x86_64 \
java-11-openjdk-javadoc-zip.x86_64 \
java-11-openjdk-jmods.x86_64 \
java-11-openjdk-src.x86_64 \
java-11-openjdk-static-libs.x86_64
# 编辑配置文件
vim ~/.zshrc
# 添加如下内容
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.14.0.9-1.el7_9.x86_64
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
# 更新配置文件
source ~/.zshrc

# 从zookeeper某个版本开始,zookeeper编译安装不依赖ant,而是依赖maven
wget http://archive.apache.org/dist/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz
tar xvf apache-maven-3.8.4-bin.tar.gz
mv apache-maven-3.8.4 maven
mkdir /apps/darren/bin/apache
mv maven /apps/darren/bin/apache/
# 编辑配置文件
vim ~/.zshrc
# 添加如下内容
export MY_EVN=/apps/darren
export MAVEN_HOME=$MY_EVN/bin/apache/maven
export PATH=$ANT_HOME/bin:$MAVEN_HOME/bin:$PATH
# 更新配置文件
source ~/.zshrc

# 下载apache-zookeeper
https://dlcdn.apache.org/zookeeper/zookeeper-3.7.0/apache-zookeeper-3.7.0.tar.gz
tar xvf apache-zookeeper-3.7.0.tar.gz
cd apache-zookeeper-3.7.0
mvn clean install

## apache-zookeeper编译安装依赖于apache-ant
#wget http://archive.apache.org/dist/ant/binaries/apache-ant-1.10.12-bin.tar.gz
#tar xvf apache-ant-1.10.12-bin.tar.gz
#mv apache-ant-1.10.12 ant
#mv ant /apps/darren/bin/apache/
#vim ~/.zshrc
## 添加如下内容
#export MY_EVN=/apps/darren
#export ANT_HOME=$MY_EVN/bin/apache/ant
#export PATH=$ANT_HOME/bin:$PATH
## 更新配置文件
#source ~/.zshrc
#
## cyrus-sasl依赖于postgresql,安装postgresql数据库,
#yum list installed | grep "postgresql"
#yum list|grep "postgresql"
#yum install postgresql.x86_64 \
#postgresql-contrib.x86_64 \
#postgresql-devel.x86_64 \
#postgresql-docs.x86_64 \
#postgresql-libs.x86_64 \
#postgresql-server.x86_64 \
#postgresql-static.x86_64 
#
## 安装cyrus-sasl库
#wget https://github.com/cyrusimap/cyrus-sasl/releases/download/cyrus-sasl-2.1.27/cyrus-sasl-2.1.27.tar.gz
#tar xvf cyrus-sasl-2.1.27.tar.gz
#cd cyrus-sasl-2.1.27
#make distclean
#./configure \
#--prefix=/apps/darren \
#--disable-anon \
#--enable-plain \
#--enable-login \
#--enable-sql \
#--with-mysql=/usr/include/mysql/ \
#--with-authdaemond
#make && make install
## 编辑配置文件
#vim ~/.zshrc
## 添加如下内容
#export LD_LIBRARY_PATH=/usr/lib64/mysql:$MY_EVN/lib/sasl2:$LD_LIBRARY_PATH
#export LIBRARY_PATH=/usr/lib64/mysql:$MY_EVN/lib/sasl2:$LIBRARY_PATH:
#export LD_RUN_PATH=$MY_EVN/lib/sasl2:$LD_RUN_PATH
## 更新配置文件
#source ~/.zshrc

配置环境变量

vim /etc/profile
# 载文件末尾添加以下内容

# 可执行文件路径
export PATH=/apps/darren/bin:/apps/darren/sbin:$PATH

# 动态链接库
LD_LIBRARY_PATH=/apps/darren/lib:/apps/darren/lib64:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH

# 找到静态库的路径
LIBRARY_PATH=/apps/darren/lib:/apps/darren/lib64:$LIBRARY_PATH:
export LIBRARY_PATH

# gcc找到头文件的路径
C_INCLUDE_PATH=/apps/darren/include:$C_INCLUDE_PATH
export C_INCLUDE_PATH

# g++找到头文件的路径
CPLUS_INCLUDE_PATH=/apps/darren/include:$CPLUS_INCLUDE_PATH
export CPLUS_INCLUDE_PATH

# 为ctags添加别名
alias vctags="ctags -R --c++-kinds=+p --fields=+iaS --extra=+q"

# 退出vim,执行命令
source /etc/profile

# vim打开/etc/ld.so.conf
vim /etc/ld.so.conf
# 添加自己的库目录

# 更新/etc/ld.so.cache文件
/sbin/ldconfig