YANO's digital garage

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

Last-modified: 2024-04-10 (水)


[一語一絵/IT系]

vpsもTrusty / 2014-06-06 (金)

2012年5月に導入したさくらのVPS。先日のGT110bに続いてTrusty化。

何はともあれ[External]VPSリモートコンソールから

root@vps:~# apt-get install update-manager-core
root@vps:~# do-release-upgrade -d
を投入する手順でトライしてみたが、やはり先日のGT110bと同様にCPAN/Perl絡みでエラーが量産される状況で環境を引き継ぐオンラインアップデートは不可。

というわけで、潔く再インストールを決断して[External]VPSコントロールパネルから「OS再インストール」をポチッとな。「Ubuntu 14.04」を選択した後はガイダンスに従ってポチポチと一時間弱。

/home配下は無事に引き継げたので/etc/ssh/sshd_config

  • Port番号を22から"ほにゃらら"に変更
  • PasswordAuthenticationはnoに
  • PermitRootLoginはwithout-passwordのままでOK
とし、
$ sudo service ssh restart
sshdを再起動した後、remoteからのssh作業にスイッチ。

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

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

続いてaptをアップデートし、ntpbuild-essentialを導入。

$ sudo apt-get update
$ sudo apt-get install ntp build-essential
[External]インターネットマルチフィード時刻情報サービス:サービス詳細に倣って/etc/ntp.confのサーバをntp1~3.jst.mfeed.ad.jpに変更。
# Specify one or more NTP servers.

# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
# on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for
# more information.
# server 0.ubuntu.pool.ntp.org
# server 1.ubuntu.pool.ntp.org
# server 2.ubuntu.pool.ntp.org
# server 3.ubuntu.pool.ntp.org
server ntp1.jst.mfeed.ad.jp
server ntp2.jst.mfeed.ad.jp
server ntp3.jst.mfeed.ad.jp
sudo /etc/init.d/ntp restart
今回はロケール設定は英語のままで。

まずはドメイン名が引けないと何も始まらないので、nsdを導入。

$ sudo apt-get install nsd
バージョンは4になったが、/etc/nsd/nsd.confの最後にゾーン設定を追加するだけ。肝心のゾーンファイルなどはそのままでいけそうだ。

続いてapache2php5のinstall。

$ sudo apt-get install apache2 php5 php5-mysql php5-cli libapache2-mod-php5
修正するのは/etc/apache2/mods-available/userdir.conf
*** userdir.conf.orig   2014-01-03 23:48:41.000000000 +0900
--- userdir.conf        2014-06-06 23:36:52.084814230 +0900
***************
*** 3,10 ****
        UserDir disabled root

        <Directory /home/*/public_html>
!               AllowOverride FileInfo AuthConfig Limit Indexes
!               Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
                <Limit GET POST OPTIONS>
                        Require all granted
                </Limit>
--- 3,11 ----
        UserDir disabled root

        <Directory /home/*/public_html>
! #             AllowOverride FileInfo AuthConfig Limit Indexes
! #             Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
!               AllowOverride All
                <Limit GET POST OPTIONS>
                        Require all granted
                </Limit>
/etc/apache2/mods-available/php5.conf
*** php5.conf.orig      2014-04-10 02:25:47.000000000 +0900
--- php5.conf   2014-06-06 23:39:21.914981486 +0900
***************
*** 22,27 ****
  # prevents .htaccess files from disabling it.
  <IfModule mod_userdir.c>
      <Directory /home/*/public_html>
!         php_admin_flag engine Off
      </Directory>
  </IfModule>
--- 22,27 ----
  # prevents .htaccess files from disabling it.
  <IfModule mod_userdir.c>
      <Directory /home/*/public_html>
! #       php_admin_flag engine Off
      </Directory>
  </IfModule>

cgiは各ファイルを/usr/lib/cgi-bin/にまるっと復元し、

# cd /usr/lib/
# tar xvf ~yano/sysbackup/vps.cgi-bin.tar.bz2
# chown -Rh www-data:www-data /usr/lib/cgi-bin

続いてpostfixdovecotspamassassinのinstall。

