Category Archive wheezy

SpamAssassinの導入(Debian wheezy)

SpamAssassinのインストール

# apt-get install spamassassin

設定ファイルを編集

# vi /etc/default/spamassassin

スパムフィルタを有効にするため、下記を変更して保存

ENABLED=1

SpamAssassin?を起動する

# /etc/init.d/spamassassin start

samba4の導入(Debian wheezy)

samba4でActiveDirectoryドメインコントローラを構築する。

必須ライブラリのインストール

# apt-get install python-dev
# apt-get install libacl1-dev libblkid-dev
# apt-get install libgnutls-dev   ← libgnutls28-dev?
# apt-get install build-essential libacl1-dev libattr1-dev libblkid-dev \
libgnutls-dev libreadline-dev  python-dev python-dnspython gdb pkg-config \
libpopt-dev libldap2-dev dnsutils libbsd-dev attr krb5-user  docbook-xsl

ダウンロードと解凍

# cd /usr/local/src
# wget http://www.samba.org/samba/ftp/stable/samba-4.1.7.tar.gz
# tar -zxvf samba-4.1.7.tar.gz

コンパイル、インストール

# cd /usr/local/src/samba-4.1.7
# ./configure enable-debug enable-selftest
# make
# make install

設定

# /usr/local/samba/bin/samba-tool domain provision
Realm [test.local]: ActiveDirectoryドメイン名 例:MYDOMAIN.LOCAL
Domain [S4]: ドメイン略称? 例:MYDOMAIN
Server Role (dc, member, standalone) [dc]: dc
DNS backend (SAMBA_INTERNAL, BIND9_FLATFILE, BIND9_DLZ, NONE) [SAMBA_INTERNAL]: SAMBA_INTERNAL
DNS forwarder IP address (write ‘none’ to disable forwarding) [192.168.2.1]: 192.168.x.x
Administrator password: パスワードを入力
Retype password: パスワードを再入力

resolv.confの設定~

名前解決に自身のDNSを使用するように変更します。

domain Sheepdog.Kennel
search Sheepdog.Kennel 192.168.1.1
nameserver 192.168.1.20 ← 自身のIPアドレス
nameserver 192.168.1.1  ← ルーター(外部のDNS)のIPアドレス

ネットワークeth0の設定

auto lo
iface lo inet loopback
iface eth0 inet static
address 192.168.1.20
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

samba4の起動

# /usr/local/samba/sbin/samba

sambaのバージョン確認

# /usr/local/samba/bin/smbclient --version
Version 4.1.7

ドメインコントローラとして動作しているか確認

# /usr/local/samba/bin/smbclient -L localhost -U%
Domain=[MYDOMAIN] OS=[Unix] Server=[Samba 4.1.7]

	Sharename       Type      Comment
	---------       ----      -------
	netlogon        Disk      
	sysvol          Disk      
	IPC$            IPC       IPC Service (Samba 4.1.7)
Domain=[MYDOMAIN] OS=[Unix] Server=[Samba 4.1.7]

	Server               Comment
	---------            -------

	Workgroup            Master
	---------            -------

認証の確認

# /usr/local/samba/bin/smbclient //localhost/netlogon -UAdministrator%'パスワードを入力' -c 'ls'
Domain=[MYDOMAIN] OS=[Unix] Server=[Samba 4.1.7]
  .                                   D        0  Fri May 30 00:54:27 2014
  ..                                  D        0  Fri May 30 00:54:40 2014

		xxxxx blocks of size xxxxxxx. xxxxx blocks available

起動スクリプトの取得

Debian用に配布されている、InitScript?を下記URLを参考にダウンロードする。
https://wiki.samba.org/index.php/Samba4/InitScript

# wget "http://anonscm.debian.org/gitweb/?p=pkg-samba/samba.git;a=blob_plain;f=debian/samba.samba-ad-dc.init;h=3132d2e367675f822342a5b7bc2e50c046aa3b8f;hb=HEAD" -O /etc/init.d/samba-ad-dc

パスを修正

# sed -i 's|/usr/sbin|/usr/local/samba/sbin|g' /etc/init.d/samba-ad-dc

スタートアップ時に起動するように設定する

# chmod 755 /etc/init.d/samba-ad-dc
# update-rc.d samba-ad-dc defaults

Postfixの導入(Debian wheezy)

# apt-get install postfix
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
  procmail postfix-mysql postfix-pgsql postfix-ldap postfix-pcre sasl2-bin dovecot-common resolvconf postfix-cdb
  ufw postfix-doc
The following NEW packages will be installed:
  postfix
0 upgraded, 1 newly installed, 0 to remove and 4 not upgraded.
Need to get 1591 kB of archives.
After this operation, 3549 kB of additional disk space will be used.
Get:1 http://http.debian.net/debian/ wheezy/main postfix amd64 2.9.6-2 [1591 kB]
Fetched 1591 kB in 3s (435 kB/s)
Preconfiguring packages ...

...

