サーバ管理



2015年 10月 6

Yosemiteにしてから(?)ターミナルで作業する時にvi(vim)を使うとテンキーが使えない問題に悩んでいた。検索したけど中々解決しなくて放っておいたのだけど、久しぶりに調べたら良記事を発見した。

コードの記憶 Macのvimとテンキーの問題

どうやらターミナルの設定に問題があったらしい。

「設定 > プロファイル > 詳細」にある VT100アプリケーションのキーパッドモードを許可 にチェックが入っているのが原因だったようだ。

ターミナル設定

チェックを外したらviでテンキーが使えるようになった。地味に不便だったから助かった。


Filed under: Mac,メモ

Trackback Uri






2014年 3月 15

同サイトのページだが探しにくいのでメモ。

SPF(Sender Policy Framework) : 迷惑メール対策委員会
SPFの歴史的背景や、SPF設定時のプロパティの解説や記述例。

間違いから学ぶSPFレコードの正しい書き方 : 迷惑メール対策委員会
SPFレコードを設定する際に間違いやすい例を参考に解説。


Filed under: postfix,メモ

Trackback Uri






2013年 11月 1

Apache2.2にmod_SpeedyCGIを組込むにはパッチが必要

で以前やったんだけどイマイチ手順がまとまっていないので。

ポイント
  • 作業ディレクトリは /root/src
  • httpd-develが必要
  • rootで作業した方が楽

1. Apacheインストール

$ su -
# yum install httpd httpd-devel

※ apxs が必要になるので httpd-devel をインストールすること

2. Speedy_CGIをダウンロードしてパッチを当てる

# cd /root/src
# wget http://daemoninc.com/SpeedyCGI/CGI-SpeedyCGI-2.22.tar.gz
# tar zxvf CGI-SpeedyCGI-2.22.tar.gz
# cd CGI-SpeedyCGI-2.22/mod_speedycgi2
# wget http://sourceforge.net/p/speedycgi/patches/_discuss/thread/f3ff7350/afa5/attachment/patch-mod_speedycgi2.c
# patch -p1 < patch-mod_speedycgi2.c

※ 参考ページにはパッチファイルをFTPでアップロードする必要があると書いてあるけどwgetで出来た。
パッチ公開ページ

3. Speedy_CGIインストール

