GuoLi
5/18/2018 - 3:08 AM

Linux新装系统环境配置

Linux新装系统环境配置

新装系统环境配置

安装系统常用开发工具

  • Ubuntu:
$ sudo apt install -y build-essential
  • Redhat:
$ sudo yum groupinstall "Development Tools"

1. 安装shadowsocks-libev

$ sudo add-apt-repository ppa:max-c-lv/shadowsocks-libev
$ sudo apt update
$ sudo apt install -y shadowsocks-libev
$ sudo add-apt-repository -r ppa:max-c-lv/shadowsocks-libev
  • Systemd shadowsocks-libev service start ss-server by default, if working as client,
    edit /lib/systemd/system/shadowsocks-libev.service and replace ss-server to ss-local.
    May also need to edit /etc/init.d/shadowsocks-libev and replace ss-server to ss-local.

2.安装genpac,设置系统代理

$ pip install genpac

# 生成autoproxy.pac文件
$ genpac -c ~/conf/genpac/config.ini

# 在LinuxMint下通过cinnamon-settings打开系统设置->网络->网络代理
# 使用自动设置,URL填写'file:///home/username/autoproxy.pac'

3. 安装Git

$ sudo add-apt-repository ppa:git-core/ppa
$ sudo apt update
$ sudo apt install -y git
  • 从源代码安装git
$ cd
$ sudo apt install -y build-essential autoconf asciidoc xsltproc
$ curl -L https://github.com/git/git/archive/master.zip -o git.zip
$ unzip git.zip
$ cd git-master
$ make configure
$ ./configure --prefix=/usr
$ make all doc
$ sudo make install install-doc install-html

  • 配置git
$ git config --global user.name guoli100
$ git config --global user.email golotv@163.com
$ git config --global credential.helper 'cache --timeout=86400'
$ git config --global http.proxy socks5://127.0.0.1:1080
$ git config --global https.proxy socks5://127.0.0.1:1080
$ git config --global core.editor vim

4. 安装Proxychains-ng

$ sudo apt install -y build-essential
$ git clone https://github.com/rofl0r/proxychains-ng.git
$ cd proxychains-ng
$ ./configure --prefix=/usr --sysconfdir=/etc
$ make
$ sudo make install
$ sudo make install-config (installs proxychains.conf)

5. 安装zsh and oh-my-zsh

  • 从源代码安装zsh
# for Ubuntu system
$ sudo apt install -y autoconf perl libncurses5-dev yodl
# for Redhat system
$ sudo yum install -y ncurses-devel

$ cd
$ git clone https://github.com/zsh-users/zsh.git
$ cd zsh
$ ./Util/preconfig
$ ./configure --prefix=/usr --bindir=/bin
$ make
$ sudo make install
$ which zsh | sudo tee -a /etc/shells
$ chsh -s "$(which zsh)"

登出当前shell后再重新登入,启用zsh

$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
$ git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions

6. 安装Vim

$ sudo add-apt-repository ppa:jonathonf/vim
$ sudo apt update
$ sudo apt install -y vim
  • 从源代码安装Vim
$ sudo apt-get install libncurses5-dev libgnome2-dev libgnomeui-dev \
libgtk2.0-dev libatk1.0-dev libbonoboui2-dev \
libcairo2-dev libx11-dev libxpm-dev libxt-dev python-dev \
python3-dev ruby-dev lua5.1 lua5.1-dev libperl-dev
$ sudo apt remove vim vim-runtime gvim
$ cd ~
$ git clone https://github.com/vim/vim.git
$ cd vim
$ ./configure --with-features=huge \
--enable-multibyte \
--enable-rubyinterp=yes \
--enable-pythoninterp=yes \
--with-python-config-dir=/usr/lib/python2.7/config-x86_64-linux-gnu/ \
--enable-python3interp=yes \
--with-python3-config-dir=/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu/ \
--enable-perlinterp=yes \
--enable-luainterp=yes \
--enable-gui=gtk2 --enable-cscope --prefix=/usr
$ make VIMRUNTIMEDIR=/usr/share/vim/vim80
$ sudo make install
$ sudo update-alternatives --install /usr/bin/editor editor /usr/bin/vim 1
$ sudo update-alternatives --set editor /usr/bin/vim
$ sudo update-alternatives --install /usr/bin/vi vi /usr/bin/vim 1
$ sudo update-alternatives --set vi /usr/bin/vim
$ git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
$ cp ~/conf/.vimrc ~
$ vim +PluginInstall +qall
$ sudo apt-get install build-essential cmake python-dev python3-dev
$ cd ~/.vim/bundle/YouCompleteMe
$ ./install.py --clang-completer
  • 如果VIM里显示YCM启动不成功,有可能是YCM安装脚本自动下载的LLVM版本不对,可以参考Full Installation Guide,自己手动安装
    • LLVM官网下载最新版本的Clang压缩包并解压到~/llvm
    • 编译ycm_core库
$ cd ~
mkdir ycm_build
$ cd ycm_build
$ cmake -G "Unix Makefiles" . -DPATH_TO_LLVM_ROOT=~/llvm ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp
$ cmake --build . --target ycm_core
$ cd ~
$ git clone https://github.com/powerline/fonts.git
$ cd fonts
$ ./install.sh

7. 安装tmux

# for Ubuntu system
$ sudo apt install -y libevent-dev libncurses5-dev autoconf automake pkg-config
# for Redhat system
$ sudo yum install -y libevent-devel ncurses-devel

$cd
$ git clone https://github.com/tmux/tmux.git
$ cd tmux
$ sh autogen.sh
$ ./configure
$ make
$ sudo make install
$ cd
$ git clone https://github.com/gpakosz/.tmux.git
$ ln -s -f .tmux/.tmux.conf .
$ cp ~/conf/.tmux.conf.local .

8. 安装virtualenv及autoenv

# 安装virtualenv
# sudo apt install -y virtualenv
$ pip3 install virtualenv
$ mkdir python-project-name
$ cd python-project-name
$ virtualenv -p python3 venv
$ source venv/bin/activate

# 安装autoenv
$ git clone git://github.com/kennethreitz/autoenv.git ~/.autoenv
$ vim ~/.zshrc
AUTOENV_ENABLE_LEAVE='yes'
source ~/.autoenv/activate.sh
# 在python项目目录下新建.env和.env.leave文件,并在文件里写入shell命令
$ cd python-project-name
$ cat .env
source `dirname $0`/env/bin/activate
$ cat .env.leave
deactivate

9. 安装google-chrome

$ wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
$ sudo sh -c "echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' > /etc/apt/sources.list.d/google-chrome.list"
$ sudo apt update
$ sudo apt install -y google-chrome-stable
# 设置google通过pac代理上网
$ google-chrome --proxy-pac-url='file:///home/username/autoproxy.pac'

10. 安装powerline fonts

参考Powerline

# clone
$ git clone https://github.com/powerline/fonts.git --depth=1
# install
$ cd fonts
$ ./install.sh
# clean-up a bit
$ cd ..
$ rm -rf fonts