Postfix is now set up with a default configuration.  If you need to make
changes, edit
/etc/postfix/main.cf (and others) as needed.  To view Postfix configuration
values, see postconf(1).

After modifying main.cf, be sure to run '/etc/init.d/postfix reload'.

Running newaliases
[ ok ] Stopping Postfix Mail Transport Agent: postfix.
[ ok ] Starting Postfix Mail Transport Agent: postfix.

Dovecot(pop3,imap)の導入

インストール

# apt-get install dovecot-common dovecot-pop3d dovecot-imapd
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  dovecot-core dovecot-gssapi dovecot-ldap dovecot-mysql dovecot-pgsql dovecot-sieve dovecot-sqlite
Suggested packages:
  dovecot-managesieved ntp dovecot-lmtpd dovecot-solr
The following NEW packages will be installed:
  dovecot-common dovecot-core dovecot-gssapi dovecot-imapd dovecot-ldap dovecot-mysql dovecot-pgsql dovecot-pop3d
  dovecot-sieve dovecot-sqlite
0 upgraded, 10 newly installed, 0 to remove and 4 not upgraded.
Need to get 6000 kB of archives.
After this operation, 9663 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://http.debian.net/debian/ wheezy/main dovecot-core amd64 1:2.1.7-7 [2866 kB]
Get:2 http://http.debian.net/debian/ wheezy/main dovecot-gssapi amd64 1:2.1.7-7 [340 kB]
Get:3 http://http.debian.net/debian/ wheezy/main dovecot-imapd amd64 1:2.1.7-7 [425 kB]
Get:4 http://http.debian.net/debian/ wheezy/main dovecot-ldap amd64 1:2.1.7-7 [355 kB]
Get:5 http://http.debian.net/debian/ wheezy/main dovecot-mysql amd64 1:2.1.7-7 [342 kB]
Get:6 http://http.debian.net/debian/ wheezy/main dovecot-pgsql amd64 1:2.1.7-7 [345 kB]
Get:7 http://http.debian.net/debian/ wheezy/main dovecot-pop3d amd64 1:2.1.7-7 [364 kB]
Get:8 http://http.debian.net/debian/ wheezy/main dovecot-sieve amd64 1:2.1.7-7 [598 kB]
Get:9 http://http.debian.net/debian/ wheezy/main dovecot-sqlite amd64 1:2.1.7-7 [340 kB]
Get:10 http://http.debian.net/debian/ wheezy/main dovecot-common all 1:2.1.7-7 [25.0 kB]
Fetched 6000 kB in 8s (672 kB/s)
Selecting previously unselected package dovecot-core.
(Reading database ... 23545 files and directories currently installed.)
Unpacking dovecot-core (from .../dovecot-core_1%3a2.1.7-7_amd64.deb) ...
Selecting previously unselected package dovecot-gssapi.
Unpacking dovecot-gssapi (from .../dovecot-gssapi_1%3a2.1.7-7_amd64.deb) ...
Selecting previously unselected package dovecot-imapd.
Unpacking dovecot-imapd (from .../dovecot-imapd_1%3a2.1.7-7_amd64.deb) ...
Selecting previously unselected package dovecot-ldap.
Unpacking dovecot-ldap (from .../dovecot-ldap_1%3a2.1.7-7_amd64.deb) ...
Selecting previously unselected package dovecot-mysql.
Unpacking dovecot-mysql (from .../dovecot-mysql_1%3a2.1.7-7_amd64.deb) ...
Selecting previously unselected package dovecot-pgsql.
Unpacking dovecot-pgsql (from .../dovecot-pgsql_1%3a2.1.7-7_amd64.deb) ...
Selecting previously unselected package dovecot-pop3d.
Unpacking dovecot-pop3d (from .../dovecot-pop3d_1%3a2.1.7-7_amd64.deb) ...
Selecting previously unselected package dovecot-sieve.
Unpacking dovecot-sieve (from .../dovecot-sieve_1%3a2.1.7-7_amd64.deb) ...
Selecting previously unselected package dovecot-sqlite.
Unpacking dovecot-sqlite (from .../dovecot-sqlite_1%3a2.1.7-7_amd64.deb) ...
Selecting previously unselected package dovecot-common.
Unpacking dovecot-common (from .../dovecot-common_1%3a2.1.7-7_all.deb) ...
Processing triggers for man-db ...
Setting up dovecot-core (1:2.1.7-7) ...

Creating config file /etc/dovecot/dovecot.conf with new version

Creating config file /etc/dovecot/dovecot-db.conf.ext with new version

Creating config file /etc/dovecot/dovecot-dict-sql.conf.ext with new version

Creating config file /etc/dovecot/dovecot-sql.conf.ext with new version

Creating config file /etc/dovecot/conf.d/10-auth.conf with new version

Creating config file /etc/dovecot/conf.d/10-director.conf with new version

Creating config file /etc/dovecot/conf.d/10-logging.conf with new version

Creating config file /etc/dovecot/conf.d/10-mail.conf with new version

Creating config file /etc/dovecot/conf.d/10-master.conf with new version

