FreeBSDに係わる構築や維持など

Archive for 7月, 2006

ユーザ毎のウェブサイトを構築

 UserDir ディレクティブを使って 各ユーザがホームディレクトリにウェブサイトを構築できるように設定します。

# vi /usr/local/etc/apache22/extra/httpd-userdir.conf

UserDir public_html
UserDir disabled root

<Directory /home/*/public_html>
    AllowOverride All
    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec ExecCGI
    <Limit GET POST OPTIONS PROPFIND>
        Order allow,deny
        Allow from all
    </Limit>
    <LimitExcept GET POST OPTIONS PROPFIND>
        Order deny,allow
        Deny from all
    </LimitExcept>
</Directory>

httpd.confの設定(コメントアウトをする)

# vi /usr/local/etc/apache22/httpd.conf

# User home directories
Include etc/apache22/extra/httpd-userdir.conf

名前ベース NameVirtualHostの設定

名前ベースでNameVirtualHostの設定を行います。

# vi /usr/local/etc/apache22/extra/httpd-vhosts.conf

NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin test@192.168.253.3
    DocumentRoot /usr/local/www/apache22/data
    ServerName vm.selfip.com
    ErrorLog /var/log/httpd/httpd-error.log
    CustomLog /var/log/httpd/httpd-access.log combined env=!nolog
   <Directory "/usr/local/www/apache22/data">
       Options Includes ExecCGI FollowSymLinks
       AllowOverride All
       Order allow,deny
       Allow from all
   </Directory>
   <IfModule log_config_module>
    LogFormat "%h %l %u %t \"%!414r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common
   <IfModule logio_module>
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
   </IfModule>
       SetEnvIf Request_URI "\.(gif)|(jpg)|(JPG)|(png)|(css)|(ico)|(js)$" nolog
       SetEnvIf Request_URI "^/_mem_bin/" worm
       SetEnvIf Request_URI "^/_vti_bin/" worm
       SetEnvIf Request_URI "^/c/" worm
       SetEnvIf Request_URI "^/d/" worm
       SetEnvIf Request_URI "^/msadc/" worm
       SetEnvIf Request_URI "^/MSADC/" worm
       SetEnvIf Request_URI "^/scripts/" worm
       SetEnvIf Request_URI "^/default.ida" worm
       SetEnvIf Request_URI "root\.exe" worm
       SetEnvIf Request_URI "cmd\.exe" worm
       SetEnvIf Request_URI "NULL\.IDA" worm
       SetEnvIf Request_URI "SEARCH" worm
       SetEnvIf Remote_Addr "192\.168\.*" nolog
   </IfModule>
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin test@192.168.253.3
    DocumentRoot /usr/local/www/apache22/tiesto.homeip.org
    ServerName tiesto.homeip.org
    ErrorLog /var/log/httpd/httpd-error.log
    CustomLog /var/log/httpd/httpd-access-tie.log combined
   <Directory "/usr/local/www/apache22/tiesto.homeip.org">
       Options Includes ExecCGI FollowSymLinks
       AllowOverride All
       Order allow,deny
       Allow from all
   </Directory>
</VirtualHost>

httpd.confの設定(コメントアウトをする)

# vi /usr/local/etc/apache22/httpd.conf

# Virtual hosts
Include etc/apache22/extra/httpd-vhosts.conf

IPFW(IP firewall)で遊ぶ

ipfw を有効にする

# uname -rs
FreeBSD 6.1-RELEASE

# vi /etc/rc.conf
firewall_enable="YES"
firewall_type="/etc/ipfw.conf"

# vi /boot/loader.conf
dummynet_load="YES"

# vi /etc/sysctl.conf
sysctl net.inet.ip.fw.verbose=1

ipfw ルール設定

# vi /etc/ipfw.conf
add 65000 allow all from any to any

# reboot

ipfw ルールの動作確認

# kldstat
Id Refs Address    Size     Name
 1    6 0xc0400000 691928   kernel
 2    1 0xc0a92000 2364     accf_http.ko
 3    1 0xc0a95000 832c     dummynet.ko
 4    2 0xc0a9e000 d9f4     ipfw.ko
 5    1 0xc0aac000 58554    acpi.ko

# ipfw show
00100 1445 538811 pipe 10 ip from any to any
65535   50   3622 deny ip from any to any

# ipfw pipe show
00010: 128.000 Kbit/s    0 ms   50 sl. 1 queues (1 buckets) droptail
    mask: 0x00 0x00000000/0x0000 -> 0x00000000/0x0000
BKT Prot ___Source IP/port____ ____Dest. IP/port____ Tot_pkt/bytes Pkt/Byte Drp
  0 tcp   192.168.11.120/2844   192.168.11.201/80    1484   540502  0    0   0

帯域制御で遊ぶ

#ipfw add pipe 10 ip from any to any
#ipfw pipe 10 config bw 128Kbit/s

日本語マニュアル関連コマンド群インストール

1. 日本語マニュアル関連コマンド群インストール

# cd /usr/ports/japanese/man
# make install

===>   Registering installation for ja-man-1.1j_5
===> SECURITY REPORT:
      This port has installed the following binaries which execute with
      increased privileges.
/usr/local/bin/jman

      If there are vulnerabilities in these programs there may be a security
      risk to the system. FreeBSD makes no guarantee about the security of
      ports included in the Ports Collection. Please type 'make deinstall'
      to deinstall the port if this is a concern.
/usr/ports/japanese/man@tiesto# make clean
===>  Cleaning for ja-groff-1.18.1_10
===>  Cleaning for ja-less+iso-382.262
===>  Cleaning for gmake-3.81_1
===>  Cleaning for libiconv-1.9.2_2
===>  Cleaning for netpbm-10.26.29
===>  Cleaning for gettext-0.14.5_2
===>  Cleaning for perl-5.8.8
===>  Cleaning for tiff-3.8.2
===>  Cleaning for jpeg-6b_4
===>  Cleaning for png-1.2.8_3
===>  Cleaning for jbigkit-1.6
===>  Cleaning for libtool-1.5.22_2
===>  Cleaning for ja-man-1.1j_5
# make clean
# rehash

2. 日本語マニュアルpackage のインストール

# pkg_add ftp://daemon.jp.freebsd.org/pub/FreeBSD-jp/man-jp/packages-5.4.0/ja-man-doc-5.4.tbz
Fetching ftp://daemon.jp.freebsd.org/pub/FreeBSD-jp/man-jp/packages-5.4.0/ja-man-doc-5.4.tbz... Done.

***********************************************************************
* Japanese online manual has been successfully installed.             *
*                                                                     *
* (1) To read jman(1), use the following command sequence:            *
*        % setenv LC_CTYPE ja_JP.eucJP                                *
*        % setenv PAGER jless                                         *
*        % jman jman                                                  *
*                                                                     *
* (2) For more info, please visit following web page (Japanese):      *
*        Jpman project         *
*                                                                     *
* (3) If you have any questions, comments, bug reports, suggestions,  *
*     and/or requests for modifications, please send e-mail to:       *
*        Jpman project mailing list            *
*                                                                     *
***********************************************************************

3. 環境変数設定

使っているシェルが csh, tcsh の場合:
% setenv LC_CTYPE ja_JP.eucJP
% setenv PAGER jless
% jman jman

使っているシェルが sh, bash, ksh, zsh の場合:
$ export LC_CTYPE=ja_JP.eucJP
$ export PAGER=jless
$ jman jman

$ jman jmanpath
$ jman jwhatis
$ jman japropos
$ jman jcatman
$ jman jmakewhatis