CentOS 5.3 x86_64にISPConfig3をインストール

今回はIPアドレス「192.168.24.1」のホスト名「your.host.name」にインストールする仮定で。

1. CentOS 5.3 x86_64をインストール。

・ディスクからでもネットワーク経由でもいいからまずはインストール
パーティションの切り方は自由)
・デフォルトでインストールするシステムで「Server」を選択し、「今すぐカスタマイズする」にチェックして「次」へ。
(Extrasから追加リポジトリの選択は禁止)
・インストールするパッケージグループにて以下を選択し、「次」へ。

  • アプリケーション
    • エディタ
    • テキストベースのインターネット
  • 開発
    • 開発ツール
    • 開発ライブラリ
  • サーバー
    • DNSネームサーバー
    • FTPサーバー
    • MySQLデータベース
    • Webサーバー
    • サーバー設定ツール
    • メールサーバー
  • ベースシステム
    • システムツール
    • ベース
    • 管理ツール

(上記以外のパッケージグループは選択禁止)
・インストール実行

2. 基本設定の変更

firewall,SELinuxをdisabledに。
IPアドレスの設定。(DHCPから固定IPへ変更とかDNSの設定とか)
・再起動

3. 自サーバーのIPアドレスとホスト名を設定

・「/etc/hosts」の編集

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1               localhost.localdomain localhost
192.168.24.1            your.host.name
::1             localhost6.localdomain6 localhost6

4. ソフトウェアの追加インストール

・インストールの為のGPGキーのインポート

rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*

・既存パッケージのアップデート
※2010-05-01追記
ISPConfig3は現時点でもCentOS5.4には対応していない為、OSのバージョンを上げない為にまず「/etc/yum.conf」の設定を行う。
詳細は以下。

yum update

・必要なソフトウェアのインストール

yum groupinstall 'Development Tools'
yum groupinstall 'Development Libraries'

5. 「Quota」のインストール

・インストール

yum install quota

・「/etc/fstab」ファイルの「/」パーティションの設定に「usrquota,grpquota」を追加。

LABEL=/                 /                       ext3    defaults,usrquota,grpquota        1 1
LABEL=/var              /var                    ext3    defaults        1 2
LABEL=/boot1            /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
LABEL=SWAP-sda3         swap                    swap    defaults        0 0

・実行

touch /aquota.user /aquota.group
chmod 600 /aquota.*
mount -o remount /
quotacheck -avugm
quotaon -avug

6. 「apache, MySQL, phpMyAdmin」のインストール

・RPMForgeを利用可能にする

rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
cd /tmp
wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
rpm -ivh rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm

・必要なパッケージのインストール

yum install ntp httpd mysql-server php php-mysql php-mbstring php-mcrypt \
phpmyadmin rpm-build gcc mysql-devel openssl-devel cyrus-sasl-devel pkgconfig \
zlib-devel pcre-devel openldap-devel postgresql-devel expect libtool-ltdl-devel \
openldap-servers libtool gdbm-devel pam-devel gamin-devel

7. 「Courier-IMAP, Courier-Authlib, And Maildrop」のインストール

・インストール用ユーザーの作成

useradd -m -s /bin/bash compileuser
passwd compileuser

・compileuserに権限の追加

visudo
[...]
root    ALL=(ALL)       ALL
compileuser   ALL=(ALL)       ALL
[...]

・ユーザーの切り替え

su compileuser

・ビルド環境の作成

mkdir $HOME/rpm
mkdir $HOME/rpm/SOURCES
mkdir $HOME/rpm/SPECS
mkdir $HOME/rpm/BUILD
mkdir $HOME/rpm/SRPMS
mkdir $HOME/rpm/RPMS
mkdir $HOME/rpm/RPMS/i386
mkdir $HOME/rpm/RPMS/x86_64
echo "%_topdir $HOME/rpm" >> $HOME/.rpmmacros

・ソースファイルのダウンロード

