http://blog.glidenote.com
に移転しました

root権限の無いサーバーにvim7.2を導入する


http://www.vim.org/
root権限を与えられていないサーバでvimのバージョンが古く、利用できないプラグインがあったのでホームディレクトリにvim7.2を導入。
環境は下記の2つ。

  • CentOS release 4.6 (Final) / version 6.3.82
  • Fedora Core release 4 (Stentz) / vim version 6.3.86

作業は下記のような流れ。全て一般ユーザーで行います。

  1. インストールディレクトリと作業用ディレクトリの作成
  2. ソースとパッチのダウンロード
  3. パッチの適用とインストール

インストールディレクトリと作業用ディレクトリの作成

ホームディレクトリにインストール用ディレクトリと作業用ディレクトリを作成。

mkdir -p $HOME/local/{bin,src}

ソースとパッチのダウンロード

vimのページからソースをダウンロードして、展開。
http://www.vim.org/download.php

cd $HOME/local/src/
wget ftp://ftp.vim.org/pub/vim/unix/vim-7.2.tar.bz2
wget ftp://ftp.vim.org/pub/vim/extra/vim-7.2-extra.tar.gz
wget ftp://ftp.vim.org/pub/vim/extra/vim-7.2-lang.tar.gz
tar xjf vim-7.2.tar.bz2
tar zxvf vim-7.2-lang.tar.gz
tar zxvf vim-7.2-extra.tar.gz

続いてパッチをダウンロード。2010年5月13日現在、最新のパッチは416です。
若干時間がかかるので、気長に待ちましょう。(一つのサーバでダウンロードしたら、他のサーバはscpなどで持ってくるのが良いです)

cd  $HOME/local/src/vim72
mkdir patches
cd patches
curl -O 'ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.[001-416]'

パッチの適用とインストール

ダウンロードしたパッチをソースに当てます。

cd $HOME/local/src/vim72
cat patches/7.2.* | patch -p0

$HOME/local/bin/vim という形で利用したいので下記のようなconfigureオプションで、configure,make,make install。

./configure \
--enable-multibyte \
--enable-xim \
--enable-fontset \
--with-features=big \
--prefix=$HOME/local
 
make | tee make.log 2>&1
make install

追記:2010年5月17日
make の時、

os_unix.c:45:30: error: selinux/selinux.h: No such file or directory
…

とかでこけるサーバあったので、その場合はcofigureにdisable-selinuxを付加して対応。(selinux自体利用していないので)

./configure \
--enable-multibyte \
--enable-xim \
--enable-fontset \
--with-features=big \
--prefix=$HOME/local \
--disable-selinux

使用したconfigureのオプションの説明としては、マルチバイト(日本語)を利用するのに下記の3つ

  • –enable-multibyte
  • –enable-xim
  • –enable-fontset

多くの機能を有効。一応指定。無くてもたぶん問題ないと思います。

  • –with-features=big

$HOME/local/bin/vim という形で利用したいので、下記のような形で指定。

  • –prefix=$HOME/local

configureオプションの種類は下記のような感じです。正直どれを適用すればいいのか説明を見てもよく分からないですが。

./configure --help
 
`configure' configures this package to adapt to many kinds of systems.
 
Usage: auto/configure [OPTION]... [VAR=VALUE]...
 
To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.
 
Defaults for the options are specified in brackets.
 
Configuration:
  -h, --help              display this help and exit
      --help=short        display options specific to this package
      --help=recursive    display the short help of all the included packages
  -V, --version           display version information and exit
  -q, --quiet, --silent   do not print `checking...' messages
      --cache-file=FILE   cache test results in FILE [disabled]
  -C, --config-cache      alias for `--cache-file=config.cache'
  -n, --no-create         do not create output files
      --srcdir=DIR        find the sources in DIR [configure dir or `..']
 
Installation directories:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                          [PREFIX]
 
By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc.  You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.
 
For better control, use the options below.
 
Fine tuning of the installation directories:
  --bindir=DIR            user executables [EPREFIX/bin]
  --sbindir=DIR           system admin executables [EPREFIX/sbin]
  --libexecdir=DIR        program executables [EPREFIX/libexec]
  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
  --libdir=DIR            object code libraries [EPREFIX/lib]
  --includedir=DIR        C header files [PREFIX/include]
  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
  --infodir=DIR           info documentation [DATAROOTDIR/info]
  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
  --mandir=DIR            man documentation [DATAROOTDIR/man]
  --docdir=DIR            documentation root [DATAROOTDIR/doc/PACKAGE]
  --htmldir=DIR           html documentation [DOCDIR]
  --dvidir=DIR            dvi documentation [DOCDIR]
  --pdfdir=DIR            pdf documentation [DOCDIR]
  --psdir=DIR             ps documentation [DOCDIR]
 
