markdown Linux的新装系统环境配置

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown Linux的新装系统环境配置相关的知识,希望对你有一定的参考价值。

# 新装系统环境配置
## 安装系统常用开发工具
- **Ubuntu**: 
```zsh
$ sudo apt install -y build-essential
```
- **Redhat**: 
```zsh
$ sudo yum groupinstall "Development Tools"
```

### 1. 安装[shadowsocks-libev](https://github.com/shadowsocks/shadowsocks-libev)
- 从PPA安装[ppa:max-c-lv/shadowsocks-libev](https://launchpad.net/~max-c-lv/+archive/ubuntu/shadowsocks-libev)
```zsh
$ 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](https://github.com/JinnLynn/genpac),设置系统代理
```zsh
$ pip install genpac

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

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

### 3. 安装[Git](https://github.com/git/git)
- 从PPA安装[ppa:git-core/ppa](https://launchpad.net/~git-core/+archive/ubuntu/ppa)
```zsh
$ sudo add-apt-repository ppa:git-core/ppa
$ sudo apt update
$ sudo apt install -y git
```
- 从源代码安装[git](https://github.com/git/git/blob/master/INSTALL)
```zsh
$ 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
```zsh
$ 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](https://github.com/rofl0r/proxychains-ng)
```zsh
$ 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](https://github.com/zsh-users/zsh) and [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh)
- 从源代码安装[zsh](https://github.com/zsh-users/zsh/blob/master/INSTALL)
```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
- 安装[oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh)
```zsh
$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
```
- 安装[zsh-autosuggestions](https://github.com/zsh-users/zsh-autosuggestions)插件
```zsh
$ git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
```

### 6. 安装Vim
- 从PPA安装[ppa:jonathonf/vim](https://launchpad.net/~jonathonf/+archive/ubuntu/vim)(Notice that this Vim don't have python compiled)
```zsh
$ sudo add-apt-repository ppa:jonathonf/vim
$ sudo apt update
$ sudo apt install -y vim
```
- 从源代码安装[Vim](https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source)
```zsh
$ 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
```

- 安装[Vundle](https://github.com/VundleVim/Vundle.vim)
```zsh
$ git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
$ cp ~/conf/.vimrc ~
$ vim +PluginInstall +qall
```
- 配置[YouCompleteMe](https://github.com/Valloric/YouCompleteMe)插件
```zsh
$ 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](https://github.com/Valloric/YouCompleteMe#full-installation-guide),自己手动安装
    - 从[LLVM](http://releases.llvm.org/download.html)官网下载最新版本的Clang压缩包并解压到`~/llvm`
    - 编译ycm_core库
```zsh
$ 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
```
- 安装[Powerline fonts](https://github.com/powerline/fonts)
```zsh
$ cd ~
$ git clone https://github.com/powerline/fonts.git
$ cd fonts
$ ./install.sh
```

### 7. 安装[tmux](https://github.com/tmux/tmux)
```zsh
# 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
```
- 安装[oh-my-tmux](https://github.com/gpakosz/.tmux)
```zsh
$ cd
$ git clone https://github.com/gpakosz/.tmux.git
$ ln -s -f .tmux/.tmux.conf .
$ cp ~/conf/.tmux.conf.local .
```

### 8. 安装virtualenv及[autoenv](https://github.com/kennethreitz/autoenv)
```zsh
# 安装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](https://www.google.com/chrome/browser/desktop/index.html)
- 从[google](https://www.google.com/chrome/browser/desktop/index.html)下载deb安装包
- 或者使用[google linux repository](https://www.google.com/linuxrepositories/)
```zsh
$ 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](https://github.com/powerline/fonts)
```zsh
# clone
$ git clone https://github.com/powerline/fonts.git --depth=1
# install
$ cd fonts
$ ./install.sh
# clean-up a bit
$ cd ..
$ rm -rf fonts
```

以上是关于markdown Linux的新装系统环境配置的主要内容,如果未能解决你的问题,请参考以下文章

linux新装系统优化

Linux中JDK环境配置

Centos6.5 -- 环境初始配置

CentOS7.5 新装系统如何查看网络,配置网卡信息

Ubuntu安装jdk,正确配置环境变量

Redhat7新装Redhat7使用前基本配置