nginxをServersman@VPSに導入してランディングページを作った記録
久しぶりの更新になります。
現在体調を崩してしまい長めの休暇を会社から貰っています。
PCに向かう元気も出てきたので回復するまでの休暇を利用して勉強をしていこうと考えています。
4月にVPSを契約したころ先輩に「そんなロースペックだったらWEBサーバーはapacheじゃなくてnginxがいいよ」と教えて頂いたのを思い出して早速導入してみました。
ついでに個人の静的なランディングページを作ってみました。WEB上の素材やtipsを利用して、デザインセンスがない割に良いページが出来たと自負しております笑
nginxの導入
Install
こちらのstable releaseの
wget http://nginx.org/download/nginx-1.2.0.tar.gz tar xvf nginx-1.2.0.tar.gz cd nginx-1.2.0 ./configure
すると
./configure: error: the HTTP rewrite module requires the PCRE library. You can either disable the module by using --without-http_rewrite_module option, or install the PCRE library into the system, or build the PCRE library statically from the source with nginx by using --with-pcre=<path> option.
(Perl Compatible Regular Expressions)PCREライブラリが無いと怒られます。
PCREとはPerl5互換の正規表現を使うためのライブラリのようです(http://www.pcre.org/)
PCREライブラリをダウンロードして再度configureします。
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.31.tar.gz tar xvf pcre-8.31.tar.gz cd nginx-1.2.0 ./configure --with-pcre=/home/fakeyakuza/pcre-8.31
すると今度はzlibがないと怒られます。
./configure: error: the HTTP gzip module requires the zlib library. You can either disable the module by using --without-http_gzip_module option, or install the zlib library into the system, or build the zlib library statically from the source with nginx by using --with-zlib=<path> option.
zlibはzipやgzipなどの圧縮アルゴリズムをライブラリ化したものです。(http://zlib.net/)
zlibをダウンロードして再度configureします。
wget http://zlib.net/zlib-1.2.7.tar.gz tar xvf zlib-1.2.7.tar.gz cd nginx-1.2.0 ./configure --with-pcre=/home/fakeyakuza/pcre-8.31 --with-zlib=/home/kisho/nginx-1.2.0/auto/lib/zlib/
やっとうまくいきました。
残りのmakeをやります。
make sudo make install
これでインストールは完了です。
nginxの起動、停止は以下のとおり。
もっと詳しくはCommandLineを見て頂ければと思います。
/usr/local/nginx/sbin/nginx #起動 /usr/local/nginx/sbin/nginx -s stop #停止
今後はnginxの仕組みの理解(実はなんで早いのかとかあまりわかっていない・・・^^;) apacheとの共存、設定いじりなどをしていきたいです。
ランディングページの作成
Collapsing Vertical Nav | PixelsDaily(via UICloud)
Perfect Full Page Background Image | CSS-Tricks
このあたりを利用させて頂いて自分が撮った写真を背景として利用して作成しました。
作成したページは/usr/local/nginx/html/以下に置けばOKです。