레이블이 gentoo인 게시물을 표시합니다. 모든 게시물 표시
레이블이 gentoo인 게시물을 표시합니다. 모든 게시물 표시

2011년 8월 2일 화요일

[Gentoo Linux] Postfix 메일계정 추가


sudo -u vmail mkdir /home/vmail/javaya.org/<MAIL-ACCOUNT>
sudo -u vmail maildirmake /home/vmail/javaya.org/<MAIL-ACCOUNT>/.maildir

insert into users
values
(2, '<MAIL-ACCOUNT>@javaya.org', '<MAIL-ACCOUNT>', '<MAIL-ACCOUNT>', 1004, 1005
, '/home/vmail/javaya.org/<MAIL-ACCOUNT>', '/home/vmail/javaya.org/<MAIL-ACCOUNT>/.maildir/', '', 'y')


설치문서
http://www.gentoo.org/doc/en/virt-mail-howto.xml

[Gentoo Linux] emerge 할때 특정 collision 무시하기

COLLISION_IGNORE="/usr/share/man/man1/maildirmake.1.bz2" emerge courier-imap

[Gentoo Linux] 로케일 설정


28. 로케일 설정

# nano -w /etc/env.d/02locale
LANG="ko_KR.UTF-8"
# env-update
# source /etc/profile

[Gentoo Linux] netqmail/vpopmail Virtual Mail Hosting System Guide



원문: http://www.gentoo.org/doc/en/qmail-howto.xml


1.  Introduction

2.  netqmail (talking to myself)
emerge mail-mta/netqmail
conflicts 발생하면
{
emerge netqmail -p
emerge -C mail-mta/ssmtp
}

vi /var/qmail/control/servercert.cnf
--------------------------------------------------------------------------------
[ req ]
# you can increase this value, but be aware that it will make things much slower
# this should be a power of 2!
default_bits = 1024
# leave the rest of these alone!
encrypt_key = yes
distinguished_name = req_dn
x509_extensions = cert_type
prompt = no

[ req_dn ]
# 2-Letter ISO country code
C=KR
# FULL name of state/province/district
# NO abbreviations!
ST=Seoul
# FULL name of city
# NO abbreviations!
L=Seoul
# Full Name of your organization
# NO abbreviations!
O=javaya.org
# Leave this alone unless specifically need to change it!
OU=Automatically-generated Qmail SMTP SSL key
# This should be a FQDN that resolves to the IP of your server
CN=localhost
# This should be the email address for the administrator of the server
emailAddress=postmaster@javaya.org

# Leave this alone!
[ cert_type ]
nsCertType = server
--------------------------------------------------------------------------------
emerge --config netqmail

# cd /var/qmail/alias
# echo qmailmaster > .qmail-root
# echo qmailmaster > .qmail-postmaster
# echo qmailmaster > .qmail-mailer-daemon


# rc-update add svscan default
# /etc/init.d/svscan start
# cd /service
# ln -s /var/qmail/supervise/qmail-send qmail-send


<yskim>
emerge mail-client/mutt


<yskim>
hostname --fqdn
위 명령을 실행한 결과가 javaya.org 등 적절한 결과가 나오지 않는다면 다음 과정을 실행
# vi /etc/conf.d/hostname
# /etc/init.d/hostname restart
# vi /var/qmail/control/me
# vi /var/qmail/control/defaultdomain
# vi /var/qmail/control/plusdomain
# vi /var/qmail/control/locals
# vi /var/qmail/control/rcpthosts


# ssh wmjavayaorg@localhost
# maildirmake .maildir
# qmail-inject root << EOF
test root e-mail!
EOF
# qmail-inject postmaster << EOF
test postmaster e-mail!
EOF
# qmail-inject wmjavayaorg << EOF
test wmjavayaorg@javaya.org e-mail!
EOF
# mutt
정상적으로 위의 메세지가 도착했는지 확인

3.  vpopmail
# emerge vpopmail

<yskim>
/etc/make.conf 파일의 USE에 mysql이 포함되어 있는지 확인하고 없다면 추가한뒤

emerge -C vpopmail
emerge vpopmail


# rc-update add mysql default
If you just emerged mysql for the first time, make sure you run
the ebuild <mysql.ebuild> config command and follow the
directions before starting the mysql server.

# /etc/init.d/mysql start
# nano /etc/vpopmail.conf
(Change the password from 'secret' to 'qlalfdldia')
# mysql -p << EOF
create database vpopmail;
use mysql;
grant select, insert, update, delete, create, drop on vpopmail.* to vpopmail@localhostidentified by 'qlalfdldia';
flush privileges;
EOF
(The following steps may or may not be needed, but we run them just to be sure)
# chown root:vpopmail /etc/vpopmail.conf
# chmod 640 /etc/vpopmail.conf
# chown root:vpopmail /var/vpopmail/bin/vchkpw
# chmod 4711 /var/vpopmail/bin/vchkpw


(You only have to do this if the vadddomain step below results in "command not found")
# source /etc/profile

(While debugging vpopmail, you may want to consult the logs)
# mysql -u vpopmail -p
mysql> select * from vpopmail.vlog;

