1.先安装libevent库,去官网下载对应的库文件,然后解压

 $ cd libevent-2.1.11-stable
 $ ./configure --prefix=/home/zhiyangh/usr/lib/libevent
 $ make && make install

2. 安装tmux

    在安装的时候需要指定libevent的库

    $ LIBEVENT_PATH=/home/zhiyangh/usr/lib/libevent
    $ ./configure --prefix=/home/zhiyangh/usr/lib/tmux CFLAGS="-I$LIBEVENT_PATH/include" LDFLAGS="-L$LIBEVENT_PATH/lib"
    $  make && make install

3. 这个时候去tmux安装目录下运行./tmux还是会报找不到

    ./tmux: error while loading shared libraries: libevent-2.1.so.7: cannot open shared object file: No such file or directory

    需要将安装的libevent配置到环境变量里面去

    例如:

    在~/.bashrc里面写上 export LD_LIBRARY_PATH=/home/zhiyangh/usr/lib/libevent/lib/:$LD_LIBRARY_PATH

 

4.另外为了避免每次启动terminal后都要手动运行tmux, 可以在~/.bashrc中增加一行, 这样就可以在打开终端时默认启动tmux: 

[[ $TERM != "screen" ]] && exec tmux