前言
最近一直捯饬服务器,总在配置运行环境,这里记录一下,避免以后再捯饬又得到处查。我一直用 ubuntu,感觉软件管理工具还是挺好用的,但服务器用的是 CentOS 系统,在软件的安装方面,感觉没有 ubuntu 来的方便(主要是软件比较老旧,如 python 版本还是 2.6 的)。
安装开发包组升级操作系统:
update system
yum groupinstall "Development Tools" -y
yum update -y
1
2
yumgroupinstall"Development Tools"-y
yumupdate-y
编译安装 Git
安装编译 git 需要用要的库:
安装编译git依赖库
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
1
yuminstallcurl-develexpat-develgettext-developenssl-develzlib-devel
在 github 上下载源码(Download Zip),scp 到远端服务器上,unzip 以后,进入 git 目录,执行:
编译git
autoconf
./configure
1
2
autoconf
./configure
出错:
编译git出错
/usr/bin/perl Makefile.PL PREFIX='/usr/local' INSTALL_BASE='' --localedir='/usr/local/share/locale'
Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 3.
BEGIN failed--compilation aborted at Makefile.PL line 3.
make[1]: *** [perl.mak] Error 2
make: *** [perl/perl.mak] Error 2
1
2
3
4
5
/usr/bin/perlMakefile.PLPREFIX='/usr/local'INSTALL_BASE=''--localedir='/usr/local/share/locale'
Can'tlocateExtUtils/MakeMaker.pmin@INC(@INCcontains:/usr/local/lib64/perl5/usr/local/share/perl5/usr/lib64/perl5/vendor_perl/usr/share/perl5/vendor_perl/usr/lib64/perl5/usr/share/perl5.)atMakefile.PLline3.
BEGINfailed--compilationabortedatMakefile.PLline3.
make[1]:***[perl.mak]Error2
make:***[perl/perl.mak]Error2
网上搜了一下:
安装perl
yum install perl-devel
1
yuminstallperl-devel
接着:
make again
make
make install
1
2
make
makeinstall
python环境
Check out pyenv where you want it installed. A good place to choose is $HOME/.pyenv (but you can install it somewhere else).
安装pyenv
git clone https://github.com/yyuu/pyenv.git ~/.pyenv
1
gitclonehttps://github.com/yyuu/pyenv.git~/.pyenv
Define environment variable PYENV_ROOT to point to the path where pyenv repo is cloned and add $PYENV_ROOT/bin to your $PATH for access to the pyenv command-line utility.
Zsh note: Modify your ~/.zshenv file instead of ~/.bash_profile. Ubuntu note: Modify your ~/.bashrc file instead of ~/.bash_profile.
pyenv var
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
1
2
echo'export PYENV_ROOT="$HOME/.pyenv"'>>~/.bash_profile
echo'export PATH="$PYENV_ROOT/bin:$PATH"'>>~/.bash_profile
Add pyenv init to your shell to enable shims and autocompletion. Please make sure eval "$(pyenv init -)" is placed toward the end of the shell configuration file since it manipulates PATH during the initialization.
Zsh note: Modify your ~/.zshenv file instead of ~/.bash_profile. Ubuntu note: Modify your ~/.bashrc file instead of ~/.bash_profile.
pyenv init
echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
1
echo'eval "$(pyenv init -)"'>>~/.bash_profile
Restart your shell so the path changes take effect. You can now begin using pyenv.
exec shell
exec $SHELL
1
exec$SHELL
实际发现,source ~/.bash_profile 更好用(执行上面的命令,没有生效)
安装 python 依赖库文件
python依赖库文件
sudo yum install readline readline-devel readline-static
sudo yum install openssl openssl-devel openssl-static
sudo yum install sqlite-devel
sudo yum install bzip2-devel bzip2-libs
1
2
3
4
sudoyuminstallreadlinereadline-develreadline-static
sudoyuminstallopensslopenssl-developenssl-static
sudoyuminstallsqlite-devel
sudoyuminstallbzip2-develbzip2-libs
安装python
pyenv install --list 查看有那些 python 版本可以安装,选择一个安装即可:
install python
pyenv install 2.7.11
1
pyenvinstall2.7.11
安装 lxml
install lxml
yum install libxslt-devel
pip install lxml
1
2
yuminstalllibxslt-devel
pipinstalllxml
安装 scrapy
install cffi
sudo yum install gcc libffi-devel
pip install scrapy
1
2
sudoyuminstallgcclibffi-devel
pipinstallscrapy