Creating config file /etc/dovecot/conf.d/10-ssl.conf with new version

Creating config file /etc/dovecot/conf.d/10-tcpwrapper.conf with new version

Creating config file /etc/dovecot/conf.d/15-lda.conf with new version

Creating config file /etc/dovecot/conf.d/15-mailboxes.conf with new version

Creating config file /etc/dovecot/conf.d/90-acl.conf with new version

Creating config file /etc/dovecot/conf.d/90-plugin.conf with new version

Creating config file /etc/dovecot/conf.d/90-quota.conf with new version

Creating config file /etc/dovecot/conf.d/auth-checkpassword.conf.ext with new version

Creating config file /etc/dovecot/conf.d/auth-deny.conf.ext with new version

Creating config file /etc/dovecot/conf.d/auth-master.conf.ext with new version

Creating config file /etc/dovecot/conf.d/auth-passwdfile.conf.ext with new version

Creating config file /etc/dovecot/conf.d/auth-sql.conf.ext with new version

Creating config file /etc/dovecot/conf.d/auth-static.conf.ext with new version

Creating config file /etc/dovecot/conf.d/auth-system.conf.ext with new version

Creating config file /etc/dovecot/conf.d/auth-vpopmail.conf.ext with new version
Creating generic self-signed certificate: /etc/dovecot/dovecot.pem
This certificate will expire in 10 years.
(replace with hand-crafted or authorized one if needed).
[ ok ] Starting IMAP/POP3 mail server: dovecot.
Setting up dovecot-gssapi (1:2.1.7-7) ...
Setting up dovecot-imapd (1:2.1.7-7) ...

Creating config file /etc/dovecot/conf.d/20-imap.conf with new version
[ ok ] Restarting IMAP/POP3 mail server: dovecot.
Setting up dovecot-ldap (1:2.1.7-7) ...

Creating config file /etc/dovecot/dovecot-ldap.conf.ext with new version

Creating config file /etc/dovecot/conf.d/auth-ldap.conf.ext with new version
[ ok ] Restarting IMAP/POP3 mail server: dovecot.
Setting up dovecot-mysql (1:2.1.7-7) ...
Setting up dovecot-pgsql (1:2.1.7-7) ...
Setting up dovecot-pop3d (1:2.1.7-7) ...

Creating config file /etc/dovecot/conf.d/20-pop3.conf with new version
[ ok ] Restarting IMAP/POP3 mail server: dovecot.
Setting up dovecot-sieve (1:2.1.7-7) ...

Creating config file /etc/dovecot/conf.d/90-sieve.conf with new version
[ ok ] Restarting IMAP/POP3 mail server: dovecot.
Setting up dovecot-sqlite (1:2.1.7-7) ...
Setting up dovecot-common (1:2.1.7-7) ...

dovecot.confの編集

# vi /etc/dovecot/dovecot.conf

MySQL5.5の導入(Debian wheezy)

MySQLのインストール

# apt-get install mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  heirloom-mailx libaio1 libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18 libnet-daemon-perl
  libplrpc-perl mysql-client-5.5 mysql-common mysql-server-5.5 mysql-server-core-5.5
Suggested packages:
  exim4 mail-transport-agent libipc-sharedcache-perl libterm-readkey-perl tinyca
Recommended packages:
  mailx
The following NEW packages will be installed:
  heirloom-mailx libaio1 libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18 libnet-daemon-perl
  libplrpc-perl mysql-client-5.5 mysql-common mysql-server mysql-server-5.5 mysql-server-core-5.5
0 upgraded, 13 newly installed, 0 to remove and 4 not upgraded.
Need to get 9924 kB of archives.
After this operation, 97.8 MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://http.debian.net/debian/ wheezy/main libaio1 amd64 0.3.109-3 [9150 B]
Get:2 http://http.debian.net/debian/ wheezy/main mysql-common all 5.5.31+dfsg-0+wheezy1 [85.3 kB]
Get:3 http://http.debian.net/debian/ wheezy/main libmysqlclient18 amd64 5.5.31+dfsg-0+wheezy1 [687 kB]
Get:4 http://http.debian.net/debian/ wheezy/main libnet-daemon-perl all 0.48-1 [46.2 kB]
Get:5 http://http.debian.net/debian/ wheezy/main libplrpc-perl all 0.2020-2 [36.0 kB]
Get:6 http://http.debian.net/debian/ wheezy/main libdbi-perl amd64 1.622-1 [898 kB]
Get:7 http://http.debian.net/debian/ wheezy/main libdbd-mysql-perl amd64 4.021-1+b1 [126 kB]
Get:8 http://http.debian.net/debian/ wheezy/main mysql-client-5.5 amd64 5.5.31+dfsg-0+wheezy1 [1923 kB]
Get:9 http://http.debian.net/debian/ wheezy/main mysql-server-core-5.5 amd64 5.5.31+dfsg-0+wheezy1 [3784 kB]
Get:10 http://http.debian.net/debian/ wheezy/main mysql-server-5.5 amd64 5.5.31+dfsg-0+wheezy1 [1900 kB]
Get:11 http://http.debian.net/debian/ wheezy/main heirloom-mailx amd64 12.5-2 [274 kB]
Get:12 http://http.debian.net/debian/ wheezy/main libhtml-template-perl all 2.91-1 [72.0 kB]
Get:13 http://http.debian.net/debian/ wheezy/main mysql-server all 5.5.31+dfsg-0+wheezy1 [83.6 kB]
Fetched 9924 kB in 22s (441 kB/s)
Preconfiguring packages ...