$ sudo apt-get install postfix postfix-policyd-spf-perl dovecot-core dovecot-pop3d dovecot-imapd spamassassin spamassassin-rules-ja procmail
まずMaildir形式の設定は/etc/dovecot/conf.d/10-mail.confで。
diff -bcr dovecot.orig/conf.d/10-mail.conf /etc/dovecot/conf.d/10-mail.conf
*** dovecot.orig/conf.d/10-mail.conf    2014-05-15 03:11:09.000000000 +0900
--- /etc/dovecot/conf.d/10-mail.conf    2014-06-07 00:32:35.134055880 +0900
***************
*** 27,33 ****
  #
  # <doc/wiki/MailLocation.txt>
  #
! mail_location = mbox:~/mail:INBOX=/var/mail/%u

  # If you need to set multiple mailbox locations or want to change default
  # namespace settings, you can do it by defining namespace sections.
--- 27,34 ----
  #
  # <doc/wiki/MailLocation.txt>
  #
! #   mail_location = mbox:~/mail:INBOX=/var/mail/%u
! mail_location = maildir:~/Maildir

  # If you need to set multiple mailbox locations or want to change default
  # namespace settings, you can do it by defining namespace sections.
ユーザ設定は既定で[External]Linux-PAMに対応しているので、/usr/local/etc/dovecot-passwdを作っていちいち手作業で登録する必要も無く、楽ちんになった。 StartSSLのサーバ証明書対応(つまりPOP3s)は/etc/dovecot/conf.d/10-ssl.conf
diff -bcr dovecot.orig/conf.d/10-ssl.conf /etc/dovecot/conf.d/10-ssl.conf
*** dovecot.orig/conf.d/10-ssl.conf     2014-05-15 03:11:09.000000000 +0900
--- /etc/dovecot/conf.d/10-ssl.conf     2014-06-09 13:11:59.444922703 +0900
***************
*** 9,16 ****
  # dropping root privileges, so keep the key file unreadable by anyone but
  # root. Included doc/mkcert.sh can be used to easily generate self-signed
  # certificate, just make sure to update the domains in dovecot-openssl.cnf
! ssl_cert = </etc/dovecot/dovecot.pem
! ssl_key = </etc/dovecot/private/dovecot.pem

  # If key file is password protected, give the password here. Alternatively
  # give it when starting dovecot with -p parameter. Since this file is often
--- 9,18 ----
  # dropping root privileges, so keep the key file unreadable by anyone but
  # root. Included doc/mkcert.sh can be used to easily generate self-signed
  # certificate, just make sure to update the domains in dovecot-openssl.cnf
! # ssl_cert = </etc/dovecot/dovecot.pem
! # ssl_key = </etc/dovecot/private/dovecot.pem
! ssl_cert = </etc/ssl/certs/ssl-mail.pem
! ssl_key = </etc/ssl/private/ssl-mail.key

  # If key file is password protected, give the password here. Alternatively
  # give it when starting dovecot with -p parameter. Since this file is often
あたりで、 SMTP認証はPostfix側が/etc/postfix/main.cf
smtpd_sasl_auth_enable = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_authenticated_header = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
で、 dovecot側が/etc/dovecot/conf.d/10-master.conf
diff -bcr dovecot.orig/conf.d/10-master.conf /etc/dovecot/conf.d/10-master.conf
*** dovecot.orig/conf.d/10-master.conf  2014-05-15 03:11:09.000000000 +0900
--- /etc/dovecot/conf.d/10-master.conf  2014-06-07 01:23:30.811983604 +0900
***************
*** 93,101 ****
    }

    # Postfix smtp-auth
!   #unix_listener /var/spool/postfix/private/auth {
!   #  mode = 0666
!   #}

    # Auth process is run as this user.
    #user = $default_internal_user
--- 93,101 ----
    }

    # Postfix smtp-auth
!   unix_listener /var/spool/postfix/private/auth {
!     mode = 0666
!   }

    # Auth process is run as this user.
    #user = $default_internal_user

【参照】
●さくらインターネット http://www.sakura.ad.jp/
●VPS(仮想専用サーバ)のさくらインターネット http://vps.sakura.ad.jp/
●インターネットマルチフィード時刻情報サービス http://www.jst.mfeed.ad.jp/
サービス詳細