X features:
  --x-includes=DIR    X include files are in DIR
  --x-libraries=DIR   X library files are in DIR
 
Optional Features:
  --disable-option-checking  ignore unrecognized --enable/--with options
  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
  --disable-darwin        Disable Darwin (Mac OS X) support.
  --disable-selinux       Don't check for SELinux support.
  --disable-xsmp          Disable XSMP session management
  --disable-xsmp-interact Disable XSMP interaction
  --enable-mzschemeinterp   Include MzScheme interpreter.
  --enable-perlinterp     Include Perl interpreter.
  --enable-pythoninterp   Include Python interpreter.
  --enable-tclinterp      Include Tcl interpreter.
  --enable-rubyinterp     Include Ruby interpreter.
  --enable-cscope         Include cscope interface.
  --enable-workshop       Include Sun Visual Workshop support.
  --disable-netbeans      Disable NetBeans integration support.
  --enable-sniff          Include Sniff interface.
  --enable-multibyte      Include multibyte editing support.
  --enable-hangulinput    Include Hangul input support.
  --enable-xim            Include XIM input support.
  --enable-fontset        Include X fontset output support.
  --enable-gui=OPTS     X11 GUI default=auto OPTS=auto/no/gtk/gtk2/gnome/gnome2/motif/athena/neXtaw/photon/carbon
  --enable-gtk-check      If auto-select GUI, check for GTK default=yes
  --enable-gtk2-check     If GTK GUI, check for GTK+ 2 default=yes
  --enable-gnome-check    If GTK GUI, check for GNOME default=no
  --enable-motif-check    If auto-select GUI, check for Motif default=yes
  --enable-athena-check   If auto-select GUI, check for Athena default=yes
  --enable-nextaw-check   If auto-select GUI, check for neXtaw default=yes
  --enable-carbon-check   If auto-select GUI, check for Carbon default=yes
  --disable-gtktest       Do not try to compile and run a test GTK program
  --disable-largefile     omit support for large files
  --disable-acl           Don't check for ACL support.
  --disable-gpm           Don't use gpm (Linux mouse daemon).
  --disable-sysmouse    Don't use sysmouse (mouse in *BSD console).
  --disable-nls           Don't support NLS (gettext()).
 
Optional Packages:
  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
  --with-mac-arch=ARCH    current, intel, ppc or both
  --with-developer-dir=PATH    use PATH as location for Xcode developer tools
  --with-local-dir=PATH   search PATH instead of /usr/local for local libraries.
  --without-local-dir     do not search /usr/local for local libraries.
  --with-vim-name=NAME    what to call the Vim executable
  --with-ex-name=NAME     what to call the Ex executable
  --with-view-name=NAME   what to call the View executable
  --with-global-runtime=DIR    global runtime directory in 'runtimepath'
  --with-modified-by=NAME       name of who modified a release version
  --with-features=TYPE    tiny, small, normal, big or huge (default: normal)
  --with-compiledby=NAME  name to show in :version message
  --with-plthome=PLTHOME   Use PLTHOME.
  --with-python-config-dir=PATH  Python's config directory
  --with-tclsh=PATH       which tclsh to use (default: tclsh8.0)
  --with-ruby-command=RUBY  name of the Ruby command (default: ruby)
  --with-x                use the X Window System
  --with-gtk-prefix=PFX   Prefix where GTK is installed (optional)
  --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional)
  --with-gnome-includes=DIR Specify location of GNOME headers
  --with-gnome-libs=DIR   Specify location of GNOME libs
  --with-gnome            Specify prefix for GNOME files
  --with-motif-lib=STRING   Library for Motif
  --with-tlib=library     terminal library to be used
 
Some influential environment variables:
  CC          C compiler command
  CFLAGS      C compiler flags
  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
              nonstandard directory <lib dir>
  LIBS        libraries to pass to the linker, e.g. -l<library>
  CPPFLAGS    C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
              you have headers in a nonstandard directory <include dir>
  CPP         C preprocessor
  XMKMF       Path to xmkmf, Makefile generator for X Window System
 
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.

最後に.bashrcやら、.zshrcやらにaliasを追記。

echo "alias vim='$HOME/local/bin/vim'" >> $HOME/.bashrc
 
echo "alias vim='$HOME/local/bin/vim'" >> $HOME/.zshrc

sourceでrcファイルを再読込するか、再ログイン。バージョンを確認して終了。

vim --version

参考サイト
さくらインターネットの共用サーバに vim をインストールする – talk to oneself 2

Write a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

About

@glidenote

このブログは個人的なものです。ここで述べられている内容は私の個人的な意見に基づくものであり、私の雇用者に一切の関係はありません