rootのパスワードを入力します。

wheezy-mysql55-01

rootパスワード(確認)

wheezy-mysql55-02

Selecting previously unselected package libaio1:amd64.
(Reading database ... 22862 files and directories currently installed.)
Unpacking libaio1:amd64 (from .../libaio1_0.3.109-3_amd64.deb) ...
Selecting previously unselected package mysql-common.
Unpacking mysql-common (from .../mysql-common_5.5.31+dfsg-0+wheezy1_all.deb) ...
Selecting previously unselected package libmysqlclient18:amd64.
Unpacking libmysqlclient18:amd64 (from .../libmysqlclient18_5.5.31+dfsg-0+wheezy1_amd64.deb) ...
Selecting previously unselected package libnet-daemon-perl.
Unpacking libnet-daemon-perl (from .../libnet-daemon-perl_0.48-1_all.deb) ...
Selecting previously unselected package libplrpc-perl.
Unpacking libplrpc-perl (from .../libplrpc-perl_0.2020-2_all.deb) ...
Selecting previously unselected package libdbi-perl.
Unpacking libdbi-perl (from .../libdbi-perl_1.622-1_amd64.deb) ...
Selecting previously unselected package libdbd-mysql-perl.
Unpacking libdbd-mysql-perl (from .../libdbd-mysql-perl_4.021-1+b1_amd64.deb) ...
Selecting previously unselected package mysql-client-5.5.
Unpacking mysql-client-5.5 (from .../mysql-client-5.5_5.5.31+dfsg-0+wheezy1_amd64.deb) ...
Selecting previously unselected package mysql-server-core-5.5.
Unpacking mysql-server-core-5.5 (from .../mysql-server-core-5.5_5.5.31+dfsg-0+wheezy1_amd64.deb) ...
Processing triggers for man-db ...
Setting up mysql-common (5.5.31+dfsg-0+wheezy1) ...
Selecting previously unselected package mysql-server-5.5.
(Reading database ... 23243 files and directories currently installed.)
Unpacking mysql-server-5.5 (from .../mysql-server-5.5_5.5.31+dfsg-0+wheezy1_amd64.deb) ...
Selecting previously unselected package heirloom-mailx.
Unpacking heirloom-mailx (from .../heirloom-mailx_12.5-2_amd64.deb) ...
Selecting previously unselected package libhtml-template-perl.
Unpacking libhtml-template-perl (from .../libhtml-template-perl_2.91-1_all.deb) ...
Selecting previously unselected package mysql-server.
Unpacking mysql-server (from .../mysql-server_5.5.31+dfsg-0+wheezy1_all.deb) ...
Processing triggers for man-db ...
Setting up libaio1:amd64 (0.3.109-3) ...
Setting up libmysqlclient18:amd64 (5.5.31+dfsg-0+wheezy1) ...
Setting up libnet-daemon-perl (0.48-1) ...
Setting up libplrpc-perl (0.2020-2) ...
Setting up libdbi-perl (1.622-1) ...
Setting up libdbd-mysql-perl (4.021-1+b1) ...
Setting up mysql-client-5.5 (5.5.31+dfsg-0+wheezy1) ...
Setting up mysql-server-core-5.5 (5.5.31+dfsg-0+wheezy1) ...
Setting up mysql-server-5.5 (5.5.31+dfsg-0+wheezy1) ...
[ ok ] Stopping MySQL database server: mysqld.
130921 11:13:23 [Note] Plugin 'FEDERATED' is disabled.
130921 11:13:23 InnoDB: The InnoDB memory heap is disabled
130921 11:13:23 InnoDB: Mutexes and rw_locks use GCC atomic builtins
130921 11:13:23 InnoDB: Compressed tables use zlib 1.2.7
130921 11:13:23 InnoDB: Using Linux native AIO
130921 11:13:23 InnoDB: Initializing buffer pool, size = 128.0M
130921 11:13:23 InnoDB: Completed initialization of buffer pool
130921 11:13:23 InnoDB: highest supported file format is Barracuda.
130921 11:13:23  InnoDB: Waiting for the background threads to start
130921 11:13:24 InnoDB: 5.5.31 started; log sequence number 1595675
130921 11:13:24  InnoDB: Starting shutdown...
130921 11:13:25  InnoDB: Shutdown completed; log sequence number 1595675
[ ok ] Starting MySQL database server: mysqld ..
[info] Checking for tables which need an upgrade, are corrupt or were
not closed cleanly..
Setting up heirloom-mailx (12.5-2) ...
update-alternatives: using /usr/bin/heirloom-mailx to provide /usr/bin/mailx (mailx) in auto mode
Setting up libhtml-template-perl (2.91-1) ...
Setting up mysql-server (5.5.31+dfsg-0+wheezy1) ...