# perl Makefile.PL
# make install
〜〜〜 コンパイル中 〜〜〜
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/lib/httpd/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
chmod 755 /usr/lib/httpd/modules/mod_speedycgi.so
[activating module `speedycgi' in /etc/httpd/conf/httpd.conf]
超参考:

Filed under: Apache,インストールメモ

Trackback Uri






2013年 6月 2

### インストール
ビルドにそこそこ時間がかかる。6時間なんてエントリーもあったけどそんなにかからなかった。15-20分位?環境はMacBookPro Retina, 13-inch, Early 2013。他のエントリーでは依存問題が…的なのがあったけど、特に問題がなかった。

$ sudo port install mongodb
Warning: port definitions are more than two weeks old, consider using selfupdate
--->  Cleaning bzip2
--->  Unable to uninstall bzip2 @1.0.6_0, the following ports depend on it:
--->  	pcre @8.12_1
--->  	python27 @2.7.2_2
--->  	freetype @2.4.9_1
--->  	php5 @5.3.10_0+apache2
Warning: Uninstall forced.  Proceeding despite dependencies.
--->  Deactivating bzip2 @1.0.6_0
--->  Unable to deactivate bzip2 @1.0.6_0, the following ports depend on it:
--->  	pcre @8.12_1
--->  	python27 @2.7.2_2
--->  	freetype @2.4.9_1
--->  	php5 @5.3.10_0+apache2
Warning: Deactivate forced.  Proceeding despite dependencies.
--->  Cleaning bzip2
--->  Uninstalling bzip2 @1.0.6_0
--->  Cleaning bzip2
--->  Fetching archive for bzip2
--->  Attempting to fetch bzip2-1.0.6_0.darwin_12.x86_64.tbz2 from http://packages.macports.org/bzip2
--->  Attempting to fetch bzip2-1.0.6_0.darwin_12.x86_64.tbz2.rmd160 from http://packages.macports.org/bzip2
--->  Installing bzip2 @1.0.6_0
--->  Activating bzip2 @1.0.6_0
--->  Cleaning bzip2
--->  Computing dependencies for libedit
--->  Fetching archive for libedit
--->  Attempting to fetch libedit-20121213-3.0_0.darwin_12.x86_64.tbz2 from http://packages.macports.org/libedit
--->  Attempting to fetch libedit-20121213-3.0_0.darwin_12.x86_64.tbz2.rmd160 from http://packages.macports.org/libedit
--->  Installing libedit @20121213-3.0_0
--->  Cleaning libedit
--->  Computing dependencies for libedit
--->  Deactivating libedit @20110802-3.0_0
--->  Cleaning libedit
--->  Activating libedit @20121213-3.0_0
--->  Cleaning libedit
--->  Computing dependencies for pcre
--->  Fetching archive for pcre
--->  Attempting to fetch pcre-8.32_1.darwin_12.x86_64.tbz2 from http://packages.macports.org/pcre
--->  Attempting to fetch pcre-8.32_1.darwin_12.x86_64.tbz2.rmd160 from http://packages.macports.org/pcre
--->  Installing pcre @8.32_1
--->  Cleaning pcre
--->  Computing dependencies for pcre
--->  Deactivating pcre @8.12_1
--->  Cleaning pcre
--->  Activating pcre @8.32_1
--->  Cleaning pcre
--->  Computing dependencies for mongodb
--->  Dependencies to be installed: libpcap scons snappy v8
--->  Fetching archive for libpcap
--->  Attempting to fetch libpcap-1.3.0_0.darwin_12.x86_64.tbz2 from http://packages.macports.org/libpcap
--->  Attempting to fetch libpcap-1.3.0_0.darwin_12.x86_64.tbz2.rmd160 from http://packages.macports.org/libpcap
--->  Installing libpcap @1.3.0_0
--->  Activating libpcap @1.3.0_0
--->  Cleaning libpcap
--->  Fetching archive for scons
--->  Attempting to fetch scons-2.2.0_0.darwin_12.noarch.tbz2 from http://packages.macports.org/scons
--->  Attempting to fetch scons-2.2.0_0.darwin_12.noarch.tbz2.rmd160 from http://packages.macports.org/scons
--->  Installing scons @2.2.0_0
--->  Activating scons @2.2.0_0
--->  Cleaning scons
--->  Fetching archive for snappy
--->  Attempting to fetch snappy-1.0.5_0.darwin_12.x86_64.tbz2 from http://packages.macports.org/snappy
--->  Attempting to fetch snappy-1.0.5_0.darwin_12.x86_64.tbz2.rmd160 from http://packages.macports.org/snappy
--->  Installing snappy @1.0.5_0
--->  Activating snappy @1.0.5_0
--->  Cleaning snappy
--->  Fetching archive for v8
--->  Attempting to fetch v8-3.17.15_0.darwin_12.x86_64.tbz2 from http://packages.macports.org/v8
--->  Attempting to fetch v8-3.17.15_0.darwin_12.x86_64.tbz2.rmd160 from http://packages.macports.org/v8
--->  Installing v8 @3.17.15_0
--->  Activating v8 @3.17.15_0
--->  Cleaning v8
--->  Fetching archive for mongodb
--->  Attempting to fetch mongodb-2.4.1_0.darwin_12.x86_64.tbz2 from http://packages.macports.org/mongodb
--->  Attempting to fetch mongodb-2.4.1_0.darwin_12.x86_64.tbz2 from http://jog.id.packages.macports.org/macports/packages/mongodb
--->  Attempting to fetch mongodb-2.4.1_0.darwin_12.x86_64.tbz2 from http://mse.uk.packages.macports.org/sites/packages.macports.org/mongodb
--->  Fetching distfiles for mongodb
--->  Attempting to fetch mongodb-src-r2.4.1.tar.gz from http://distfiles.macports.org/mongodb
--->  Verifying checksum(s) for mongodb
--->  Extracting mongodb
--->  Applying patches to mongodb
--->  Configuring mongodb
--->  Building mongodb
--->  Staging mongodb into destroot
--->  Creating launchd control script
###########################################################
# A startup item has been generated that will aid in
# starting mongodb with launchd. It is disabled
# by default. Execute the following command to start it,
# and to cause it to launch at startup:
#
# sudo port load mongodb
###########################################################
--->  Installing mongodb @2.4.1_0
--->  Activating mongodb @2.4.1_0
--->  Cleaning mongodb
--->  Updating database of binaries: 100.0%
--->  Scanning binaries for linking errors: 100.0%
--->  Found 137 broken file(s), matching files to ports
--->  Found 3 broken port(s), determining rebuild order
--->  Rebuilding in order
     apache2 @2.2.22 +preforkmpm
     git-core @1.7.7.2 +doc+pcre+python27
     php5 @5.3.10 +apache2
--->  Computing dependencies for apache2
--->  Fetching archive for apache2
--->  Attempting to fetch apache2-2.2.24_0+preforkmpm.darwin_12.x86_64.tbz2 from http://packages.macports.org/apache2
--->  Attempting to fetch apache2-2.2.24_0+preforkmpm.darwin_12.x86_64.tbz2.rmd160 from http://packages.macports.org/apache2
--->  Installing apache2 @2.2.24_0+preforkmpm
--->  Cleaning apache2
--->  Computing dependencies for apache2
--->  Deactivating apache2 @2.2.22_1+preforkmpm
--->  Cleaning apache2
--->  Activating apache2 @2.2.24_0+preforkmpm
--->  Cleaning apache2
--->  Computing dependencies for git-core
--->  Dependencies to be installed: p5.12-term-readkey
--->  Fetching archive for p5.12-term-readkey
--->  Attempting to fetch p5.12-term-readkey-2.300.0_3.darwin_12.x86_64.tbz2 from http://packages.macports.org/p5.12-term-readkey
--->  Attempting to fetch p5.12-term-readkey-2.300.0_3.darwin_12.x86_64.tbz2.rmd160 from http://packages.macports.org/p5.12-term-readkey
--->  Installing p5.12-term-readkey @2.300.0_3
--->  Activating p5.12-term-readkey @2.300.0_3
--->  Cleaning p5.12-term-readkey
--->  Fetching archive for git-core
--->  Attempting to fetch git-core-1.8.2.1_0+credential_osxkeychain+doc+pcre+python27.darwin_12.x86_64.tbz2 from http://packages.macports.org/git-core
--->  Attempting to fetch git-core-1.8.2.1_0+credential_osxkeychain+doc+pcre+python27.darwin_12.x86_64.tbz2 from http://jog.id.packages.macports.org/macports/packages/git-core
--->  Attempting to fetch git-core-1.8.2.1_0+credential_osxkeychain+doc+pcre+python27.darwin_12.x86_64.tbz2 from http://mse.uk.packages.macports.org/sites/packages.macports.org/git-core
--->  Fetching distfiles for git-core
--->  Attempting to fetch git-1.8.2.1.tar.gz from http://git-core.googlecode.com/files/
--->  Attempting to fetch git-manpages-1.8.2.1.tar.gz from http://git-core.googlecode.com/files/
--->  Attempting to fetch git-htmldocs-1.8.2.1.tar.gz from http://git-core.googlecode.com/files/
--->  Verifying checksum(s) for git-core
--->  Extracting git-core
--->  Applying patches to git-core
--->  Configuring git-core
--->  Building git-core
--->  Staging git-core into destroot
--->  Installing git-core @1.8.2.1_0+credential_osxkeychain+doc+pcre+python27
--->  Cleaning git-core
--->  Computing dependencies for git-core
--->  Deactivating git-core @1.7.7.2_0+doc+pcre+python27
--->  Cleaning git-core
--->  Activating git-core @1.8.2.1_0+credential_osxkeychain+doc+pcre+python27
--->  Cleaning git-core
--->  Computing dependencies for php5
--->  Fetching archive for php5
--->  Attempting to fetch php5-5.3.23_0+apache2.darwin_12.x86_64.tbz2 from http://packages.macports.org/php5
--->  Attempting to fetch php5-5.3.23_0+apache2.darwin_12.x86_64.tbz2 from http://jog.id.packages.macports.org/macports/packages/php5
--->  Attempting to fetch php5-5.3.23_0+apache2.darwin_12.x86_64.tbz2 from http://mse.uk.packages.macports.org/sites/packages.macports.org/php5
--->  Fetching distfiles for php5
--->  Attempting to fetch php-5.3.23.tar.bz2 from http://jp.php.net/get/php-5.3.23.tar.bz2/from/this/mirror?dummy=
--->  Verifying checksum(s) for php5
--->  Extracting php5
--->  Applying patches to php5
--->  Configuring php5
Error: org.macports.configure for port php5 returned: configure failure: command execution failed
Please see the log file for port php5 for details:
    /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_lang_php5/php5/main.log
Error: Unable to upgrade port: 1
Error rebuilding php5
    while executing
"error "Error rebuilding $portname""
    (procedure "revupgrade_scanandrebuild" line 382)
    invoked from within
"revupgrade_scanandrebuild broken_port_counts $opts"
    (procedure "macports::revupgrade" line 5)
    invoked from within
"macports::revupgrade $opts"
    (procedure "action_revupgrade" line 2)
    invoked from within
"action_revupgrade $action $portlist $opts"
    (procedure "action_target" line 94)
    invoked from within
"$action_proc $action $portlist [array get global_options]"
    (procedure "process_cmd" line 95)
    invoked from within
"process_cmd $remaining_args"
    invoked from within
"if { [llength $remaining_args] > 0 } {

    # If there are remaining arguments, process those as a command
    set exit_status [process_cmd $remaining..."
    (file "/opt/local/bin/port" line 4785)
$ sudo port load mongodb

で起動時にデーモンが立ち上がるようになるみたい。

### mongodbデーモン起動

mongod でデーモン起動。

$ mongod
mongod --help for help and startup options
Sun Jun  2 09:11:40.248 [initandlisten] MongoDB starting : pid=28245 port=27017 dbpath=/data/db/ 64-bit host=clicktx-MBP.local
Sun Jun  2 09:11:40.248 [initandlisten] 
Sun Jun  2 09:11:40.248 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
Sun Jun  2 09:11:40.249 [initandlisten] db version v2.4.1
Sun Jun  2 09:11:40.249 [initandlisten] git version: nogitversion
Sun Jun  2 09:11:40.249 [initandlisten] build info: Darwin clicktx-MBP.local 12.3.0 Darwin Kernel Version 12.3.0: Sun Jan  6 22:37:10 PST 2013; root:xnu-2050.22.13~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
Sun Jun  2 09:11:40.249 [initandlisten] allocator: tcmalloc
Sun Jun  2 09:11:40.249 [initandlisten] options: {}
Sun Jun  2 09:11:40.249 [initandlisten] exception in initAndListen: 10296 
*********************************************************************
 ERROR: dbpath (/data/db/) does not exist.
 Create this directory or give existing directory in --dbpath.
 See http://dochub.mongodb.org/core/startingandstoppingmongo
*********************************************************************
, terminating
Sun Jun  2 09:11:40.249 dbexit: 
Sun Jun  2 09:11:40.249 [initandlisten] shutdown: going to close listening sockets...
Sun Jun  2 09:11:40.249 [initandlisten] shutdown: going to flush diaglog...
Sun Jun  2 09:11:40.249 [initandlisten] shutdown: going to close sockets...
Sun Jun  2 09:11:40.249 [initandlisten] shutdown: waiting for fs preallocator...
Sun Jun  2 09:11:40.249 [initandlisten] shutdown: lock for final commit...
Sun Jun  2 09:11:40.249 [initandlisten] shutdown: final commit...
Sun Jun  2 09:11:40.249 [initandlisten] shutdown: closing all files...
Sun Jun  2 09:11:40.249 [initandlisten] closeAllFiles() finished
Sun Jun  2 09:11:40.249 dbexit: really exiting now

データベースのディレクトリがないみたい。

### mongodbシェルを使う

$ mongo
MongoDB shell version: 2.4.1
connecting to: test
> 

tabでコマンドの補完やカーソルキーで履歴の表示など出来る。

### チュートリアルを試してみる

[MongoDBの薄い本(The Little MongoDB Book) – cuspy diary](http://www.cuspy.org/diary/2012-04-17)


Filed under: Mac,MongoDB,インストールメモ

Trackback Uri






2013年 5月 19

Linodeのマニュアルにはiptablesの設定の仕方とか書いてあって親切。

Linode – Creating a Firewall

ルールの作成
vi /etc/iptables.firewall.rules

*filter

#  Allow all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0
-A INPUT -i lo -j ACCEPT
-A INPUT -d 127.0.0.0/8 -j REJECT

#  Accept all established inbound connections
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

#  Allow all outbound traffic - you can modify this to only allow certain traffic
-A OUTPUT -j ACCEPT

#  Allow HTTP and HTTPS connections from anywhere (the normal ports for websites and SSL).
-A INPUT -p tcp --dport 80 -j ACCEPT
-A INPUT -p tcp --dport 443 -j ACCEPT

#  Allow SSH connections
#
#  The -dport number should be the same port number you set in sshd_config
#
-A INPUT -p tcp -m state --state NEW --dport 22 -j ACCEPT

#  Allow ping
-A INPUT -p icmp -j ACCEPT

#  Log iptables denied calls
-A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7

#  Drop all other inbound - default deny unless explicitly allowed policy
-A INPUT -j DROP
-A FORWARD -j DROP

COMMIT
ルールの適用
sudo iptables-restore < /etc/iptables.firewall.rules
ルールの確認
sudo iptables -nL
ルールの保存

CentOS6.2以上の場合は

/sbin/service iptables save

Filed under: メモ

Trackback Uri