YANO's digital garage

Copyright ©YANO All rights reserved. https://www.bravotouring.com/~yano/

Last-modified: 2024-04-08 (月)


[一語一絵/IT系]

さくらのVPS乗り換え / 2012-05-08 (火)

3月に書いたさくらのVPSリニューアルについて、そのうち1GBに増量される予定があるとはいえHDD容量は20GBと100GBの差があり、同じ月額料金でスペックに差が付いてしまう事に悔しい思いをしていたのだが、[External]新プラン乗り換え優遇策が実施されているので、乗り換えることに。

メモリ2GBの[External]CloudCore VPSも試そうかと思ったのだが、月額945円が年契約のキャンペーン価格であり、正規の3ヶ月契約だと2,100円になるので見送った。

何はともあれコンソールから

$ sudo apt-get install openssh-server vim
してopenssh-servervimをインストール。 旧サーバから~/.ssh
$ scp -pr ~/.ssh 49.212.xx.yyy:~/
と、まるごとコピーした後、/etc/ssh/sshd_config
  • Port番号を22から変更
  • PasswordAuthenticationをnoに
  • PermitRootLoginをnoに
を変更。
$ sudo service ssh restart
sshdを再起動した後、remoteからのssh作業にスイッチ。

続いてお約束の設定変更。

$ sudo /usr/sbin/groupmod -n owner yano
$ sudo update-alternatives --config editor
で、グループ名とデフォルトエディタを変更。
$ sudo visudo
~~
%admin ALL=(ALL) NOPASSWD: ALL
sudoでいちいちパスワードを打たなくていいようvisudoでNOPASSWDオプションを付与しておく。

続いてaptをアップデートし、ntpbuild-essentialを導入。/etc/ntp.confを編集して、サーバをntp.jst.mfeed.ad.jpに変更。

$ sudo apt-get update
$ sudo apt-get install ntp build-essential
$ sudo vi /etc/ntp.conf
$ sudo /etc/init.d/ntp restart
それからロケール設定。
$ sudo apt-get install language-pack-ja
$ sudo locale-gen ja_JP.UTF-8
$ sudo /usr/sbin/update-locale LANG=ja_JP.UTF-8
で日本語(ja_JP.UTF-8)環境をインストールし、~/.bashrc
export LC_ALL="ja_JP.UTF-8"
てな具合にLC_ALLをexport。

続いてnsdを導入。パッケージとしてはnsd3nsdがあるが、積極的に旧版をチョイスするだけの根拠は持ち合わせて無いので、素直にnsd3を導入。

$ sudo apt-get install nsd3
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  nsd3
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 842kB of archives.
After this operation, 1,622kB of additional disk space will be used.
Get:1 http://jp.archive.ubuntu.com/ubuntu/ lucid/universe nsd3 3.2.4-1 [842kB]
Fetched 842kB in 0s (1,037kB/s)
Selecting previously deselected package nsd3.
(Reading database ... 42388 files and directories currently installed.)
Unpacking nsd3 (from .../archives/nsd3_3.2.4-1_i386.deb) ...
Processing triggers for man-db ...
Processing triggers for ureadahead ...
ureadahead will be reprofiled on next reboot
Setting up nsd3 (3.2.4-1) ...
dpkg-statoverrides: warning: --update given but /etc/nsd3/nsd.conf does not exist
Could not open /etc/nsd3/nsd.conf: No such file or directory
* Building nsd3 zones...
nsd3
$ sudo ls -la /etc/nsd3/
total 16
drwxr-x---  2 nsd  nsd  4096 May  8 11:21 .
drwxr-xr-x 80 root root 4096 May  8 11:46 ..
-rw-r--r--  1 root root 4406 Dec 14 10:06 nsd.conf.sample
という具合にインストールできて、昨年のようなエラーは出なくなった。

さて肝心の設定は~/etc/nsd3/nsd.conf~/etc/nsd3/xn--48jd5f0d.jp.zoneの設定ファイル編集後、nsd-checkconfで書式を確認し、nsdc rebuildでdbをアップデートした後、nsdc startする流れ。

$ sudo mv /etc/nsd3 /etc/nsd3.orig
$ sudo ln -s ~yano/etc/nsd3 /etc/
$ chmod 755 ~yano/etc/nsd3
$ sudo chown -R yano:owner ~yano/etc/nsd3 /etc
$ cd ~yano/etc/nsd3
$ cp -p nsd.conf.sample nsd.conf
$ vi ~/etc/nsd3/nsd.conf
$ vi ~/etc/nsd3/xn--48jd5f0d.jp.zone
$ nsd-checkconf /etc/nsd3/nsd.conf
$ sudo nsdc rebuild
$ sudo nsdc start
$ nslookup bravotouring.com localhost
Server:         localhost
Address:        127.0.0.1#53

Name:   bravotouring.com
Address: 49.212.xx.yyy
という結果になれば、ひとまず設定はOK。