MySQLの使用

# mysql -u root -p
Enter password:(パスワードを入力)
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 44
Server version: 5.5.31-0+wheezy1 (Debian)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

PostgreSQLの導入(Debian wheezy)

# apt-get install postgresql
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  libldap-2.4-2 libpq5 libsasl2-2 libsasl2-modules lsb-release openssl postgresql-9.1 postgresql-client-9.1
  postgresql-client-common postgresql-common ssl-cert
Suggested packages:
  libsasl2-modules-otp libsasl2-modules-ldap libsasl2-modules-sql libsasl2-modules-gssapi-mit
  libsasl2-modules-gssapi-heimdal lsb ca-certificates oidentd ident-server locales-all postgresql-doc-9.1
  openssl-blacklist
The following NEW packages will be installed:
  libldap-2.4-2 libpq5 libsasl2-2 libsasl2-modules lsb-release openssl postgresql postgresql-9.1
  postgresql-client-9.1 postgresql-client-common postgresql-common ssl-cert
0 upgraded, 12 newly installed, 0 to remove and 4 not upgraded.
Need to get 6999 kB of archives.
After this operation, 26.1 MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://http.debian.net/debian/ wheezy/main libsasl2-2 amd64 2.1.25.dfsg1-6+deb7u1 [120 kB]
Get:2 http://http.debian.net/debian/ wheezy/main libldap-2.4-2 amd64 2.4.31-1+nmu2 [243 kB]
Get:3 http://http.debian.net/debian/ wheezy/main libpq5 amd64 9.1.9-1 [527 kB]
Get:4 http://http.debian.net/debian/ wheezy/main libsasl2-modules amd64 2.1.25.dfsg1-6+deb7u1 [116 kB]
Get:5 http://http.debian.net/debian/ wheezy/main lsb-release all 4.1+Debian8+deb7u1 [27.2 kB]
Get:6 http://http.debian.net/debian/ wheezy/main openssl amd64 1.0.1e-2 [699 kB]
Get:7 http://http.debian.net/debian/ wheezy/main postgresql-client-common all 134wheezy3 [62.8 kB]
Get:8 http://http.debian.net/debian/ wheezy/main postgresql-client-9.1 amd64 9.1.9-1 [1385 kB]
Get:9 http://http.debian.net/debian/ wheezy/main ssl-cert all 1.0.32 [19.5 kB]
Get:10 http://http.debian.net/debian/ wheezy/main postgresql-common all 134wheezy3 [138 kB]
Get:11 http://http.debian.net/debian/ wheezy/main postgresql-9.1 amd64 9.1.9-1 [3620 kB]
Get:12 http://http.debian.net/debian/ wheezy/main postgresql all 9.1+134wheezy3 [42.4 kB]
Fetched 6999 kB in 12s (561 kB/s)
Preconfiguring packages ...
Selecting previously unselected package libsasl2-2:amd64.
(Reading database ... 21443 files and directories currently installed.)
Unpacking libsasl2-2:amd64 (from .../libsasl2-2_2.1.25.dfsg1-6+deb7u1_amd64.deb) ...
Selecting previously unselected package libldap-2.4-2:amd64.
Unpacking libldap-2.4-2:amd64 (from .../libldap-2.4-2_2.4.31-1+nmu2_amd64.deb) ...
Selecting previously unselected package libpq5.
Unpacking libpq5 (from .../libpq5_9.1.9-1_amd64.deb) ...
Selecting previously unselected package libsasl2-modules:amd64.
Unpacking libsasl2-modules:amd64 (from .../libsasl2-modules_2.1.25.dfsg1-6+deb7u1_amd64.deb) ...
Selecting previously unselected package lsb-release.
Unpacking lsb-release (from .../lsb-release_4.1+Debian8+deb7u1_all.deb) ...
Selecting previously unselected package openssl.
Unpacking openssl (from .../openssl_1.0.1e-2_amd64.deb) ...
Selecting previously unselected package postgresql-client-common.
Unpacking postgresql-client-common (from .../postgresql-client-common_134wheezy3_all.deb) ...
Selecting previously unselected package postgresql-client-9.1.
Unpacking postgresql-client-9.1 (from .../postgresql-client-9.1_9.1.9-1_amd64.deb) ...
Selecting previously unselected package ssl-cert.
Unpacking ssl-cert (from .../ssl-cert_1.0.32_all.deb) ...
Selecting previously unselected package postgresql-common.
Unpacking postgresql-common (from .../postgresql-common_134wheezy3_all.deb) ...
Adding 'diversion of /usr/bin/pg_config to /usr/bin/pg_config.libpq-dev by postgresql-common'
Selecting previously unselected package postgresql-9.1.
Unpacking postgresql-9.1 (from .../postgresql-9.1_9.1.9-1_amd64.deb) ...
Selecting previously unselected package postgresql.
Unpacking postgresql (from .../postgresql_9.1+134wheezy3_all.deb) ...
Processing triggers for man-db ...
Setting up libsasl2-2:amd64 (2.1.25.dfsg1-6+deb7u1) ...
Setting up libldap-2.4-2:amd64 (2.4.31-1+nmu2) ...
Setting up libpq5 (9.1.9-1) ...
Setting up libsasl2-modules:amd64 (2.1.25.dfsg1-6+deb7u1) ...
Setting up lsb-release (4.1+Debian8+deb7u1) ...
Setting up openssl (1.0.1e-2) ...
Setting up postgresql-client-common (134wheezy3) ...
Setting up postgresql-client-9.1 (9.1.9-1) ...
update-alternatives: using /usr/share/postgresql/9.1/man/man1/psql.1.gz to provide /usr/share/man/man1/psql.1.gz (psql.1.gz) in auto mode
Setting up ssl-cert (1.0.32) ...
Setting up postgresql-common (134wheezy3) ...
supported_versions: WARNING: Unknown Debian release: 7.1
Adding user postgres to group ssl-cert
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
Setting up postgresql-9.1 (9.1.9-1) ...
Creating new cluster (configuration: /etc/postgresql/9.1/main, data: /var/lib/postgresql/9.1/main)...
Moving configuration file /var/lib/postgresql/9.1/main/postgresql.conf to /etc/postgresql/9.1/main...
Moving configuration file /var/lib/postgresql/9.1/main/pg_hba.conf to /etc/postgresql/9.1/main...
Moving configuration file /var/lib/postgresql/9.1/main/pg_ident.conf to /etc/postgresql/9.1/main...
Configuring postgresql.conf to use port 5432...
update-alternatives: using /usr/share/postgresql/9.1/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode
[ ok ] Starting PostgreSQL 9.1 database server: main.
Setting up postgresql (9.1+134wheezy3) ...