cd /tmp
wget http://prdownloads.sourceforge.net/courier/courier-authlib-0.62.2.tar.bz2
wget http://prdownloads.sourceforge.net/courier/courier-imap-4.5.0.tar.bz2
wget http://prdownloads.sourceforge.net/courier/maildrop-2.1.0.tar.bz2

・「courier-authlib」のビルド

cd /tmp
sudo rpmbuild -ta courier-authlib-0.62.2.tar.bz2

・インストール

cd $HOME/rpm/RPMS/x86_64
sudo rpm -ivh courier-authlib-0.62.2-1.x86_64.rpm courier-authlib-mysql-0.62.2-1.x86_64.rpm courier-authlib-devel-0.62.2-1.x86_64.rpm

・「courier-imap」のビルド

cd /tmp
rpmbuild -ta courier-imap-4.5.0.tar.bz2

・インストール

cd $HOME/rpm/RPMS/x86_64
sudo rpm -ivh courier-imap-4.5.0-3.x86_64.rpm

・「maildrop」のビルド

cd /tmp
sudo rpmbuild -ta maildrop-2.1.0.tar.bz2

・インストール

cd $HOME/rpm/RPMS/x86_64
sudo rpm -ivh maildrop-2.1.0-3.x86_64.rpm

・ユーザーの切り替え

exit

8. 「Postfix」に「Quota」パッチの適用

・ソースファイルのダウンロード

cd /usr/src
wget http://mirror.centos.org/centos/5/os/SRPMS/postfix-2.3.3-2.1.el5_2.src.rpm
rpm -ivh postfix-2.3.3-2.1.el5_2.src.rpm
cd /usr/src/redhat/SOURCES
wget http://vda.sourceforge.net/VDA/postfix-2.3.3-vda.patch.gz
gunzip postfix-2.3.3-vda.patch.gz
cd /usr/src/redhat/SPECS/