続いてapache2php5のinstall。

yano@vps:~$ apt-get install apache2 php5-mysql php5-cli libapache2-mod-php5
に続いて、サイトの設定。default-siteを元に設定ファイル~yano/etc/apache2/www.bravotouring.comを作成し、default-siteはdisableに。
$ cd /etc/apache2/
$ sudo a2dissite default
Site default disabled.
Run '/etc/init.d/apache2 reload' to activate new configuration!
$ sudo a2enmod ssl
Enabling module ssl.
See /usr/share/doc/apache2.2-common/README.Debian.gz on how to configure SSL and create self-signed certificates.
Run '/etc/init.d/apache2 restart' to activate new configuration!
$ cd /etc/apache2/sites-available/
$ su -
# ln -s ~yano/etc/apache2/www.bravotouring.com /etc/apache2/sites-available/
# ln -s ~yano/etc/apache2/www.bravotouring.com-ssl /etc/apache2/sites-available/
# a2ensite www.bravotouring.com
Enabling site www.bravotouring.com.
Run '/etc/init.d/apache2 reload' to activate new configuration!
# a2ensite www.bravotouring.com-ssl
Enabling site www.bravotouring.com-ssl.
Run '/etc/init.d/apache2 reload' to activate new configuration!
# make-ssl-cert /usr/share/ssl-cert/ssleay.cnf ~yano/apache-ssl.crt
~~ WindowでCommonName(サイト名)の設定 ~~
# openssl x509 -in ~yano/apache-ssl.crt > /etc/ssl/certs/ssl-cert-www.bravotouring.com.pem
# openssl rsa -in ~yano/apache-ssl.crt > /etc/ssl/private/ssl-cert-www.bravotouring.com.key
# chmod 640 /etc/ssl/private/ssl-cert-www.bravotouring.com.key
# rm ~yano/apache-ssl.crt

PCREの設定で、/etc/php5/apache2/php.ini

[Pcre]
;PCRE library backtracking limit.
;pcre.backtrack_limit=100000
pcre.backtrack_limit=512000

;PCRE library recursion limit.
;Please note that if you set this value to a high number you may consume all
;the available process stack and eventually crash PHP (due to reaching the
;stack size limit imposed by the Operating System).
;pcre.recursion_limit=100000
pcre.recursion_limit=512000
と修正。

UserDirの設定では /etc/apache2/mods-enabled/userdir.conf

<IfModule mod_userdir.c>
  UserDir public_html
  UserDir disabled root

  <Directory /home/*/public_html>
#   AllowOverride FileInfo AuthConfig Limit Indexes
#   Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
    AllowOverride All
    Options MultiViews Indexes SymLinksIfOwnerMatch ExecCGI
    <Limit GET POST OPTIONS>
      Order allow,deny
      Allow from all
    </Limit>
    <LimitExcept GET POST OPTIONS>
      Order deny,allow
      Deny from all
    </LimitExcept>
  </Directory>
</IfModule>
/etc/apache2/mods-enabled/php5.conf
<IfModule mod_php5.c>
  <FilesMatch "\.ph(p3?|tml)$">
    SetHandler application/x-httpd-php
  </FilesMatch>
  <FilesMatch "\.phps$">
    SetHandler application/x-httpd-php-source
  </FilesMatch>
  # To re-enable php in user directories comment the following lines
  # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
  # prevents .htaccess files from disabling it.
  <IfModule mod_userdir.c>
    <Directory /home/*/public_html>
#     php_admin_value engine Off
    </Directory>
  </IfModule>
</IfModule>
の2ヶ所を書き換えて完了。

cgiは各ファイルを/usr/lib/cgi-bin/にまるっとコピー。

# scp -pr oldvps:/usr/lib/cgi-bin/* /usr/lib/cgi-bin/
# chown -R www-data:www-data /usr/lib/cgi-bin

【参照】
●INTERNET Watch http://internet.watch.impress.co.jp/
さくらインターネットがVPSに参入、月額980円の「さくらのVPS」開始 2010年9月1日
「さくらのVPS」がリニューアル、1Gプランが月額980円、2Gプランが月額1480円に 2012年3月21日
月945円でメモリ容量2GBが利用可能な「CloudCore VPS」を試す 2012年5月2日
●さくらインターネット http://www.sakura.ad.jp/
「さくらのVPS」リニューアルのお知らせ 2012年3月21日
「さくらのVPS」ご利用中のお客様の新プラン乗り換え優遇施策の実施について 2012年3月29日
「さくらのVPS」ご利用中のお客様の新プラン乗り換え優遇施策の実施期間延長について 2012年4月11日
さくらインターネット、仮想専用サーバサービス「さくらのVPS」をリニューアル 2012年3月21日
●VPS(仮想専用サーバ)のさくらインターネット http://vps.sakura.ad.jp/
●CloudCore VPS http://www.cloudcore.jp/vps/