PATHの設定

.bashrcを作成する。

# su postgres
$ cd
$ nano .bashrc

下記を記述する。

#!/bin/bash

PATH="$PATH":/usr/lib/postgresql/9.1/bin
export POSTGRES_HOME=/usr/lib/postgresql/9.1
export PGLIB=$POSTGRES_HOME/lib
export PGDATA=/var/lib/postgresql/9.1/main

.bashrcを反映させる。

$ source ~/.bashrc

インストール時に作成されたDBクラスタを移動する

インストール時に作成されたDBクラスタはエンコードがSQL_ASCIIになっている。
UTF8を使用したいので、ディレクトリ名を変更する。

postgresqlを停止する。

$ exit ←postgresユーザからログアウトしてrootに戻る
# /etc/init.d/postgresql stop

mainディレクトリの名前を変更する

$ su postgres
$ cd /var/lib/postgresql/9.1
$ mv main main-org

空のディレクトリを作成する。

$ mkdir main
$ chmod 700 main

データベースの初期化

$ initdb --encoding=UTF8 --locale=ja_JP.UTF-8
initdb: invalid locale name "ja_JP.UTF-8"
initdb: invalid locale name "ja_JP.UTF-8"
initdb: invalid locale name "ja_JP.UTF-8"
initdb: invalid locale name "ja_JP.UTF-8"
initdb: invalid locale name "ja_JP.UTF-8"
initdb: invalid locale name "ja_JP.UTF-8"
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale C.
The default text search configuration will be set to "english".

fixing permissions on existing directory /var/lib/postgresql/9.1/main ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 24MB
creating configuration files ... ok
creating template1 database in /var/lib/postgresql/9.1/main/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating collations ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
loading PL/pgSQL server-side language ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the -A option the
next time you run initdb.

Success. You can now start the database server using:

    postgres -D /var/lib/postgresql/9.1/main
or
    pg_ctl -D /var/lib/postgresql/9.1/main -l logfile start

postgresユーザからログアウトしてrootに戻る。

$ exit

PostgreSQL(Server)の起動