・「postfix.spec」の編集(「%define MYSQL 0」を「%define MYSQL 1」に変更、「Patch0: postfix-2.3.3-vda.patch」を「# Patches」の後に追加、「%patch0 -p1 -b .vda」を「%setup -q」の後に追加)

[...]
%define MYSQL 1
[...]
# Patches

Patch0: postfix-2.3.3-vda.patch
Patch1: postfix-2.1.1-config.patch
Patch3: postfix-alternatives.patch
Patch6: postfix-2.1.1-obsolete.patch
Patch7: postfix-2.1.5-aliases.patch
Patch8: postfix-large-fs.patch
Patch9: postfix-2.2.5-cyrus.patch
Patch10: postfix-CVE-2008-2936.patch
[...]
%setup -q
# Apply obligatory patches
%patch0 -p1 -b .vda
%patch1 -p1 -b .config
%patch3 -p1 -b .alternatives
%patch6 -p1 -b .obsolete
%patch7 -p1 -b .aliases
%patch8 -p1 -b .large-fs
%patch9 -p1 -b .cyrus
%patch10 -p1 -b .CVE-2008-2936
[...]

・「Quota」と「MySQL」をサポートした「Postfix」のビルド

rpmbuild -ba postfix.spec

・インストール

cd /usr/src/redhat/RPMS/x86_64
rpm -ivh postfix-2.3.3-2.1.x86_64.rpm

・「Sendmail」を切り、「Postfix, saslauthd, courier-authlib」の起動

chkconfig --levels 235 courier-authlib on
/etc/init.d/courier-authlib start
chkconfig --levels 235 sendmail off
chkconfig --levels 235 postfix on
chkconfig --levels 235 saslauthd on
/etc/init.d/sendmail stop
/etc/init.d/postfix start
/etc/init.d/saslauthd start

9. 「Courier」の設定

・「courier-imap」の起動リンクの作成

chkconfig --levels 235 courier-imap on
/etc/init.d/courier-authlib restart
/etc/init.d/courier-imap restart

・自動で作成された証明書の削除

cd /usr/lib/courier-imap/share/
rm -f imapd.pem
rm -f pop3d.pem

・「/usr/lib/courier-imap/etc/imapd.cnf」のコモンネームの変更

[...]
CN=your.host.name
[...]

・「/usr/lib/courier-imap/etc/pop3d.cnf」のコモンネームの変更

[...]
CN=your.host.name
[...]

・証明書の再作成

./mkimapdcert
./mkpop3dcert

・「courier-authlib, courier-imap」の再起動

/etc/init.d/courier-authlib restart
/etc/init.d/courier-imap restart

10. 「Getmail」のインストール

・インストール

yum install getmail

11. 「phpMyAdmin」を構成

MySQLを起動

chkconfig --levels 235 mysqld on
/etc/init.d/mysqld start

・rootパスワードの設定

mysqladmin -u root password ********
mysqladmin -h your.host.name -u root password ********

・「/etc/httpd/conf.d/phpmyadmin.conf」を編集(のディレクティブをコメントアウト

#
#  Web application to manage MySQL
#

#<Directory "/usr/share/phpmyadmin">
#  Order Deny,Allow
#  Deny from all
#  Allow from 127.0.0.1
#</Directory>

Alias /phpmyadmin /usr/share/phpmyadmin
Alias /phpMyAdmin /usr/share/phpmyadmin
Alias /mysqladmin /usr/share/phpmyadmin

・「/usr/share/phpmyadmin/config.inc.php」の編集(認証タイプを'cookie'から'http'へ)

[...]
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'http';
[...]

・「apache」の起動リンクを作成して起動

chkconfig --levels 235 httpd on
/etc/init.d/httpd start

12. 「Amavisd-new, SpamAssassin, ClamAV」のインストール

・インストール

yum install amavisd-new spamassassin clamav clamd unzip bzip2 unrar perl-DBD-mysql

・起動

chkconfig --levels 235 amavisd on
chkconfig --levels 235 clamd on
/usr/bin/freshclam
/etc/init.d/amavisd start
/etc/init.d/clamd start

・必要なディレクトリの作成

mkdir /var/run/amavisd /var/spool/amavisd /var/spool/amavisd/tmp /var/spool/amavisd/db
chown amavis /var/run/amavisd /var/spool/amavisd /var/spool/amavisd/tmp /var/spool/amavisd/db

13. 「Apache2 With mod_php, mod_fcgi/PHP5, suPHP」のインストール

・パッケージインストール元レポジトリの追加

cd /etc/yum.repos.d/
wget http://centos.karan.org/kbsingh-CentOS-Extras.repo

・「/etc/yum.repos.d/kbsingh-CentOS-Extras.repo」の編集([kbs-CentOS-Testing]セクションの「gpgcheck」を'0'に、「enabled」を'1'に変更)

[...]
[kbs-CentOS-Testing]
name=CentOS.Karan.Org-EL$releasever - Testing
gpgcheck=0
gpgkey=http://centos.karan.org/RPM-GPG-KEY-karan.org.txt
enabled=1
baseurl=http://centos.karan.org/el$releasever/extras/testing/$basearch/RPMS/

・「Apache2with mod_php5, mod_fcgid, PHP5」のインストール

yum install php php-devel php-gd php-imap php-ldap php-mysql php-odbc php-pear php-xml php-xmlrpc \
php-eaccelerator php-mbstring php-mcrypt php-mhash php-mssql php-snmp php-soap php-tidy curl \
curl-devel perl-libwww-perl ImageMagick libxml2 libxml2-devel mod_fcgid php-cli httpd-devel

・「/etc/php.ini」の編集(「error_reporting」を'E_ALL & ~E_NOTICE'へ、「cgi.fix_pathinfo = 1」を追記)

[...]
;error_reporting  =  E_ALL
error_reporting = E_ALL & ~E_NOTICE
[...]
cgi.fix_pathinfo = 1

・「suPHP」のインストール

cd /tmp
wget http://suphp.org/download/suphp-0.7.1.tar.gz
tar xvfz suphp-0.7.1.tar.gz
cd suphp-0.7.1/
./configure --prefix=/usr --sysconfdir=/etc --with-apr=/usr/bin/apr-1-config --with-apxs=/usr/sbin/apxs \
--with-apache-user=apache --with-setid-mode=owner --with-php=/usr/bin/php-cgi --with-logfile=/var/log/httpd/suphp_log \
--enable-SUPHP_USE_USERGROUP=yes
make
make install

・「/etc/httpd/conf.d/suphp.conf」の編集(「apache」の構成モジュールに「suPHP」を追加)

LoadModule suphp_module modules/mod_suphp.so

・「/etc/suphp.conf」の編集(作成)

[global]
;Path to logfile
logfile=/var/log/httpd/suphp.log

;Loglevel
loglevel=info

;User Apache is running as
webserver_user=apache

;Path all scripts have to be in
docroot=/

;Path to chroot() to before executing script
;chroot=/mychroot

; Security options
allow_file_group_writeable=true
allow_file_others_writeable=false
allow_directory_group_writeable=true
allow_directory_others_writeable=false

;Check wheter script is within DOCUMENT_ROOT
check_vhost_docroot=true

;Send minor error messages to browser
errors_to_browser=false

;PATH environment variable
env_path=/bin:/usr/bin

;Umask to set, specify in octal notation
umask=0077

; Minimum UID
min_uid=100

; Minimum GID
min_gid=100

[handlers]
;Handler for php-scripts
x-httpd-suphp="php:/usr/bin/php-cgi"

;Handler for CGI-scripts
x-suphp-cgi="execute:!self"

・「apache」の再起動

/etc/init.d/httpd restart

14. 「PureFTPd」のインストール

・インストール

yum install pure-ftpd

・「PureFTPd」の起動リンクを作成し、起動

chkconfig --levels 235 pure-ftpd on
/etc/init.d/pure-ftpd start

15. 「MyDNS」のインストール

・インストール

cd /tmp
wget http://mydns.bboy.net/download/mydns-mysql-1.1.0-1.i386.rpm
rpm -ivh mydns-mysql-1.1.0-1.i386.rpm

・「/etc/init.d/mydns」を編集(「chkconfig: 345 52 50」 → 「# chkconfig: 345 65 50」)

[...]
# chkconfig: 345 65 50
[...]

・起動リンクを作成

chkconfig --levels 235 mydns on

16. 「Vlogger, Webalizer」のインストール

・インストール

yum install webalizer perl-DateTime-Format-HTTP perl-DateTime-Format-Builder
cd /tmp
wget http://n0rp.chemlab.org/vlogger/vlogger-1.3.tar.gz
tar xvfz vlogger-1.3.tar.gz
mv vlogger-1.3/vlogger /usr/sbin/
rm -rf vlogger*

17. 「Jailkit」のインストール

・インストール

cd /tmp
wget http://olivier.sessink.nl/jailkit/jailkit-2.5.tar.gz
tar xvfz jailkit-2.5.tar.gz
cd jailkit-2.5
./configure
make
make install
cd /tmp
rm -rf jailkit-2.5*

18. 「fail2ban」のインストール

・インストール

yum install fail2ban
chkconfig --levels 235 fail2ban on
/etc/init.d/fail2ban start

19. 「rkhunter」のインストール

・インストール

yum install rkhunter

20. 「SquirrelMail」のインストール

・インストール

yum install squirrelmail

・「apache」の再起動

/etc/init.d/httpd restart

・「SquirrelMail」を構成

/usr/share/squirrelmail/config/conf.pl

・以下の「<--」の先を入力

SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Main Menu --
1.  Organization Preferences
2.  Server Settings
3.  Folder Defaults
4.  General Options
5.  Themes
6.  Address Books
7.  Message of the Day (MOTD)
8.  Plugins
9.  Database
10. Languages

D.  Set pre-defined settings for specific IMAP servers

C   Turn color off
S   Save data
Q   Quit

Command >> <-- D


SquirrelMail Configuration : Read: config.php
---------------------------------------------------------
While we have been building SquirrelMail, we have discovered some
preferences that work better with some servers that don't work so
well with others.  If you select your IMAP server, this option will
set some pre-defined settings for that server.

Please note that you will still need to go through and make sure
everything is correct.  This does not change everything.  There are
only a few settings that this will change.

Please select your IMAP server:
    bincimap    = Binc IMAP server
    courier     = Courier IMAP server
    cyrus       = Cyrus IMAP server
    dovecot     = Dovecot Secure IMAP server
    exchange    = Microsoft Exchange IMAP server
    hmailserver = hMailServer
    macosx      = Mac OS X Mailserver
    mercury32   = Mercury/32
    uw          = University of Washington's IMAP server

    quit        = Do not change anything
Command >> <-- courier


SquirrelMail Configuration : Read: config.php
---------------------------------------------------------
While we have been building SquirrelMail, we have discovered some
preferences that work better with some servers that don't work so
well with others.  If you select your IMAP server, this option will
set some pre-defined settings for that server.

Please note that you will still need to go through and make sure
everything is correct.  This does not change everything.  There are
only a few settings that this will change.

Please select your IMAP server:
    bincimap    = Binc IMAP server
    courier     = Courier IMAP server
    cyrus       = Cyrus IMAP server
    dovecot     = Dovecot Secure IMAP server
    exchange    = Microsoft Exchange IMAP server
    hmailserver = hMailServer
    macosx      = Mac OS X Mailserver
    mercury32   = Mercury/32
    uw          = University of Washington's IMAP server

    quit        = Do not change anything
Command >> courier

              imap_server_type = courier
         default_folder_prefix = INBOX.
                  trash_folder = Trash
                   sent_folder = Sent
                  draft_folder = Drafts
            show_prefix_option = false
          default_sub_of_inbox = false
show_contain_subfolders_option = false
            optional_delimiter = .
                 delete_folder = true

Press any key to continue... <-- press a key


SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Main Menu --
1.  Organization Preferences
2.  Server Settings
3.  Folder Defaults
4.  General Options
5.  Themes
6.  Address Books
7.  Message of the Day (MOTD)
8.  Plugins
9.  Database
10. Languages

D.  Set pre-defined settings for specific IMAP servers

C   Turn color off
S   Save data
Q   Quit

Command >> <--S


SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Main Menu --
1.  Organization Preferences
2.  Server Settings
3.  Folder Defaults
4.  General Options
5.  Themes
6.  Address Books
7.  Message of the Day (MOTD)
8.  Plugins
9.  Database
10. Languages

D.  Set pre-defined settings for specific IMAP servers

C   Turn color off
S   Save data
Q   Quit

Command >> <--Q

・「/etc/squirrelmail/config_local.php」の編集(「$default_folder_prefix」の設定をコメントアウト

<?php

/**
 * Local config overrides.
 *
 * You can override the config.php settings here.
 * Don't do it unless you know what you're doing.
 * Use standard PHP syntax, see config.php for examples.
 *
 * @copyright &copy; 2002-2006 The SquirrelMail Project Team
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 * @version $Id: config_local.php,v 1.2 2006/07/11 03:33:47 wtogami Exp $
 * @package squirrelmail
 * @subpackage config
 */

//$default_folder_prefix                = '';
?>

21. 「ISPConfig3」のインストール

・インストール
※「ISPConfig-3.0.1.6」をインストールすると、ISPConfig用のポートを設定した後に「phpmyadmin, webmail」にデフォルトのままではアクセス出来なくなる。
→ 「ISPConfig-3.0.1.3」を推奨。「ISPConfig-3.0.1.6」をインストールした場合は、最後のISPConfig-3.0.1.6の為の「phpmyadmin, webmail」の設定を参照。

cd /tmp
wget http://downloads.sourceforge.net/ispconfig/ISPConfig-3.0.1.6.tar.gz?use_mirror=
tar xvfz ISPConfig-3.0.1.6.tar.gz
cd ispconfig3_install/install/

・実行

php -q install.php

・以下の「<--」の先を入力

[root@server1 install]# php -q install.php


--------------------------------------------------------------------------------
 _____ ___________   _____              __ _
|_   _/  ___| ___ \ /  __ \            / _(_)
  | | \ `--.| |_/ / | /  \/ ___  _ __ | |_ _  __ _
  | |  `--. \  __/  | |    / _ \| '_ \|  _| |/ _` |
 _| |_/\__/ / |     | \__/\ (_) | | | | | | | (_| |
 \___/\____/\_|      \____/\___/|_| |_|_| |_|\__, |
                                              __/ |
                                             |___/
--------------------------------------------------------------------------------


>> Initial configuration

Operating System: CentOS 5.3 or compatible

    Following will be a few questions for primary configuration so be careful.
    Default values are in [brackets] and can be accepted with <ENTER>.
    Tap in "quit" (without the quotes) to stop the installer.


Select language (en,de) [en]: <-- ENTER

Installation mode (standard,expert) [standard]: <-- ENTER

Full qualified hostname (FQDN) of the server, eg server1.domain.tld  [server1.example.com]: <-- ENTER

MySQL server hostname [localhost]: <-- ENTER

MySQL root username [root]: <-- ENTER

MySQL root password []: <-- yourrootsqlpassword

MySQL database to create [dbispconfig]: <-- ENTER

MySQL charset [utf8]: <-- ENTER

Generating a 2048 bit RSA private key
.....+++
...............................................+++
writing new private key to 'smtpd.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [GB]: <-- ENTER
State or Province Name (full name) [Berkshire]: <-- ENTER
Locality Name (eg, city) [Newbury]: <-- ENTER
Organization Name (eg, company) [My Company Ltd]: <-- ENTER
Organizational Unit Name (eg, section) []: <-- ENTER
Common Name (eg, your name or your server's hostname) []: <-- ENTER
Email Address []: <-- ENTER
Configuring Jailkit
Configuring SASL
Configuring PAM
Configuring Courier
Configuring Spamassassin
Configuring Amavisd
Configuring Getmail
Configuring Pureftpd
Configuring MyDNS
Configuring Apache
Configuring Firewall
Installing ISPConfig
ISPConfig Port [8080]: <-- ENTER

Configuring DBServer
Installing Crontab
no crontab for root
no crontab for getmail
Restarting services ...
Stopping MySQL:                                            [  OK  ]
Starting MySQL:                                            [  OK  ]
Shutting down postfix:                                     [  OK  ]
Starting postfix:                                          [  OK  ]
Stopping saslauthd:                                        [  OK  ]
Starting saslauthd:                                        [  OK  ]
Shutting down Mail Virus Scanner (amavisd):                [  OK  ]
Starting Mail Virus Scanner (amavisd):                     [  OK  ]
Stopping Clam AntiVirus Daemon:                            [  OK  ]
Starting Clam AntiVirus Daemon:                            [  OK  ]
Stopping Courier authentication services: authdaemond
Starting Courier authentication services: authdaemond
Stopping Courier-IMAP server: imap imap-ssl pop3 pop3-ssl
Starting Courier-IMAP server: imap imap-ssl pop3 pop3-ssl
Stopping httpd:                                            [  OK  ]
[Mon May 25 15:58:22 2009] [warn] NameVirtualHost *:80 has no VirtualHosts
Starting httpd:                                            [  OK  ]
Stopping pure-ftpd:                                        [  OK  ]
Starting pure-ftpd:                                        [  OK  ]
Installation completed.
[root@server1 install]#

22. ISPConfig-3.0.1.6の為の「phpmyadmin, webmail」の設定

・「/var/www/ispconfig/sites/database_phpmyadmin.php」を変更(リダイレクト先の「'/phpmyadmin'」を「':8080/phpmyadmin'」へ)

header('location:' . $http . '://' . $serverData['server_name'] . ':8080/phpmyadmin');

・「/var/www/ispconfig/mail/webmailer.php」を変更(リダイレクト先の「'/webmail'」を「':8080/webmail'」へ)

header('location:' . $http . '://' . $serverData['server_name'] . ':8080/webmail');

※2010-05-01追記
メールの受信が出来ない場合はamavisdが正常に動作してない可能性あり。
以下参照。

以上で完了!
長いわ。