# vadddomain javaya.org qlalfdldia
(Now quickly verify the domain is setup properly)
# printf "postmaster@javaya.org\0qlalfdldia\0blah\0" | vchkpw `which id` 3<&0
uid=89(vpopmail) gid=89(vpopmail) groups=0(root)
(If you don't see something similar to above, then permissions somewhere are incorrect)

# vadduser qmailmaster@javaya.org qlalfdldia

4.  Courier POP/IMAP

# emerge net-mail/courier-imap

# vi /etc/courier/authlib/authdaemonrc
(Set the authmodulelist variable to only contain "authvchkpw")
authmodulelist에 authvchkpw 만 지정
--------------------------------------------------------------------------------
#authmodulelist="authmysql "
authmodulelist="authvchkpw"
--------------------------------------------------------------------------------

# cd /etc/courier-imap
# vi pop3d.cnf
(Edit the [ req_dn ] section)
[ req_dn ]을 다음과 같이 수정
--------------------------------------------------------------------------------
[ req_dn ]
C=KR
ST=Seoul
L=Seoul
O=Courier Mail Server
OU=Automatically-generated POP3 SSL key
CN=localhost
emailAddress=postmaster@javaya.org
--------------------------------------------------------------------------------

# mkpop3dcert
# rc-update add courier-pop3d-ssl default
# /etc/init.d/courier-pop3d-ssl start


# cd /etc/courier-imap
# vi imapd.cnf
(Edit the [ req_dn ] section)
[ req_dn ]을 다음과 같이 수정
--------------------------------------------------------------------------------
[ req_dn ]
C=KR
ST=Seoul
L=Seoul
O=Courier Mail Server
OU=Automatically-generated IMAP SSL key
CN=localhost
emailAddress=postmaster@javaya.org
--------------------------------------------------------------------------------

# mkimapdcert
# rc-update add courier-imapd-ssl default
# /etc/init.d/courier-imapd-ssl start


5.  netqmail (talking to the world)

# cd /var/qmail/control/
# nano conf-smtpd
(Uncomment the SMTP-AUTH variables and set QMAIL_SMTP_CHECKPASSWORD to /var/vpopmail/bin/vchkpw)
QMAIL_SMTP_CHECKPASSWORD 부분을 다음과 같이 수정
--------------------------------------------------------------------------------
#QMAIL_SMTP_CHECKPASSWORD="/bin/cmd5checkpw"
QMAIL_SMTP_CHECKPASSWORD="/var/vpopmail/bin/vchkpw"
--------------------------------------------------------------------------------

# nano servercert.cnf
(Edit the [ req_dn ] section)
[ req_dn ]을 다음과 같이 수정
--------------------------------------------------------------------------------
# 2-Letter ISO country code
C=KR
# FULL name of state/province/district
# NO abbreviations!
ST=Seoul
# FULL name of city
# NO abbreviations!
L=Seoul
# Full Name of your organization
# NO abbreviations!
O=javaya.org
# Leave this alone unless specifically need to change it!
OU=Automatically-generated Qmail SMTP SSL key
# This should be a FQDN that resolves to the IP of your server
CN=localhost
# This should be the email address for the administrator of the server
emailAddress=postmaster@javaya.org
--------------------------------------------------------------------------------

# mkservercert
# cd /service
# ln -s /var/qmail/supervise/qmail-smtpd qmail-smtpd
# /etc/init.d/svscan restart

********************************************************************************
여기까지만 설치함
********************************************************************************

6.  Horde / IMP Webmail Client
# emerge horde-imp

<yskim>
horde.php 가 conf.php/conf.xml로 바뀐듯..


# cd /var/www/localhost/htdocs/horde/config/
# for f in *.dist ; do mv ${f} ${f/.dist} ; done
# vi horde.php
(Under 'Horde Authentication':)
$conf['auth']['driver'] = 'imap';
$conf['auth']['params']['dsn'] = '{localhost:993/imap/ssl/novalidate-cert}';

(Under 'Horde Logging':)
$conf['log']['name'] = '/var/log/apache2/horde.log';

(Under 'Problem Reporting':)
$conf['problems']['enabled'] = true;
$conf['problems']['email'] = 'webmaster@wh0rd.org';

# nano registry.php
(Under 'Handlers':)
$this->registry['auth']['login'] = 'imp';
$this->registry['auth']['logout'] = 'imp';

(Under 'Application registry':)
Set the 'status' element of applications['imp'] from 'inactive' to 'active'

# touch /var/log/apache2/horde.log
# chown apache:apache /var/log/apache2/horde.log


# cd /var/www/localhost/htdocs/horde/imp/config/
# for f in *.dist ; do mv ${f} ${f/.dist} ; done
# vi servers.php


<yskim>
# vi /etc/apache2/vhosts.d/00_default_vhost.conf
--------------------------------------------------------------------------------
<VirtualHost *:80>
    RewriteEngine on
    RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
    RewriteRule .* - [F]
    ServerAdmin webmaster@javaya.org
    DocumentRoot "/var/www/localhost/"
    ServerName horde.javaya.org
    RailsDefaultUser wmjavayaorg
    ErrorLog /var/log/apache2/horde.localhost-error_log
    CustomLog /var/log/apache2/horde.localhost-access_log common
</VirtualHost>
--------------------------------------------------------------------------------
# vi /var/named/personal/javaya.org
--------------------------------------------------------------------------------
horde           IN      CNAME   @
--------------------------------------------------------------------------------
# /etc/init.d/named restart







********************************************************************************
Horde 설치
********************************************************************************
emerge horde

cd /var/www/localhost/htdocs/horde/config/
for f in *.dist; do cp $f `basename $f .dist`; done


vi /var/www/localhost/htdocs/horde/scripts/sql/create.mysql.sql
mysql -u root < /var/www/localhost/htdocs/horde/scripts/sql/create.mysql.sql

http://horde.javaya.org/horde/admin/setup/config.php
    Setup ->
    Authentication -> What backend should we use for authenticating users to Horde?
        IMAP / DSN / {localhost:993/imap/ssl/novalidate-cert}
    Logging
        /var/log/apache2/horde.log
    Problem Reporting -> Where should problem report emails be sent?
        webmaster@javaya.org
    Problem Reporting -> If Horde cannot determine a user's ...
        javaya.org

    Generate Horde Configuration 클릭
  
--------------------------------------------------------------------------------
<?php
/* CONFIG START. DO NOT CHANGE ANYTHING IN OR AFTER THIS LINE. */
// $Horde: horde/config/conf.xml,v 1.74.2.41 2006/08/04 17:13:25 jan Exp $
$conf['debug_level'] = E_ALL;
$conf['max_exec_time'] = 0;
$conf['use_ssl'] = 2;
$conf['server']['name'] = $_SERVER['SERVER_NAME'];
$conf['server']['port'] = $_SERVER['SERVER_PORT'];
$conf['compress_pages'] = true;
$conf['umask'] = 077;
$conf['session']['name'] = 'Horde';
$conf['session']['use_only_cookies'] = true;
$conf['session']['cache_limiter'] = 'nocache';
$conf['session']['timeout'] = 0;
$conf['cookie']['domain'] = $_SERVER['SERVER_NAME'];
$conf['cookie']['path'] = '/horde';
$conf['sql']['phptype'] = false;
$conf['auth']['admins'] = array('wmjavayaorg@javaya.org');
$conf['auth']['checkip'] = true;
$conf['auth']['checkbrowser'] = true;
$conf['auth']['alternate_login'] = false;
$conf['auth']['redirect_on_logout'] = false;
$conf['auth']['params']['dsn'] = '{localhost:993/imap/ssl/novalidate-cert}';
$conf['auth']['params']['imapconfig'] = 'dsn';
$conf['auth']['driver'] = 'imap';
$conf['signup']['allow'] = false;
$conf['log']['priority'] = PEAR_LOG_NOTICE;
$conf['log']['ident'] = 'HORDE';
$conf['log']['params'] = array();
$conf['log']['name'] = '/var/log/apache2/horde.log';
$conf['log']['params']['append'] = true;
$conf['log']['type'] = 'file';
$conf['log']['enabled'] = true;
$conf['log_accesskeys'] = false;
$conf['prefs']['driver'] = 'session';
$conf['datatree']['driver'] = 'null';
$conf['group']['driver'] = 'datatree';
$conf['cache']['default_lifetime'] = 1800;
$conf['cache']['params']['dir'] = Horde::getTempDir();
$conf['cache']['params']['gc'] = 86400;
$conf['cache']['driver'] = 'file';
$conf['token']['driver'] = 'none';
$conf['mailer']['params']['sendmail_path'] = '/usr/lib/sendmail';
$conf['mailer']['params']['sendmail_args'] = '-oi';
$conf['mailer']['type'] = 'sendmail';
$conf['vfs']['params']['vfsroot'] = '/tmp';
$conf['vfs']['type'] = 'file';
$conf['sessionhandler']['type'] = 'none';
$conf['problems']['email'] = 'webmaster@javaya.org';
$conf['problems']['maildomain'] = 'javaya.org';
$conf['problems']['tickets'] = false;
$conf['menu']['apps'] = array('imp');
$conf['menu']['always'] = false;
$conf['menu']['links']['help'] = 'all';
$conf['menu']['links']['help_about'] = true;
$conf['menu']['links']['options'] = 'authenticated';
$conf['menu']['links']['problem'] = 'all';
$conf['menu']['links']['login'] = 'all';
$conf['menu']['links']['logout'] = 'authenticated';
$conf['hooks']['permsdenied'] = false;
$conf['hooks']['username'] = false;
$conf['hooks']['preauthenticate'] = false;
$conf['hooks']['postauthenticate'] = false;
$conf['hooks']['authldap'] = false;
$conf['portal']['fixed_blocks'] = array();
$conf['accounts']['driver'] = 'null';
$conf['imsp']['enabled'] = false;
$conf['kolab']['enabled'] = false;
/* CONFIG END. DO NOT CHANGE ANYTHING IN OR BEFORE THIS LINE. */
--------------------------------------------------------------------------------


********************************************************************************
Horde IMP 설치
********************************************************************************
emerge horde-imp

cd /var/www/localhost/htdocs/horde/imp/config/
for f in *.dist; do cp $f `basename $f .dist`; done

vi /var/www/localhost/htdocs/horde/imp/config/conf.php
--------------------------------------------------------------------------------
<?php
/* CONFIG START. DO NOT CHANGE ANYTHING IN OR AFTER THIS LINE. */
// $Horde: imp/config/conf.xml,v 1.53.2.16 2006/12/24 05:06:57 chuck Exp $
$conf['utils']['gnupg_keyserver'] = array('wwwkeys.pgp.net');
$conf['utils']['gnupg_timeout'] = '10';
$conf['menu']['apps'] = array('imp');
$conf['user']['select_sentmail_folder'] = false;
$conf['user']['allow_resume_all_in_drafts'] = false;
$conf['user']['allow_folders'] = true;
$conf['user']['allow_resume_all'] = false;
$conf['user']['allow_view_source'] = true;
$conf['user']['alternate_login'] = false;
$conf['user']['redirect_on_logout'] = false;
$conf['server']['change_server'] = false;
$conf['server']['change_port'] = false;
$conf['server']['change_protocol'] = false;
$conf['server']['change_smtphost'] = false;
$conf['server']['change_smtpport'] = false;
$conf['server']['server_list'] = 'none';
$conf['server']['sort_limit'] = '0';
$conf['server']['cache_folders'] = false;
$conf['server']['cache_msgbody'] = false;
$conf['mailbox']['show_attachments'] = false;
$conf['mailbox']['show_preview'] = false;
$conf['mailbox']['show_xpriority'] = false;
$conf['fetchmail']['show_account_colors'] = false;
$conf['fetchmail']['size_limit'] = '4000000';
$conf['msgsettings']['filtering']['words'] = './config/filter.txt';
$conf['msgsettings']['filtering']['replacement'] = '****';
$conf['spam']['reporting'] = false;
$conf['notspam']['reporting'] = false;
$conf['msg']['prepend_header'] = true;
$conf['msg']['append_trailer'] = true;
$conf['compose']['allow_cc'] = true;
$conf['compose']['allow_bcc'] = true;
$conf['compose']['allow_receipts'] = true;
$conf['compose']['special_characters'] = true;
$conf['compose']['use_vfs'] = false;
$conf['compose']['link_all_attachments'] = false;
$conf['compose']['link_attachments_notify'] = true;
$conf['compose']['link_attachments'] = true;
$conf['compose']['add_maildomain_to_unexpandable'] = false;
$conf['compose']['attach_size_limit'] = '0';
$conf['compose']['attach_count_limit'] = '0';
$conf['hooks']['vinfo'] = false;
$conf['hooks']['signature'] = false;
$conf['hooks']['trailer'] = false;
$conf['hooks']['fetchmail_filter'] = false;
$conf['hooks']['mbox_redirect'] = false;
$conf['hooks']['mbox_icon'] = false;
$conf['hooks']['spam_bounce'] = false;
$conf['maillog']['use_maillog'] = true;
$conf['tasklist']['use_tasklist'] = true;
$conf['notepad']['use_notepad'] = true;
/* CONFIG END. DO NOT CHANGE ANYTHING IN OR BEFORE THIS LINE. */
--------------------------------------------------------------------------------

[Gentoo Linux] mysql 설치

# emerge mysql
# emerge --config mysql
# vi /etc/mysql/my.cnf

utf8 을 원하는 캐릭터셋으로 변경 (euckr or 그대로 등등..)
innodb_data_file_path = ibdata1:10M:autoextend:max:128M 에서 :max:128M을 삭제

# mysql_install_db
# /etc/init.d/mysql start

Gentoo Linux에 chkrootkit 설치 및 crontab 등록



# emerge chkrootkit

# vi /root/check_chkrootkit.sh
--------------------------------------------------------------------------------
#!/bin/bash
chk=`/usr/sbin/chkrootkit`
if [ -n "$chk" ] ;then
       echo $chk | mail -s "Javaya SYSTEM Chkrootkit Result " <MAIL-ADDR>
       echo Finished

fi
--------------------------------------------------------------------------------

# chown 700 /root/check_chkrootkit.sh
# vi /etc/crontab
--------------------------------------------------------------------------------
00 4 * * * root /root/scripts/check_chkrootkit.sh
--------------------------------------------------------------------------------

Gentoo Linux에 CVS 설치 (with JailRoot)


1. Install
# USE="server" emerge cvs
# emerge cvsd


2. Create a CVS Jailroot

# mkdir /var/lib/cvsd
# cvs -d /var/lib/cvsd/root init
# cvsd-buildroot /var/lib/cvsd
# cd /var/lib/cvsd
# mkdir -p var/lock

# vi /etc/cvsd/cvsd.conf
--------------------------------------------------------------------------------
RootJail /var/lib/cvsd
Uid cvsd
Gid cvsd
Listen * 2401 # or whatever port you'd like it to listen on, up to you
Repos /root
--------------------------------------------------------------------------------


3. Add Users
cvsd-passwd /var/lib/cvsd/root YOUR_USER_HERE

읽기만 가능한 사용자를 만드려면 아래와 같이 진행한다.
# touch /var/lib/cvsd/root/CVSROOT/readers
# chown cvsd:cvsd /var/lib/cvsd/root/CVSROOT/readers
# vi /var/lib/cvsd/root/CVSROOT/readers
/var/lib/cvsd/root/CVSROOT/readers 파일에 내용 추가


4. 권한설정
# cd /var/lib
# chown -R cvsd:cvsd cvsd
# chmod -R 775 /var/lib/cvsd/root


5. 데몬 시작 및 자동시작 데몬으로 등록

# /etc/init.d/cvsd restart
# rc-update add cvsd default


6. Quick local test
CVSROOT=:pserver:retti@localhost:/root; export CVSROOT


* USE="server" 플래그를 사용하지 않으면 다음과 같은 에러가 발생
/var/lib/cvsd 디렉토리 삭제, unmerge 한뒤 1번 부터 다시 시작

cvs [login aborted]: unrecognized auth response from localhost: cvs: unrecognized option `--allow-root=/root'

Gentoo Linux에 Postgresql 8.3.1 설치


1. 설치 가능여부 확인
# emerge -pv =postgresql-8.3.1

!!! All ebuilds that could satisfy "=dev-db/postgresql-8.3.1" have been masked.
!!! One of the following masked packages is required to complete your request:
- dev-db/postgresql-8.3.1 (masked by: ~amd64 keyword)

위과 같은 에러가 나온다면 /etc/make.conf에 ACCEPT_KEYWORDS="~amd64" 을 추가한다.
해당 아키텍처에서 충분히 테스트 되지 않았거나 다른 문제로 아직 안정화되지 않았다는 의미다.


2. emerge
# emerge =postgresql-8.3.1

# passwd postgres

3. /etc에 심볼릭 링크 추가

아래와 같이 추가적인 설정을 한다.
# mkdir -p /var/lib/postgresql/data
# chown -R postgres:postgres /var/lib/postgresql/data
# su - postgres
# initdb -E UTF8 -D /var/lib/postgresql/data
# exit
# vi /etc/conf.d/postgresql
--------------------------------------------------------------------------------
PGDATA="/var/lib/postgresql/data"
--------------------------------------------------------------------------------

PostgreSQL 설정파일을 빨리 찾을 수 있도록 심볼릭 링크를 추가한다.
(대부분의 사람들은 /etc/postgresql 디렉토리에서 설정파일을 찾을 것이다)

# mkdir /etc/postgresql
# ln -s /var/lib/postgresql/data/pg_hba.conf /etc/postgresql/pg_hba.conf
# ln -s /var/lib/postgresql/data/postgresql.conf /etc/postgresql/postgresql.conf


4. 외부 접속 설정

리슨할 IP를 설정 (아래 두개중에 적당한 정책을 선택)
listen_addresses = '192.168.1.200'  # 192.168.1.200로 접속할 경우에만 접속허용
listen_addresses = '*'              # 서버에 할당된 모든 아이피로의 접속 허용

아래를 참고해서 적절히 설정
(인터넷을 통해 접속이 허용된다면 SSL이나 Kerberos를 사용할 것을 권장)
# vi /var/lib/postgresql/data/postgresql.conf
--------------------------------------------------------------------------------
#--------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#--------------------------------------------------------------------
# - Connection Settings -
listen_addresses = '*'         # what IP address(es) to listen on;
                                        # comma-separated list of addresses;
                                        # defaults to 'localhost', '*' = all
#port = 5432
max_connections = 100
# note: increasing max_connections costs ~400 bytes of shared memory per
# connection slot, plus lock space (see max_locks_per_transaction).  You
# might also need to raise shared_buffers to support more connections.
#superuser_reserved_connections = 2
#unix_socket_directory = ''
#unix_socket_group = ''
#unix_socket_permissions = 0777         # octal
#bonjour_name = ''                      # defaults to the computer name

# - Security & Authentication -
#authentication_timeout = 60            # 1-600, in seconds
ssl = on
#password_encryption = on
#db_user_namespace = off
--------------------------------------------------------------------------------


5. 내부 접속 설정
아래를 참고해 적절히 수정
# vi /var/lib/postgresql/data/pg_hba.conf

--------------------------------------------------------------------------------
# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
# "local" is for Unix domain socket connections only
local   all         postgres                          trust
local   all         all                               md5
# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
# IPv6 local connections:
host    all         all         ::1/128               md5

hostssl all         all         *           md5
--------------------------------------------------------------------------------


6. 로그설정
# mkdir /var/log/pglog
# chown postgres:postgres -R /var/log/pglog

아래를 참고해 적절히 설정
# vi /var/lib/postgresql/data/postgresql.conf

--------------------------------------------------------------------------------
#---------------------------------------------------------------------------
# ERROR REPORTING AND LOGGING
#---------------------------------------------------------------------------

    # - Where to Log -
#log_destination = 'stderr'
# This is used when logging to stderr:
redirect_stderr = on

# These are only used if redirect_stderr is on:
log_directory = '/var/log/pglog'

log_filename = 'pgsql-%Y-%m-%d.log'
#log_truncate_on_rotation = off
#log_rotation_age = 1440
#log_rotation_size = 10240

# These are relevant when logging to syslog:
#syslog_facility = 'LOCAL0'
#syslog_ident = 'postgres'


# - When to Log -

#client_min_messages = notice
#log_min_messages = notice
#log_error_verbosity = default
log_min_error_statement = error
#log_min_duration_statement = -1
#silent_mode = off
# - What to Log -
#debug_print_parse = off
#debug_print_rewritten = off
#debug_print_plan = off
#debug_pretty_print = off
log_connections = on
#log_disconnections = off
#log_duration = off
log_line_prefix = '<%t> '

log_statement = 'ddl'
#log_hostname = off
--------------------------------------------------------------------------------


7. Log Rotation
# emerge logrotate
# vi /etc/logrotate.d/postgresql

--------------------------------------------------------------------------------
# Compress postgresql log files
# Provided by DouweQuerty
/var/log/pglog/pglog.tar {
  missingok
  ifempty
  rotate 7
  weekly
  sharedscripts
  prerotate
    cd /var/log/pglog/
    tar -C /var/log/pglog/ -cp --remove-files --wildcards -f pglog.tar --exclude *$(date +%Y-%m-%d)* *.log
  endscript
  postrotate
  endscript
}
--------------------------------------------------------------------------------

# echo "" > /var/log/pglog/pglog.tar
아래 명령을 실행해서 loglotate가 정성적으로 설정되었는지 확인한다.
# logrotate -f /etc/logrotate.conf

8. Install a Procedural Language (postgresql가 구동중인 상태에서 실해해야 한다.)

# /etc/init.d/postgresql start
# su - postgres
# createlang plpgsql template1


9. Installing JDBC driver (생략)
# emerge -av jdbc-postgresql


10. Finish and Start
# /etc/init.d/postgresql start
부팅시 로딩되도록 한다.

# rc-update add postgresql default

11.Postgresql Login
# su - postgres
# mkdir /var/lib/postgresql/data/bbs
# psql -U postgres

* Create user
CREATE USER bbs PASSWORD '<password>'
CREATEDB
VALID UNTIL 'infinity';

* Create tablespace
CREATE TABLESPACE bbs OWNER bbs LOCATION '/var/lib/postgresql/data/bbs';

* Create database
CREATE DATABASE bbs
WITH ENCODING='UNICODE'
OWNER=bbs
TABLESPACE=bbs;


 


Gentoo Linux에 Apache2 and Tomcat6 설치

0. 설치정보
================================================================================
- 작성일: 2008-10-20
- 설치할 프로그램 목록
 Apache 2.2.9
 Tomcat 6.0.14-r1
 JDK 1.5.0.15
- 이전엔 라이센스 문제 때문에 JDK를 SUN 홈페이지에서 따로 받아서 설치해야 했었는데 정책이 바꼈는지 emerge 하면 바로 다운 받아서 설치한다.
- 2008-10-20 현재 톰켓을 emerge하면 JDK-1.5.0.15를 알아서 설치한다. 따라서 별도로 emerge 하지 않아도 된다.
- 2008-10-20 현재 톰켓을 emerge하면 mod_jk를 알아서 설치한다. 따라서 별도로 emerge 하지 않아도 된다.
================================================================================


1. apache2 설치
# vi /etc/make.conf
--------------------------------------------------------------------------------
USE="apache2"
--------------------------------------------------------------------------------

# emerge www-servers/apache
vi /etc/conf.d/apache2
--------------------------------------------------------------------------------
APACHE2_OPTS="-D JK"
--------------------------------------------------------------------------------


2. tomcat 설치
# emerge www-servers/tomcat


3. apache tomcat 데몬을 시작
/etc/init.d/apache2 restart && /etc/init.d/tomcat5 restart

시작후 다음 페이지가 정상적으로 나오는지 확인한다.
http://<서버IP>/

위에서 출력되는 파일은 시스템 상에 다음 파일이다.
/var/lib/tomcat-6/webapps/ROOT/index.jsp

이미지가 엑박으로 나오는건 무시해도 됨

4. 인덱스 페이지 변경 [옵션]
인덱스 파일명을 변경하려면 다음 파일을 수정

# vi /etc/apache2/httpd.conf
--------------------------------------------------------------------------------
DirectoryIndex index.html index.jsp
--------------------------------------------------------------------------------


5. Apache Virtual Host 설정 [옵션]
virtual host 설정 중 가장 먼저오는 설정이 디폴트 설정(일치하는 호스트가 없을 경우 보여지는 사이트)

vi /etc/apache2/vhosts.d/00_default_vhost.conf
--------------------------------------------------------------------------------
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /var/www/domain1.dummy-host.example.com/htdocs
    ServerName domain1.dummy-host.example.com
    ErrorLog /var/log/apache2/localhost-error_log
    CustomLog /var/log/apache2/localhost-access_log common
</VirtualHost>
--------------------------------------------------------------------------------


6. Tomcat server.xml 파일 수정 [옵션]

vi /etc/tomcat-5.5/server.xml
--------------------------------------------------------------------------------
<Host name="domain1.dummy-host.example.com" debug="0"
appBase="/var/www/domain1.dummy-host.example.com/htdocs" unpackWARs="true"
autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
    <Logger className="org.apache.catalina.logger.FileLogger" directory="logs" 
prefix="domain1.dummy-host.example.com"   suffix=".log"  timestamp="true"/>
    <Context path="" docBase="" debug="0" allowLinking="true"/>
</Host>
--------------------------------------------------------------------------------


7. 아파치와 톰켓을 서버 기동시 자동시작 되도록 한다.
# rc-update add apache2 default
# rc-update add tomcat-6 default


 

Gentoo Mirror 변경

cat /etc/make.conf

#GENTOO_MIRRORS="http://ftp.kaist.ac.kr/pub/gentoo/"
GENTOO_MIRRORS="http://ftp.daum.net/gentoo/"

CentOS를 Gentoo로 변신시키기

IDC에  설치되어 있던 CentOS를 원격지에서 Gentoo Linux로 변경시켰던 내용을 요약


<CentOS로 부팅>
* 현 시스템의 하드웨어 정보확인
--------------------------------------------------------------------------------
[root@localhost ~]# lspci
00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)
00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]
00:01.1 IDE interface: Intel Corporation 82371SB PIIX3 IDE [Natoma/Triton II]
00:01.2 USB Controller: Intel Corporation 82371SB PIIX3 USB [Natoma/Triton II] (rev 01)
00:01.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 03)
00:02.0 VGA compatible controller: Cirrus Logic GD 5446
00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 03)

[root@localhost ~]# lsmod
Module                  Size  Used by
ip_conntrack_ftp       41489  0
ip_conntrack_netbios_ns    36033  0
ipt_REJECT             38849  1
xt_tcpudp              36417  12
xt_state               35265  13
ip_conntrack           91237  3 ip_conntrack_ftp,ip_conntrack_netbios_ns,xt_state
nfnetlink              40457  1 ip_conntrack
iptable_filter         36161  1
ip_tables              55329  1 iptable_filter
x_tables               50377  4 ipt_REJECT,xt_tcpudp,xt_state,ip_tables
dm_mirror              60617  0
dm_multipath           52945  0
dm_mod                 99737  2 dm_mirror,dm_multipath
video                  53197  0
sbs                    49921  0
backlight              39873  1 video
i2c_ec                 38593  1 sbs
button                 40544  0
battery                43849  0
asus_acpi              50917  0
acpi_memhotplug        40133  0
ac                     38729  0
lp                     47121  0
floppy                 95465  0
e1000                 155601  0
i2c_piix4              42573  0
i2c_core               56129  2 i2c_ec,i2c_piix4
pcspkr                 36289  0
ide_cd                 73697  0
cdrom                  68713  1 ide_cd
parport_pc             62313  1
serio_raw              40517  0
parport                73165  2 lp,parport_pc
ata_piix               54981  0
libata                192345  1 ata_piix
sd_mod                 56257  0
scsi_mod              188665  2 libata,sd_mod
ext3                  167249  7
jbd                    93873  1 ext3
uhci_hcd               57433  0
ohci_hcd               54493  0
ehci_hcd               65741  0

[root@localhost ~]# ifconfig -a
eth0      Link encap:Ethernet  HWaddr DE:AD:BE:E0:02:39
          inet addr:115.68.20.101  Bcast:115.68.20.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1978 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1658 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:253256 (247.3 KiB)  TX bytes:199147 (194.4 KiB)
          Base address:0xc040 Memory:f2020000-f2040000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:996 errors:0 dropped:0 overruns:0 frame:0
          TX packets:996 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1849560 (1.7 MiB)  TX bytes:1849560 (1.7 MiB)

[root@localhost ~]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
115.68.20.0     *               255.255.255.0   U     0      0        0 eth0
default         115.68.20.1     0.0.0.0         UG    0      0        0 eth0

[root@localhost ~]# cat /etc/resolv.conf
nameserver 220.90.215.11
nameserver 168.126.63.1
search localhost

[root@localhost ~]# df -m
Filesystem           1M-blocks      Used Available Use% Mounted on
/dev/hda1                  996        50       894   6% /boot
/dev/hda3                 1984       495      1387  27% /
/dev/hda5                 7933       657      6868   9% /var
/dev/hda6                 7933       147      7378   2% /usr/local
/dev/hda7                 5950      3411      2232  61% /usr
/dev/hda8                  996        34       911   4% /tmp
/dev/hda9                10973       156     10250   2% /home
tmpfs                      250         0       250   0% /dev/shm

# fdisk -l /dev/hda
Disk /dev/hda: 41.9 GB, 41943040000 bytes
255 heads, 63 sectors/track, 5099 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000588ae

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1         131     1052226   83  Linux
/dev/hda2             132         392     2096482+  82  Linux swap / Solaris
/dev/hda3             393         653     2096482+  83  Linux
/dev/hda4             654        5099    35712495    f  W95 Ext'd (LBA)
/dev/hda5             654        1697     8385898+  83  Linux
/dev/hda6            1698        2741     8385898+  83  Linux
/dev/hda7            2742        3524     6289416   83  Linux
/dev/hda8            3525        3655     1052226   83  Linux
/dev/hda9            3656        5099    11598898+  83  Linux
 

* 하드디스크 파티셔닝 계획
--------------------------------------------------------------------------------
- 원본
/dev/hda1                  996
/dev/hda3                 1984
/dev/hda5                 7933
/dev/hda6                 7933
/dev/hda7                 5950
/dev/hda8                  996
/dev/hda9                10973

- 기본
hda1 /boot 유지
hda2 swap 유지

- 변경
hda3, hda5 ~ hda8 삭제

dev  mount size
hda3 /tmp    2G
hda5 /  30G


* 설치
--------------------------------------------------------------------------------

# umount /dev/hda9
# mkfs.ext3 /dev/hda9
# mkdir /mnt/gentoo
# mount -t ext3 /dev/hda9 /mnt/gentoo
# cd /mnt/gentoo
# wget http://ftp.daum.net/gentoo/releases/amd64/current/stages/stage3-amd64-2008.0.tar.bz2
# bzip2 -d stage3-i686-2008.0.tar.bz2
# time tar xvf stage3-i686-2008.0.tar
real    1m9.484s
user    0m1.138s
sys     0m17.466s

/* 최신버전 Portage snapshot를 설치 */
# cd /mnt/gentoo/usr
# wget http://ftp.daum.net/gentoo/releases/snapshots/current/portage-2008.0.tar.bz2
# time bzip2 -d portage-2008.0.tar.bz2
real    0m36.732s
user    0m25.455s
sys     0m31.276s

# time tar xvf portage-2008.0.tar
real    1m58.076s
user    0m3.309s
sys     0m40.213s

/* Chrooting */
# cd /
# mount -t proc proc /mnt/gentoo/proc
# cp -L /etc/resolv.conf /mnt/gentoo/etc/
# chroot /mnt/gentoo /bin/bash
# env-update && source /etc/profile
>>> Regenerating /etc/ld.so.cache...

/* Set your time zone */
# ls /usr/share/zoneinfo
# cp /usr/share/zoneinfo/Asia/Seoul /etc/localtime
# date
2008. 10. 16. (목) 16:50:42 KST

/* Set your host and domain name */
localhost / # cd /etc
localhost etc # echo "127.0.0.1 ns.javaya.org ns localhost" > hosts
localhost etc # sed -i -e 's/HOSTNAME.*/HOSTNAME="ns"/' conf.d/hostname
localhost etc # hostname ns
localhost etc # hostname -f
ns.javaya.org

/* Kernel Configuration */
localhost etc # echo "GENTOO_MIRRORS=\"http://ftp.kaist.ac.kr/pub/gentoo/\"" >> make.conf
localhost etc # time emerge gentoo-sources

real  2m51.435s
user  0m58.220s
sys   0m29.890s
localhost etc # cd /usr/src/linux
localhost linux # make menuconfig
(Configure your kernel)
localhost linux # time make -j2

(Elapsed time depends highly on the options you selected)
real  3m51.962s
user  3m27.060s
sys   0m24.310s

localhost linux # make modules_install
(/boot 파티션이 마운트 되지 않았다면 마운트한다)
localhost linux # cp arch/i386/boot/bzImage /boot/bzImage-2.6.24-gentoo-r7

/* Configure the system - filesystem */
localhost linux # cd /etc
localhost etc # nano -w fstab
/dev/hda1   /boot     ext3    noauto,noatime     1 2
/dev/hda9   /         ext3    noatime            0 1
/dev/hda2   none      swap    sw                 0 0

/* Configure the system - network */
localhost etc # cd conf.d
localhost conf.d # echo 'config_eth0=( "115.68.20.101/24" )' >> net
localhost conf.d # echo 'routes_eth0=( "default via 115.68.20.1" )' >> net
localhost conf.d # rc-update add net.eth0 default
(If you compiled your network card driver as a module,
add it to /etc/modules.autoload.d/kernel-2.6)
localhost conf.d # echo sk98lin >> /etc/modules.autoload.d/kernel-2.6
(If you want to reconnect via ssh after you have rebooted your new box:)
localhost conf.d # rc-update add sshd default

/* Configure the system - password */
localhost conf.d # passwd
New UNIX password: type_the_password
Retype new UNIX password: type_the_password_again
passwd: password updated successfully

localhost conf.d # nano -w /etc/conf.d/clock
TIMEZONE="Asia/Seoul"


/* Installing System Tools  */
localhost conf.d # time emerge syslog-ng vixie-cron


/* Install extra tools if required  */
localhost conf.d # emerge xfsprogs       (If you use the XFS file system)
localhost conf.d # emerge jfsutils       (If you use the JFS file system)
localhost conf.d # emerge reiserfsprogs  (If you use the Reiser file system)
localhost conf.d # emerge dhcpcd         (If you need a DHCP client)
localhost conf.d # emerge ppp            (If you need PPPoE ADSL connectivity)


/* Configuring the Bootloader */
localhost conf.d # mount -t ext3 /dev/hda1 /mnt/gentoo/boot

localhost conf.d # time emerge grub
localhost conf.d # nano -w /boot/grub/grub.conf
--------------------------------------------------------------------------------
default 0
timeout 10

title=Gentoo
 root (hd0,0)
 kernel /bzImage-2.6.24-gentoo-r7 root=/dev/hda9
--------------------------------------------------------------------------------
localhost conf.d # grub
Probing devices to guess BIOS drives. This may take a long time.

grub> root (hd0,0)
 Filesystem type is ext2fs, partition type 0x83

grub> setup (hd0)
 Checking if "/boot/grub/stage1" exists... yes
 Checking if "/boot/grub/stage2" exists... yes
 Checking if "/boot/grub/e2fs_stage1_5" exists... yes
 Running "embed /boot/grub/e2fs_stage1_5 (hd0)"...  16 sectors are embedded.
succeeded
 Running "install /boot/grub/stage1 (hd0) (hd0)1+16 p (hd0,0)/boot/grub/stage2 /boot/
grub/menu.lst"... succeeded
Done.

grub> quit

/* Reboot */
livecd conf.d # exit
livecd / # umount /mnt/gentoo/proc /mnt/gentoo/boot /mnt/gentoo
livecd / # reboot


/* 파티션 조정 */

ns ~ # fdisk /dev/hda
<fdisk를 이용해서 다음과 같이 파티션 설정, 파티션 설정후 순서를 바로잡기 위해 extra메뉴에서 fix order를 선택>
--------------------------------------------------------------------------------
Command (m for help): x

Expert command (m for help): m
Command action
   b   move beginning of data in a partition
   c   change number of cylinders
   d   print the raw data in the partition table
   e   list extended partitions
   f   fix partition order
   g   create an IRIX (SGI) partition table
   h   change number of heads
   i   change the disk identifier
   m   print this menu
   p   print the partition table
   q   quit without saving changes
   r   return to main menu
   s   change number of sectors/track
   v   verify the partition table
   w   write table to disk and exit

Expert command (m for help): f
Expert command (m for help): r
Command (m for help): w


ns ~ # fdisk -l

Disk /dev/hda: 41.9 GB, 41943040000 bytes
255 heads, 63 sectors/track, 5099 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000588ae

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1         131     1052226   83  Linux
/dev/hda2             132         392     2096482+  82  Linux swap / Solaris
/dev/hda3             393         653     2096482+  83  Linux
/dev/hda4             654        5099    35712495    f  W95 Ext'd (LBA)
/dev/hda5             654        3455    22507033+  83  Linux
/dev/hda6            3456        3466       88326   83  Linux
/dev/hda7            3467        3476       80293+  83  Linux
/dev/hda8            3477        3486       80293+  83  Linux
/dev/hda9            3656        5099    11598898+  83  Linux


ns ~ # reboot

<reboot...>
================================================================================
/dev/hda3 -> /tmp
/dev/hda5 -> /
위와 같이 마운트 시켜서 쓸 것임
================================================================================

ns ~ # mkfs.ext3 /dev/hda3
ns ~ # mkfs.ext3 /dev/hda5
ns ~ # mkdir /mnt/newmount
ns ~ # mount /dev/hda5 /mnt/newmount

ns ~ # cp -p R /bin /mnt/newmount
ns ~ # cp -p -R /boot /mnt/newmount
ns ~ # cp -p -R /dev /mnt/newmount
ns ~ # cp -p -R /etc /mnt/newmount
ns ~ # cp -p -R /lib -> lib64 /mnt/newmount
ns ~ # cp -p -R /lib32 /mnt/newmount
ns ~ # cp -p -R /lib64 /mnt/newmount
ns ~ # cp -p -R /mnt /mnt/newmount
ns ~ # cp -p -R /opt /mnt/newmount
ns ~ # cp -p -R /root /mnt/newmount
ns ~ # cp -p -R /sbin /mnt/newmount
ns ~ # cp -p -R /sys /mnt/newmount
ns ~ # cp -p -R /usr /mnt/newmount
ns ~ # cp -p -R /var /mnt/newmount

ns ~ # mkdir /mnt/newmount/proc
ns ~ # mkdir /mnt/newmount/home
ns ~ # mkdir /mnt/newmount/tmp

ns ~ # nano -w /mnt/newmount/etc/fstab
--------------------------------------------------------------------------------
/dev/hda1   /boot     ext3    noauto,noatime     1 2
/dev/hda5   /         ext3    noatime            0 1
/dev/hda3   /tmp      ext3    noatime            0 1
/dev/hda2   none      swap    sw                 0 0
--------------------------------------------------------------------------------

ns ~ # mount -t ext3 /dev/hda1 /boot
ns ~ # nano -w /boot/grub/grub.conf
--------------------------------------------------------------------------------
title=Gentoo
    root (hd0,0)
    kernel /bzImage-2.6.24-gentoo-r7 root=/dev/hda5
title=GentooOLD
    root (hd0,0)
    kernel /bzImage-2.6.24-gentoo-r7 root=/dev/hda9
--------------------------------------------------------------------------------

ns ~ # grub
--------------------------------------------------------------------------------
Probing devices to guess BIOS drives. This may take a long time.

grub> root (hd0,0)
 Filesystem type is ext2fs, partition type 0x83

grub> setup (hd0)
 Checking if "/boot/grub/stage1" exists... yes
 Checking if "/boot/grub/stage2" exists... yes
 Checking if "/boot/grub/e2fs_stage1_5" exists... yes
 Running "embed /boot/grub/e2fs_stage1_5 (hd0)"...  16 sectors are embedded.
succeeded
 Running "install /boot/grub/stage1 (hd0) (hd0)1+16 p (hd0,0)/boot/grub/stage2 /boot/
grub/menu.lst"... succeeded
Done.

grub> quit
--------------------------------------------------------------------------------

ns ~ # reboot
<reboot...>
** 기타 파티션 정리 및 남은 파티션 필요에 따라 마운트
emerge -vpe world
echo 'USE="nptl nptlonly -ipv6 -fortran unicode svg dbus \
> X -kde -qt3 -qt4 -arts -eds -esd qtk gnome hal avahi gstreamer firefox apache2 nls"' >> /etc/make.conf

Gentoo Linux x86 Quick Install Guide

설치환경
M/B: Asus P5GZ-MX
CPU:
VGA:
NIC: 


1.Introduction

이 문서는 젠투 스테이지3 설치를 위한 모든 명령에 대해 설명한다. 스테이지3와 스냅샷 포테이지 다운로드를 하려면 인터넷에 연결되어 있어야 한다.
이후의 측정 시간들은 AMD 2000 1.66 Ghz, 512MB 메모리, SATA 하드 2개로 구성된 시스템에서 측정한 것으로 시스템에 따라 차이가 날 수 있다.

2.Quick Install Guide

Installation Media

미러 사이트 에서 CD를 다운로드 받는다. releases/x86/<release>/installcd 에서 minimal CD ISO파일을 찾을 수 있다. minimal installation CD 는 인터넷 기반의 설치에서만 사용 가능하다. 이 문서에서는 minimal CD 기반의 설치에 대해서만 설명할 것이다.
다운받은 CD를 굽고 그 시디로 부팅한다.
부팅 선택화면에서 gentoo-nofb를 입력하고 부팅한다. 부팅시 시스템이 멈추는 현상이 발생하면 nodetect 옵션을 사용하여 부팅하고 필요한 모듈을 명시적으로 로딩한다.
  • Code Listing 2.1: Boot the minimal CD
Gentoo Linux Installation LiveCD                     http://www.gentoo.org
Enter to Boot; F1 for kernels  F2 for options.
boot: gentoo-nofb
  (or in case of problems)
boot: gentoo-nofb nodetect


Optional: loading modules

Asus P5GZ-MX 보드의 경우 Marvell 88E8001 Gigabit Ethernet을 사용하기 때문에 아래와 같이 모듈을 로딩한다.
  • Code Listing 2.2: Load required modules
livecd root # lspci
(Use lspci's output to identify required modules)

(sk98lin 모듈을 로딩한다)
livecd root # modprobe sk98lin


Network Configuration

아래와 같이 수동으로 네트워크 정보를 설정한다. 아래에서 192.168.1.10는 설치될 머신에 할당될 IP, 192.168.1.1은 default gateway , 219.250.36.130은 네임서버 IP이다.
  • Code Listing 2.4: Configure networking the manual way
livecd root # ifconfig eth0 192.168.1.10/24
livecd root # route add default gw 192.168.1.1
livecd root # echo nameserver 219.250.36.130 > /etc/resolv.conf


Preparing the Disks

fdisk 또는 cfdisk를 이용해서 파티션을 설정한다. 최소 1개의 스왑 파티션(타입 82)와 1개의 리눅스 파티션(타입 83)이 필요하다. 아래에서는 1개의 /boot 파티션, 1개의 스왑 파티션, 나머지를 / 파티션으로 설정한다. 하드디스크 인터페이스에 따라 SATA나 SCSI는 /dev/sda로 IDE는 /dev/hda로 표시될 것이다. (/boot 파티션은 제일 처음 100메가 이하로 설정할 것을 권장한다)
  • Code Listing 2.8: Create the partitions
livecd ~ # fdisk /dev/sda

(The rest of this guide uses the following partitioning scheme)
livecd ~ # fdisk -l /dev/sda

Disk /dev/sda: 599.9 GB, 599978409984 bytes
255 heads, 63 sectors/track, 72943 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1          12       96358+  83  Linux
/dev/sda2              13         110      787185   82  Linux swap / Solaris
/dev/sda3             111       72943   585031072+  83  Linux

mke2fs, mke2fs -j, mkreiserfs, mkfs.xfs, mkfs.jfs 명령을 이용해 리눅스 파티션을 포멧 한다. mkswap, swapon 명령어를 이용해 스왑 파티션을 초기화 한다.

  • Code Listing 2.9: Create the file systems and activate swap
(ext2 is all you need on the /boot partition)
livecd ~ # mke2fs /dev/sda1

(Let's use ext3 on the main partition)
livecd ~ # mke2fs -j /dev/sda3

(Create and activate swap)
livecd ~ # mkswap /dev/sda2 && swapon /dev/sda2

위의 파티션들을 마운트 한다.

  • Code Listing 2.10: Mount the file systems
livecd ~ # mount /dev/sda3 /mnt/gentoo
livecd ~ # mkdir /mnt/gentoo/boot
livecd ~ # mount /dev/sda1 /mnt/gentoo/boot


Setting Up The Stage

아래처럼 시스템 시간을 확인해서 틀린 경우 시간을 맞춘다.
  • Code Listing 2.11: Set the date and UTC time
(Check the clock)
livecd ~ # date
Mon Mar  6 00:14:13 UTC 2006

(Set the current date and time if required)
livecd ~ # date 030600162006 (Format is MMDDhhmmYYYY)
Mon Mar  6 00:16:00 UTC 2006

미러 사이트에서 stage 파일을 다운로드 받는다. /mnt/gentoo 디렉토리에서 다음 명령어를 실행해 압축을 푼다. tar xjpf <stage3 tarball>

  • Code Listing 2.12: Download a stage3 archive
livecd ~ # cd /mnt/gentoo
livecd gentoo # links http://www.gentoo.org/main/en/mirrors.xml
(Pick a mirror, move to the releases/x86/current/stages directory highlight the
stage3 of your choice, probably the i686 stage3 and press D to download it)

(또는 미러 선택을 하지 않고 아래와 같이 직접 URL을 입력해 다운받는다.)
livecd ~ # cd /mnt/gentoo
livecd gentoo # wget ftp://gentoo.osuosl.org/pub/gentoo/releases/x86/current/stages/stage3-i686-2007.0.tar.bz2
  • Code Listing 2.13: Unpack the stage3 archive
livecd gentoo # time tar xjpf stage3*

real  1m13.157s
user  1m2.920s
sys   0m7.230s

최신버전 Portage snapshot를 설치한다. 설치과정의 stage3 설치과정과 유사하다.

  • Code Listing 2.14: Download the latest Portage snapshot
livecd gentoo # cd /mnt/gentoo/usr
livecd usr # links http://www.gentoo.org/main/en/mirrors.xml
(Pick a mirror, move to the snapshots/ directory,
highlight portage-latest.tar.bz2 and press D to download it)

(또는 미러 사이트의 URL을 입력해 직접 다운로드 한다)
livecd gentoo # cd /mnt/gentoo/usr
livecd usr # wget http://gentoo.osuosl.org/snapshots/portage-latest.tar.bz2
  • Code Listing 2.15: Unpack the Portage snapshot
livecd usr # time tar xjf portage*

real  0m51.523s
user  0m28.680s
sys   0m12.840s


Chrooting

아래와 같이 /proc 파일 시스템을 마운트 하고 /etc/resolv.conf 파일을 복사한다. 그리고 젠투 환경으로 chroot 한다.
  • Code Listing 2.16: Chroot
livecd usr # cd /
livecd / # mount -t proc proc /mnt/gentoo/proc
livecd / # cp -L /etc/resolv.conf /mnt/gentoo/etc/
livecd / # chroot /mnt/gentoo /bin/bash
livecd / # env-update && source /etc/profile
>>> Regenerating /etc/ld.so.cache...


Set your time zone

/usr/share/zoneinfo 디렉토리에 위치한 파일을 이용해 타임 존을 설정한다.
  • Code Listing 2.17: Setting your timezone
livecd / # ls /usr/share/zoneinfo
(Using Seoul as an example)
livecd / # cp /usr/share/zoneinfo/Asia/Seoul /etc/localtime

livecd / # date
Wed Mar  8 00:46:05 KST 2007


Set your host and domain name

아래와 같이 /etc/conf.d/hostname, /etc/hosts 파일에 호스트 이름을 설정한다. 아래에서는 호스트 네임이 mybox이고 도메인 이름이 at.myplace이다. nano를 이용해 아래와 같이 설정한다.
  • Code Listing 2.18: Set host and domain name
livecd / # cd /etc
livecd etc # echo "127.0.0.1 mybox.at.myplace mybox localhost" > hosts
livecd etc # sed -i -e 's/HOSTNAME.*/HOSTNAME="mybox"/' conf.d/hostname
(Use defined host name and check)
livecd etc # hostname mybox
livecd etc # hostname -f
mybox.at.myplace


Kernel Configuration

커널 소스(gentoo-sources 이용)를 설치하고 설정하고 컴파일해서 arch/i386/boot/bzImage 파일을 /boot로 복사한다.
  • Code Listing 2.19: Install a kernel source, compile it and install the kernel
livecd etc # time emerge gentoo-sources

real  2m51.435s
user  0m58.220s
sys   0m29.890s
livecd etc # cd /usr/src/linux
livecd linux # make menuconfig
(Configure your kernel)
livecd linux # time make -j2

(Elapsed time depends highly on the options you selected)
real  3m51.962s
user  3m27.060s
sys   0m24.310s

livecd linux # make modules_install
(/boot 파티션이 마운트 되지 않았다면 마운트한다)
livecd linux # cp arch/i386/boot/bzImage /boot/kernel

Configure the system

Edit your /etc/fstab and replace BOOT, ROOT and SWAP with the actual partition names. Don't forget to check that the file systems match your installation. 지금까지 설치한 환경에 맞게 /etc/fstab파일을 실제 환경에 맞게 수정한다.
  • Code Listing 2.20: Example fstab
livecd linux # cd /etc
livecd etc # nano -w fstab
/dev/sda1   /boot     ext2    noauto,noatime     1 2
/dev/sda3   /         ext3    noatime            0 1
/dev/sda2   none      swap    sw                 0 0

/etc/conf.d/net파일을 네트워크 환경에 맞게 수정한다. net.eth0 스크립트를 default run level에 추가한다. 여러개의 랜카드를 사용한다면 /etc/init.d/net.eth1 심볼릭 링크 파일 등을 만들어 default run level에 추가한다. 아래를 참고하여 설정한다.

  • Code Listing 2.21: Configure networking
livecd etc # cd conf.d
livecd conf.d # echo 'config_eth0=( "192.168.1.10/24" )' >> net
livecd conf.d # echo 'routes_eth0=( "default via 192.168.1.1" )' >> net
livecd conf.d # rc-update add net.eth0 default
(If you compiled your network card driver as a module,
add it to /etc/modules.autoload.d/kernel-2.6)
livecd conf.d # echo sk98lin >> /etc/modules.autoload.d/kernel-2.6
(If you want to reconnect via ssh after you have rebooted your new box:)
livecd conf.d # rc-update add sshd default

Set the root password using passwd를 이용해서 root 패스워드를 설정한다.

  • Code Listing 2.22: Set the root password
livecd conf.d # passwd
New UNIX password: type_the_password
Retype new UNIX password: type_the_password_again
passwd: password updated successfully

위에서 설정했던 타임 존으로 /etc/conf.d/clock 파일을 설정한다.

  • Code Listing 2.23: Edit /etc/conf.d/clock
livecd conf.d # nano -w /etc/conf.d/clock
TIMEZONE="Europe/Brussels"

/etc/rc.conf, /etc/conf.d/rc , /etc/conf.d/keymaps 파일에 추가으로 필요한 시스템 설정을 한다. (필요하다면)

  • Code Listing 2.24: Optional: edit some config files
livecd conf.d # nano -w /etc/rc.conf
livecd conf.d # nano -w /etc/conf.d/rc
livecd conf.d # nano -w /etc/conf.d/keymaps


Installing System Tools

syslog-ng, vixie-cron 와 같은 시스템 툴을 설치하고 default run level에 추가한다.
  • Code Listing 2.25: Install a syslogger and a cron daemon
livecd conf.d # time emerge syslog-ng vixie-cron

real  1m52.699s
user  1m1.630s
sys   0m35.220s
livecd conf.d # rc-update add syslog-ng default
livecd conf.d # rc-update add vixie-cron default

필요한 파일 시스템 툴 (xfsprogs, reiserfsprogs or jfsutils) 과 네트워킹 툴 (dhcpcd or ppp) 을 설치한다.

  • Code Listing 2.26: Install extra tools if required
livecd conf.d # emerge xfsprogs       (If you use the XFS file system)
livecd conf.d # emerge jfsutils       (If you use the JFS file system)
livecd conf.d # emerge reiserfsprogs  (If you use the Reiser file system)
livecd conf.d # emerge dhcpcd         (If you need a DHCP client)
livecd conf.d # emerge ppp            (If you need PPPoE ADSL connectivity)


Configuring the Bootloader

grub를 설치하고 /boot/grub/grub.conf를 설정한다.
1. Using grub
  • Code Listing 2.27: Emerge grub and edit its configuration file
livecd conf.d # time emerge grub

real  1m8.634s
user  0m39.460s
sys   0m15.280s
livecd conf.d # nano -w /boot/grub/grub.conf
  • Code Listing 2.28: Example grub.conf
default 0
timeout 10

title=Gentoo
root (hd0,0)
kernel /boot/kernel root=/dev/sda3
  • Code Listing 2.29: Install grub
livecd conf.d # grub
Probing devices to guess BIOS drives. This may take a long time.

grub> root (hd0,0)
 Filesystem type is ext2fs, partition type 0x83

grub> setup (hd0)
 Checking if "/boot/grub/stage1" exists... yes
 Checking if "/boot/grub/stage2" exists... yes
 Checking if "/boot/grub/e2fs_stage1_5" exists... yes
 Running "embed /boot/grub/e2fs_stage1_5 (hd0)"...  16 sectors are embedded.
succeeded
 Running "install /boot/grub/stage1 (hd0) (hd0)1+16 p (hd0,0)/boot/grub/stage2 /boot/
grub/menu.lst"... succeeded
Done.

grub> quit


Reboot

chroot 환경을 종료하고 모든 파일 시스템을 언마운트한 뒤 리붓한다.
  • Code Listing 2.33: Reboot
livecd conf.d # exit
livecd / # umount /mnt/gentoo/proc /mnt/gentoo/boot /mnt/gentoo
livecd / # reboot
(Don't forget to remove the CD)


Finalizing the Installation

root로 로그인한 뒤 useradd를 이용해 계정을 추가한다.
  • Code Listing 2.34: Connect to your new box from another PC
(Clean up your known_hosts file because your new box
has generated a new definitive hostkey)
$ nano -w ~/.ssh/known_hosts
(Look for the IP of your new PC and delete the line,
then save the file and exit nano)

(Use the IP address of your new box)
$ ssh root@192.168.1.10
The authenticity of host '192.168.1.10 (192.168.1.10)' can't be established.
RSA key fingerprint is 96:e7:2d:12:ac:9c:b0:94:90:9f:40:89:b0:45:26:8f.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.10' (RSA) to the list of known hosts.
Password: type_the_password
  • Code Listing 2.35: Add a new user
mybox ~ # adduser -g users -G lp,wheel,audio,cdrom,portage,cron -m john
mybox ~ # passwd john
New UNIX password: Set John's password
Retype new UNIX password: Type John's password again
passwd: password updated successfully
  • root로 ssh 접근 제한
/etc/ssh/sshd_config 파일 수정
PermitRootLogin no

Last configuration touches

mirrorselect를 이용해 미러 사이트 선택을 위한 /etc/make.conf파일의 SYNC, GENTOO_MIRRORS 변수를 설정한다.
  • Code Listing 2.36: Use mirrorselect and set MAKEOPTS
mybox ~ # emerge mirrorselect
mybox ~ # mirrorselect -i -o >> /etc/make.conf
mybox ~ # mirrorselect -i -r -o >> /etc/make.conf
(Usually, (the number of processors + 1) is a good value)
mybox ~ # echo 'MAKEOPTS="-j3"' >> /etc/make.conf

USE 플래그의 enable, disable 설정을 한다. USE 플래그의 enable/disable 설정에 따른 패키지를 확인하려면 emerge -vpe world 명령을 이용한다. 아래 명령어를 이용해서 /etc/make.conf 파일의 USE 변수를 설정한다. 듀얼코어나 듀얼 시피유인 경우는 -j3를 싱글인 경우는 -j2를 사용한다.

  • Code Listing 2.37: View USE flags in use and enable or disable some
mybox ~ # emerge -vpe world
(Portage displays the packages and their USE flags, as an example, let's
disable ipv6 and fortran, and enable unicode)
mybox ~ # echo 'USE="nptl nptlonly -ipv6 -fortran unicode svg dbus \
> X -kde -qt3 -qt4 -arts -eds -esd qtk gnome hal avahi gstreamer firefox apache2 nls"' >> /etc/make.conf


최근 버전의 glibc는 로케일 설정을 위해 /etc/locale.gen를 사용한다.
  • Code Listing 2.38: Define locales
mybox ~ # cd /etc
mybox etc # nano -w locale.gen

최적화를 위해 필요하다면 /etc/make.conf의 CFLAGS 변수를 수정한다. 프로세스 타입과 -O2 -pipe 옵션 정도는 사용할 것을 권장한다.

You may also want to switch to ~x86. You should only do this if you can deal with the odd broken ebuild or package. If you'd rather keep your system stable, don't add the ACCEPT_KEYWORDS variable. Adding FEATURES="parallel-fetch ccache" is also a good idea.
  • Code Listing 2.39: Last edit of make.conf
mybox etc # nano -w make.conf
(Set -march to your CPU type in CFLAGS)
CFLAGS="-O3 -march=i686 -pipe"
(Add the following line)
FEATURES="parallel-fetch ccache"
(Only add the following if you know what you're doing)
ACCEPT_KEYWORDS="~x86"

약간의 성능 증가를 위해 상당히 많은 시간을 필요로 하는 작업이지만 최종 수정된 설정을 반영하기를 원한다면 전체 시스템일 다시 컴파일 해야한다. 항상 새로운 버전의 패키지를 유지하고 하여 시스템을 최적하 할 수 있다. 시스템 유지보수 관점에서는 재컴파일 하는 것은 좋은 방법일 수 있다. Gentoo GCC Upgrading Guide를 참고하라. (듀얼 시피유인 경우는 -O3를 싱글인 경우는 -O2를 사용한다)

Recompiling only the packages that have already been updated since the release or that are affected by your new USE flags will take enough time. You might also have to remove packages that block your upgrade. Look for "[blocks B ]" in the output of emerge -vpuD --newuse world and use emerge -C to remove them.
  • Code Listing 2.40: Update your packages
(Install ccache)
mybox etc # emerge ccache

(Please note that the switch to ~x86 causes many packages to be upgraded)
mybox etc # emerge -vpuD --newuse world
(Take a good look at the package list and their USE flags,
remove blocking packages if any, and start the lengthy process)
mybox etc # time emerge -vuD --newuse world
(79 packages have been (re)compiled)

real  180m13.276s
user  121m22.905s
sys   36m31.472s

(Remerge libtool to avoid further potential problems)
mybox etc # emerge libtool

(Update config files, make sure you do not let etc-update
update config files you have edited)
mybox etc # etc-update

(If perl has been updated, you should run the perl-cleaner script)
mybox etc # time perl-cleaner all
real  1m6.495s
user  0m42.699s
sys   0m10.641s

(In case of a major upgrade of python, you should run the python-updater script)
mybox etc # python-updater

What to do next

Depending on what your new Gentoo machine is supposed to do, you will probably want to install server applications or a desktop system. Just as an example, emerge gnome and emerge kde have been timed on the ~x86 system installed as describe above. Both have been installed from the same starting point. 필요하다면 emerge gnome 또는 emerge kde 를 실행해서 gnome이나 kde를 설치한다.
다른 문서를 참고해서 설치할 프로그램을 설정하는 방법을 확인한다.
Important: The following is only an example. It is in no way meant as a recommended setup.
  • Code Listing 2.41: Emerge GNOME
mybox etc # emerge -vp gnome
(Look at the list of packages and their USE flags,
then edit make.conf if required.
mybox etc # nano -w /etc/make.conf
(The following USE flags have been defined)
USE="nptl nptlonly -ipv6 -fortran unicode svg hal dbus \
     -kde -qt3 -qt4 -arts -eds -esd gnome gstreamer gtk firefox"

mybox etc # time emerge gnome
(326 packages have been emerged)

real  520m44.532s
user  339m21.144s
sys   146m22.337s
  • Code Listing 2.42: Emerge KDE
mybox etc # emerge -vp kde-meta
(Look at the list of packages and their USE flags,
then edit make.conf if required.
mybox etc # nano -w /etc/make.conf
The following USE flags have been defined)
USE="nptl nptlonly -ipv6 -fortran unicode svg hal dbus \
     kde qt3 qt4 -arts -eds -esd -gnome -gstreamer -gtk -firefox"

mybox etc # time emerge kde-meta
(391 packages have been emerged)

real  1171m25.318s
user  851m26.393s
sys   281m45.629s
참고:
Gnome 설치시 다음 에러가 발생하는 경우
-------------------------------------------------------------------------------- 
!!! ERROR: x11-libs/gtk+-2.8.19 failed. 
Call stack: 
ebuild.sh, line 1555: Called dyn_setup 
ebuild.sh, line 668: Called pkg_setup 
gtk+-2.8.19.ebuild, line 57: Called die 

!!! cairo needs the X flag set 
!!! If you need support, post the topmost build error, and 
the call stack if relevant. 
-------------------------------------------------------------------------------- 
USE="X" emerge x11-libs/cairo