# /etc/init.d/postgresql start
[....] Starting PostgreSQL 9.1 database server: main[....] The PostgreSQL server failed to start. Please check the log output: 2013-09-21 08:38:45 UTC FATAL: could not load server certificate file "server.crt": No such file or dir[FAILy ... failed!

ここで、上記エラーが出る。
インストール時に作成された、server.keyとserver.crtをmainディレクトリに移動する。

# su postgres
$ cd /var/lib/postgresql/9.1/main-org
$ mv server.* ../main/
$ exit

再度、起動する。

# /etc/init.d/postgresql start
[ ok ] Starting PostgreSQL 9.1 database server: main.

Apache+PHP導入(Debian wheezy)

Apacheのインストール

# apt-get install apache2
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common libapr1 libaprutil1 libaprutil1-dbd-sqlite3
  libaprutil1-ldap
Suggested packages:
  www-browser apache2-doc apache2-suexec apache2-suexec-custom
The following NEW packages will be installed:
  apache2 apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common libapr1 libaprutil1
  libaprutil1-dbd-sqlite3 libaprutil1-ldap
0 upgraded, 9 newly installed, 0 to remove and 4 not upgraded.
Need to get 1461 kB of archives.
After this operation, 5599 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://http.debian.net/debian/ wheezy/main libapr1 amd64 1.4.6-3 [99.6 kB]
Get:2 http://http.debian.net/debian/ wheezy/main libaprutil1 amd64 1.4.1-3 [89.8 kB]
Get:3 http://http.debian.net/debian/ wheezy/main libaprutil1-dbd-sqlite3 amd64 1.4.1-3 [19.0 kB]
Get:4 http://http.debian.net/debian/ wheezy/main libaprutil1-ldap amd64 1.4.1-3 [16.6 kB]
Get:5 http://http.debian.net/debian/ wheezy/main apache2.2-bin amd64 2.2.22-13 [779 kB]
Get:6 http://http.debian.net/debian/ wheezy/main apache2-utils amd64 2.2.22-13 [162 kB]
Get:7 http://http.debian.net/debian/ wheezy/main apache2.2-common amd64 2.2.22-13 [291 kB]
Get:8 http://http.debian.net/debian/ wheezy/main apache2-mpm-worker amd64 2.2.22-13 [2256 B]
Get:9 http://http.debian.net/debian/ wheezy/main apache2 amd64 2.2.22-13 [1432 B]
Fetched 1461 kB in 5s (245 kB/s)
Selecting previously unselected package libapr1.
(Reading database ... 22167 files and directories currently installed.)
Unpacking libapr1 (from .../libapr1_1.4.6-3_amd64.deb) ...
Selecting previously unselected package libaprutil1.
Unpacking libaprutil1 (from .../libaprutil1_1.4.1-3_amd64.deb) ...
Selecting previously unselected package libaprutil1-dbd-sqlite3.
Unpacking libaprutil1-dbd-sqlite3 (from .../libaprutil1-dbd-sqlite3_1.4.1-3_amd64.deb) ...
Selecting previously unselected package libaprutil1-ldap.
Unpacking libaprutil1-ldap (from .../libaprutil1-ldap_1.4.1-3_amd64.deb) ...
Selecting previously unselected package apache2.2-bin.
Unpacking apache2.2-bin (from .../apache2.2-bin_2.2.22-13_amd64.deb) ...
Selecting previously unselected package apache2-utils.
Unpacking apache2-utils (from .../apache2-utils_2.2.22-13_amd64.deb) ...
Selecting previously unselected package apache2.2-common.
Unpacking apache2.2-common (from .../apache2.2-common_2.2.22-13_amd64.deb) ...
Selecting previously unselected package apache2-mpm-worker.
Unpacking apache2-mpm-worker (from .../apache2-mpm-worker_2.2.22-13_amd64.deb) ...
Selecting previously unselected package apache2.
Unpacking apache2 (from .../apache2_2.2.22-13_amd64.deb) ...
Processing triggers for man-db ...
Setting up libapr1 (1.4.6-3) ...
Setting up libaprutil1 (1.4.1-3) ...
Setting up libaprutil1-dbd-sqlite3 (1.4.1-3) ...
Setting up libaprutil1-ldap (1.4.1-3) ...
Setting up apache2.2-bin (2.2.22-13) ...
Setting up apache2-utils (2.2.22-13) ...
Setting up apache2.2-common (2.2.22-13) ...
Enabling site default.
Enabling module alias.
Enabling module autoindex.
Enabling module dir.
Enabling module env.
Enabling module mime.
Enabling module negotiation.
Enabling module setenvif.
Enabling module status.
Enabling module auth_basic.
Enabling module deflate.
Enabling module authz_default.
Enabling module authz_user.
Enabling module authz_groupfile.
Enabling module authn_file.
Enabling module authz_host.
Enabling module reqtimeout.
Setting up apache2-mpm-worker (2.2.22-13) ...
[ ok ] Starting web server: apache2.
Setting up apache2 (2.2.22-13) ...

PHP5のインストール

# apt-get install php5
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  apache2-mpm-prefork libapache2-mod-php5 libonig2 libqdbm14 php5-cli php5-common psmisc
Suggested packages:
  php-pear
The following packages will be REMOVED:
  apache2-mpm-worker
The following NEW packages will be installed:
  apache2-mpm-prefork libapache2-mod-php5 libonig2 libqdbm14 php5 php5-cli php5-common psmisc
0 upgraded, 8 newly installed, 1 to remove and 4 not upgraded.
Need to get 6246 kB of archives.
After this operation, 19.4 MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://http.debian.net/debian/ wheezy/main apache2-mpm-prefork amd64 2.2.22-13 [2360 B]
Get:2 http://security.debian.org/ wheezy/updates/main php5-common amd64 5.4.4-14+deb7u4 [587 kB]
Get:3 http://http.debian.net/debian/ wheezy/main psmisc amd64 22.19-1+deb7u1 [135 kB]
Get:4 http://http.debian.net/debian/ wheezy/main libonig2 amd64 5.9.1-1 [145 kB]
Get:5 http://security.debian.org/ wheezy/updates/main libapache2-mod-php5 amd64 5.4.4-14+deb7u4 [2665 kB]
Get:6 http://http.debian.net/debian/ wheezy/main libqdbm14 amd64 1.8.78-2 [153 kB]
Get:7 http://security.debian.org/ wheezy/updates/main php5 all 5.4.4-14+deb7u4 [1026 B]
Get:8 http://security.debian.org/ wheezy/updates/main php5-cli amd64 5.4.4-14+deb7u4 [2557 kB]
Fetched 6246 kB in 10s (616 kB/s)
dpkg: apache2-mpm-worker: dependency problems, but removing anyway as you requested:
 apache2 depends on apache2-mpm-worker (= 2.2.22-13) | apache2-mpm-prefork (= 2.2.22-13) | apache2-mpm-event (= 2.2.22-13) | apache2-mpm-itk (= 2.2.22-13); however:
  Package apache2-mpm-worker is to be removed.
  Package apache2-mpm-prefork is not installed.
  Package apache2-mpm-event is not installed.
  Package apache2-mpm-itk is not installed.

(Reading database ... 22750 files and directories currently installed.)
Removing apache2-mpm-worker ...
[ ok ] Stopping web server: apache2 ... waiting .
Selecting previously unselected package apache2-mpm-prefork.
(Reading database ... 22745 files and directories currently installed.)
Unpacking apache2-mpm-prefork (from .../apache2-mpm-prefork_2.2.22-13_amd64.deb) ...
Setting up apache2-mpm-prefork (2.2.22-13) ...
[ ok ] Starting web server: apache2.
Selecting previously unselected package psmisc.
(Reading database ... 22750 files and directories currently installed.)
Unpacking psmisc (from .../psmisc_22.19-1+deb7u1_amd64.deb) ...
Selecting previously unselected package php5-common.
Unpacking php5-common (from .../php5-common_5.4.4-14+deb7u4_amd64.deb) ...
Selecting previously unselected package libonig2.
Unpacking libonig2 (from .../libonig2_5.9.1-1_amd64.deb) ...
Selecting previously unselected package libqdbm14.
Unpacking libqdbm14 (from .../libqdbm14_1.8.78-2_amd64.deb) ...
Selecting previously unselected package libapache2-mod-php5.
Unpacking libapache2-mod-php5 (from .../libapache2-mod-php5_5.4.4-14+deb7u4_amd64.deb) ...
Selecting previously unselected package php5.
Unpacking php5 (from .../php5_5.4.4-14+deb7u4_all.deb) ...
Selecting previously unselected package php5-cli.
Unpacking php5-cli (from .../php5-cli_5.4.4-14+deb7u4_amd64.deb) ...
Processing triggers for man-db ...
Setting up psmisc (22.19-1+deb7u1) ...
Setting up php5-common (5.4.4-14+deb7u4) ...

Creating config file /etc/php5/mods-available/pdo.ini with new version
Setting up libonig2 (5.9.1-1) ...
Setting up libqdbm14 (1.8.78-2) ...
Setting up libapache2-mod-php5 (5.4.4-14+deb7u4) ...

Creating config file /etc/php5/apache2/php.ini with new version
[ ok ] Restarting web server: apache2 ... waiting .
Setting up php5 (5.4.4-14+deb7u4) ...
Setting up php5-cli (5.4.4-14+deb7u4) ...

Creating config file /etc/php5/cli/php.ini with new version
update-alternatives: using /usr/bin/php5 to provide /usr/bin/php (php) in auto mode

バーチャルホストの設定

# cd /etc/apache2/sites-enabled
# nano 000-default
<VirtualHost *:80>
        ServerAdmin webmaster@sitename.jp

        DocumentRoot /var/www/vhosts/www.sitename.jp
        ServerName www.sitename.jp
        ServerAlias localhost
        <Directory />
                Options FollowSymLinks
                AllowOverride FileInfo
        </Directory>
#       <Directory /var/www/html>
#               Options FollowSymLinks MultiViews
#               AllowOverride None
#               Order allow,deny
#               allow from all
#       </Directory>
#
#       ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
#       <Directory "/usr/lib/cgi-bin">
#               AllowOverride None
#               Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
#               Order allow,deny
#               Allow from all
#       </Directory>

#       ErrorLog ${APACHE_LOG_DIR}/error.log
        ErrorLog /var/log/apache2/www.sitename.jp-error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

#       CustomLog ${APACHE_LOG_DIR}/access.log combined
        CustomLog /var/log/apache2/www.sitename.jp-access.log combined
</VirtualHost>

バーチャルホストのディレクトリを作成する

# cd /var/www
# mkdir vhosts
# cd vhosts
# mkdir www.sitesname.jp
# cd ..
# chown -R daemon:daemon vhosts
# chmod 755 -R vhosts

Apacheの再起動

# /etc/init.d/apache2 restart