<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>yupmin&#039;s another space</title>
	<atom:link href="http://yupmin.net/feed" rel="self" type="application/rss+xml" />
	<link>http://yupmin.net</link>
	<description>developer&#039;s note</description>
	<lastBuildDate>Wed, 18 Jan 2012 02:59:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>using SimpleDB CLI</title>
		<link>http://yupmin.net/using-simpledb-cli</link>
		<comments>http://yupmin.net/using-simpledb-cli#comments</comments>
		<pubDate>Tue, 17 Jan 2012 06:00:04 +0000</pubDate>
		<dc:creator>yupmin</dc:creator>
				<category><![CDATA[AWS]]></category>
		<category><![CDATA[aws]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[simpledb]]></category>

		<guid isPermaLink="false">http://yupmin.net/?p=565</guid>
		<description><![CDATA[case : amazon linux ami http://aws.amazon.com/code/1136 http://code.google.com/p/amazon-simpledb-cli/ sudo yum install autoconf automake libtool make sudo yum install perl-CPAN perl-YAML sudo yum install openssl-devel sudo yum install perl-Digest-SHA perl-XML-Simple perl-Digest-SHA1 perl-Digest-HMAC perl-Time-HiRes sudo perl -MCPAN -e 'install Bundle::LWP' wget http://aws-libraries.s3.amazonaws.com/perl/AmazonSimpleDB/2009-04-15/AmazonSimpleDB-2009-04-15-perl-library.zip unzip AmazonSimpleDB-2009-04-15-perl-library.zip &#8230; <a href="http://yupmin.net/using-simpledb-cli">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>case : amazon linux ami</strong></p>
<p><a href="http://aws.amazon.com/code/1136">http://aws.amazon.com/code/1136</a><br />
<a href="http://code.google.com/p/amazon-simpledb-cli/">http://code.google.com/p/amazon-simpledb-cli/</a></p>
<pre>sudo yum install autoconf automake libtool make
sudo yum install perl-CPAN perl-YAML
sudo yum install openssl-devel
sudo yum install perl-Digest-SHA perl-XML-Simple perl-Digest-SHA1 perl-Digest-HMAC perl-Time-HiRes
sudo perl -MCPAN -e 'install Bundle::LWP'

wget http://aws-libraries.s3.amazonaws.com/perl/AmazonSimpleDB/2009-04-15/AmazonSimpleDB-2009-04-15-perl-library.zip
unzip AmazonSimpleDB-2009-04-15-perl-library.zip
sitelib=$(perl -MConfig -le 'print $Config{sitelib}')
sudo scp -r AmazonSimpleDB-*-perl-library/src/Amazon $sitelib

sudo curl -Lo /usr/local/bin/simpledb http://simpledb-cli.notlong.com
sudo chmod +x /usr/local/bin/simpledb</pre>
<p>몇가지 테스트를 해보자</p>
<pre>simpledb create-domain snapshot
simpledb list-domains
simpledb put snapshot test test='abc'
simpledb select "SELECT * FROM snapshot"
simpledb delete snapshot test
simpledb select "SELECT * FROM snapshot"</pre>
]]></content:encoded>
			<wfw:commentRss>http://yupmin.net/using-simpledb-cli/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>starting with AWS EC2 part 1</title>
		<link>http://yupmin.net/starting-with-aws-ec2-part-1</link>
		<comments>http://yupmin.net/starting-with-aws-ec2-part-1#comments</comments>
		<pubDate>Wed, 21 Dec 2011 14:38:43 +0000</pubDate>
		<dc:creator>yupmin</dc:creator>
				<category><![CDATA[AWS]]></category>
		<category><![CDATA[aws]]></category>
		<category><![CDATA[ec2]]></category>

		<guid isPermaLink="false">http://yupmin.net/?p=465</guid>
		<description><![CDATA[AWS(Amazon Web Service)를 사용하게 되면 일단 가입한지 일년동안은 AWS Free Usage Tier 로 1 Linux Micro Instance, ELB, EBS 10G, S3, SimpleDB, SQS등 무료로 사용이 가능하다. EC2를 만들어 사용하기 전에 EC2에서 사용하는 storage 개념부터 이해해야 한다. 일종의 하드 디스크의 개념인 &#8230; <a href="http://yupmin.net/starting-with-aws-ec2-part-1">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://yupmin.net/wp-content/uploads/2011/11/logo_aws.gif" rel="lightbox[465]"><img class="aligncenter size-full wp-image-508" title="logo_aws" src="http://yupmin.net/wp-content/uploads/2011/11/logo_aws.gif" alt="" width="164" height="60" /></a></p>
<p>AWS(Amazon Web Service)를 사용하게 되면 일단 가입한지 일년동안은 <a href="http://aws.amazon.com/free/">AWS Free Usage Tier</a> 로 1 Linux Micro Instance, ELB, EBS 10G, S3, SimpleDB, SQS등 무료로 사용이 가능하다.</p>
<p>EC2를 만들어 사용하기 전에 EC2에서 사용하는 storage 개념부터 이해해야 한다.</p>
<p>일종의 하드 디스크의 개념인 AMI(Amazon Machine Images)를 이용해서 서버를 런칭하게 되는데, AMI는 두가지 Storage 종류가 있다. EBS-backed storage device 와 S3-backed storage device인 ephemeral storage(하루살이 목숨의?) 로 두가지다.</p>
<p>보통 micro instance가 아닌 Small, Medium, Large 등으로 좀 많은 돈이 들어 만드는 instance에 들어가는 storage는 S3-backed storage를 사용하게 된다. 이 S3-backed storage는 EBS보다 빠르나 instance가 정지(stop)되거나 종료(terminate)되면 storage의 내용은 날라가게 됩니다.(그 서버는 restart만 가능하게 되는 것이다.) 그러니 일단 그런 storage를 사용하게 되면 주의해야 한다. 단 S3-backed storage로 AMI를 만들게 되면 S3를 이용해서 다른곳으로 이동할수 있다고 한다.</p>
<p>어떤 서비스 조합으로 이용할것인가는 대해서는 고민좀 해봐야 한다. Free Usage Tier 일 경우 1년동안 EBS Volume을 10G를 사용할수 있다. 일단 Micro Linux Instance + 10G EBS Volume을 사용해 보겠다.</p>
<p>나의 경우에는 ubuntu ami보다 amazon linux ami를 선호하는데, 이유는 ubuntu ami의 경우 가끔씩 리부팅시(극히 낮은 빈도지만, 직접 경험해봤다. 경험적 판단임을 밝혀둔다. aws console에서는 분명 제대로 돌아가고 있는데 ssh 접근이 안된다. 다시 한번 밝히건데, 이러한 이유가 ubuntu ami라는 확신은 없다.) hang이 걸리기 때문이다.</p>
<p>AWS(<a href="http://aws.amazon.com/">http://aws.amazon.com/</a>)에 접속해서 계정을 만들어라. 신용카드 사용에 대한 좀 복잡한 과정이 있음에 유의하자.</p>
<p>그리고 그 과정이 끝났으면 AWS Management Console (<a href="https://console.aws.amazon.com">https://console.aws.amazon.com</a>) 로 해서 EC2 탭으로 들어간다. [Launch Instance]를 눌러서 Basic 32-bit Amazon Linux AMI를 선택해서 일단 생성한다. 대부분 기본 옵션을 선택하면 되는데, 생성시 미리 Security Group 과 Key Pairs 메뉴를 클릭해서 각각 셋팅을 해두는 게 좋다. 생성시 region을 정확히 확인해 둔다.</p>
<p>Security Group 은 일종의 방화벽으로 외부에서 EC2안으로의 접근 및 port forward 등이 가능하다. &#8216;default&#8217; 라고 있는데, 처음이라면 일단 &#8216;default&#8217; Security Group를 사용해서 서비스를 이용하면 된다. 만일 ssh 접근이 안된다면 SSH Rule을 추가하여 접근하면 된다.</p>
<p>Key Pairs 는 서버에 접근하는 SSH 키 생성/import를 할수 있다. 자신이 원래 쓰던 ssh key가 있다면 등록도 가능하니 일단 등록시 두면 된다.</p>
<p>Unix 콘솔이 있다면 다음과 같이 로그인 한후 기본 업데이트를 실행한다.</p>
<pre class="brush: shell;">ssh -i keypair-xxxx.pem ec2-user@xxx.xxx
sudo yum update</pre>
<p>일단 로그인까지 완료가 되면 AWS 사용 가능한 상태가 된다.</p>
<p>EBS Volume 을 연결하기 위해선 다음과 같이 한다. 콘솔(<a href="https://console.aws.amazon.com">https://console.aws.amazon.com</a>)에 로그인을 해서 Elastic Block Store 메뉴에서 EBS Volume 10G를 만들어주고, [Attach Volume]을 한다.(단 생성시 AMI 랑 같은 region에 만들어야 한다.) 일단 device path를 확인한다. (대부분 /dev/sdf이다.)</p>
<pre class="brush: shell;">sudo mkfs.ext4 /dev/sdf
sudo mount -t ext4 /dev/sdf /mnt
vi /etc/fstab

/dev/sdf    /mnt        ext4    defaults        0   0</pre>
<p>그리고 EBS 볼륨이 아닌 Ephemeral Storage Volume을 사용하는 인스턴스를 사용하기 위해선 약간 더 복잡한 단계를 거쳐야 한다. Amazon Linux AMI로 small이상의 인스턴스를 생성하면 볼륨이 안붙은체로 나온다.</p>
<p>일단 이렇게 인스턴스를 생성하기 전에 몇가지 준비를 해야 한다.</p>
<p>생성 방식이 좀 까다로운데 command line developertools을 사용해야 한다. command line developertools 을 사용하기 위해선 인증서를 만들어야 하는데, My Account &gt; Security Credentials 로 가서 중간에 [X.509 Certificate] 탭을 눌러서 인증서와 키를 각각 다운 받아 둔다. 그 인증서와 키를 나의 Desktop 이던 사용하는 서버에 저장한다. 그리고 편의성을 위해 keypair name 등도 같이 저장하는게 편하다. (데스크탑이나 다른 서버를 이용할시 <a href="http://aws.amazon.com/developertools/351">http://aws.amazon.com/developertools/351</a> 툴을 다운 받아서 사용해야 한다. 자세한 설명은 <a href="https://help.ubuntu.com/community/EC2StartersGuide">https://help.ubuntu.com/community/EC2StartersGuide</a> 를 참조한다.)</p>
<pre class="brush: shell;">mkdir ~/.ec2
chmod 700 ~/.ec2
mv cert-xxxx.pem ~/.ec2
mv pk-xxx.pem ~/.ec2
mv keypair-xxx.pem ~/.ec2
chmod 600 ~/.ec2/*.pem
vi ~/.bashrc

export EC2_KEYPAIR=keypair-xxx	# keypair!, name only, not the file name
export EC2_PRIVATE_KEY=~/.ec2/pk-xxxx.pem
export EC2_CERT=~/.ec2/cert-xxxx.pem
export EC2_URL=https://ec2.ap-northeast-1.amazonaws.com # region which you are using

# test
ec2-describe-keypairs

# run-instance
ec2-run-instances ami-xxxxx --block-device-mapping '/dev/sda2=ephemeral0' --block-device-mapping '/dev/sda3=ephemeral1' -k kyepair-xxx
-z ap-northeast-1</pre>
<p>여기서 ephemeral0 은 swap 을 ephemeral1은 추가 드라이브를 말한다.</p>
<p>일단 기본적인 서버 사용까지를 적어봤다. part2에서는 몇가지 서비스를 깔아보면서 진행을 해보겠다. 좀더 볼만한 사이트로는 다음의 사이트가 있다. <a href="http://paulstamatiou.com/how-to-getting-started-with-amazon-ec2">http://paulstamatiou.com/how-to-getting-started-with-amazon-ec2</a></p>
]]></content:encoded>
			<wfw:commentRss>http://yupmin.net/starting-with-aws-ec2-part-1/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>install memcached</title>
		<link>http://yupmin.net/install-memcached</link>
		<comments>http://yupmin.net/install-memcached#comments</comments>
		<pubDate>Wed, 19 Oct 2011 01:54:43 +0000</pubDate>
		<dc:creator>yupmin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://yupmin.net/?p=96</guid>
		<description><![CDATA[아 Memcached 홈페이지 배너가 너무 Geek(덕스럽) 하다. 이 포스트가 이 블로그에서 제일 많이 들어오는 거리 중 하나라서 기념 배너를 추가해봤다. case centos 일단centos 배포본에는 memcached가 없다 그래서 소스컴파일로 설치한다.(root로 가정) yum install libevent libevent-devel wget http://memcached.googlecode.com/files/memcached-1.4.9.tar.gz tar -xvzf memcached-1.4.9.tar.gz cd &#8230; <a href="http://yupmin.net/install-memcached">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://yupmin.net/wp-content/uploads/2010/08/memcached_banner75.jpg" rel="lightbox[96]"><img class="aligncenter size-full wp-image-471" title="memcached_banner75" src="http://yupmin.net/wp-content/uploads/2010/08/memcached_banner75.jpg" alt="" width="785" height="145" /></a></p>
<p>아 <a href="http://memcached.org/">Memcached 홈페이지</a> 배너가 너무 Geek(덕스럽) 하다. 이 포스트가 이 블로그에서 제일 많이 들어오는 거리 중 하나라서 기념 배너를 추가해봤다.</p>
<p><strong>case centos</strong><br />
일단centos 배포본에는 memcached가 없다 그래서 소스컴파일로 설치한다.(root로 가정)</p>
<pre class="brush: shell;">yum install libevent libevent-devel
wget http://memcached.googlecode.com/files/memcached-1.4.9.tar.gz
tar -xvzf memcached-1.4.9.tar.gz
cd memcached-1.4.9
./configure --with-libevent=/usr/lib/
make; make install</pre>
<p>기본 설정 파일도 만들어주자.</p>
<pre class="brush: shell;">vi /etc/memcached.conf
#Memory a usar
-m 16
# default port
-p 11211
# user to run daemon nobody/apache/www-data
-u nobody
# only listen locally
-l 127.0.0.1</pre>
<p>init script 도 생성해준다. 참조 사이트</p>
<ul>
<li><a href="http://www.vbseo.com/blogs/danny-bembibre/daemon-scripts-memcached-44/" target="_self">http://www.vbseo.com/blogs/danny-bembibre/daemon-scripts-memcached-44/</a></li>
<li><a href="http://www.dev411.com/wiki/Memcached_startup_files_for_Red_Hat_%28RHEL%29" target="_self">http://www.dev411.com/wiki/Memcached_startup_files_for_Red_Hat_%28RHEL%29</a></li>
</ul>
<p>일단 만들어 놓은 스크립트가 있으니 다운받아 사용도록 하자</p>
<p>memcached init script downlod : <a href="http://yupmin.net/wp-content/uploads/2010/08/memcached_script.tar.gz">memcached_script.tar.gz</a></p>
<pre class="brush: shell;">wget http://yupmin.net/wp-content/uploads/2010/08/memcached_script.tar.gz
tar xvfz memcached_script.tar.gz
mv start-memcached /usr/local/bin/start-memcached
mv memcached /etc/init.d/memcached
chmod 755 /usr/local/bin/start-memcached
chmod 755 /etc/init.d/memcached</pre>
<p><strong>case ubuntu</strong></p>
<p>유분투에는 쉽게 설치 패키지가 준비되어있다.(root로 가정)</p>
<pre class="brush: shell;">apt-get install memcached
service memcached start</pre>
<p><strong>case centos</strong></p>
<p>memcached php 관련 패키지는 centos에 있다.</p>
<pre class="brush: shell;">yum install php-pecl-memcache</pre>
<p>혹은  php버젼이 업데이트 되거나 몇가지 안되는 경우가 있다 이럴땐 직접 컴파일한다.</p>
<pre class="brush: shell;">wget http://pecl.php.net/get/memcache-2.2.5.tgz
tar xvfz memcache-2.2.5.tgz
cd memcache-2.2.5
phpize
./configure --enable-memcache
make
cp modules/memcache.so /usr/lib/php/modules</pre>
<p>php에 모듈을 셋팅해주자.</p>
<pre class="brush: shell;">vi /etc/php.d/memcache.ini
extension=memcache.so</pre>
<p>memcached php test : <a href="http://dorkage.net/2009/02/memcached-test/" target="_blank">http://dorkage.net/2009/02/memcached-test/</a></p>
<p>이외에 또한 memcache php 모듈과 다르게 memcached php모듈이 있는데 필요하면 깔아둔다.</p>
<p>참조 : <a href="http://libmemcached.org">http://libmemcached.org</a> <a href="http://pecl.php.net/package/memcached">http://pecl.php.net/package/memcached</a></p>
<pre class="brush: shell;">wget http://launchpad.net/libmemcached/1.0/0.53/+download/libmemcached-0.53.tar.gz
./configre
make; make install

wget http://pecl.php.net/get/memcached-2.0.0b2.tgz
tar xvfz memcached-2.0.0b2.tgz
cd memcached-2.0.0b2
phpize
./configure --with-libmemcached-dir=/usr/local/lib/
make; make install

vi /etc/php.d/memached.ini

extension=memcached.so</pre>
<p>A quick way to get memcached status : <a href="http://www.mysqlperformanceblog.com/2008/11/26/a-quick-way-to-get-memcached-status/" rel="bookmark">http://www.mysqlperformanceblog.com/2008/11/26/a-quick-way-to-get-memcached-status/</a></p>
<pre class="brush: shell;">watch "echo stats | nc 127.0.0.1 11211"</pre>
<p>mysql 컨퍼런스에서 한 외국인 강사가 발표했던 키노트 : <a href="http://download.tangent.org/talks/Memcached%20Study.pdf">http://download.tangent.org/talks/Memcached%20Study.pdf</a></p>
]]></content:encoded>
			<wfw:commentRss>http://yupmin.net/install-memcached/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>install mercurial with nginx</title>
		<link>http://yupmin.net/install-mercurial-with-nginx</link>
		<comments>http://yupmin.net/install-mercurial-with-nginx#comments</comments>
		<pubDate>Sun, 16 Oct 2011 05:29:42 +0000</pubDate>
		<dc:creator>yupmin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[aws]]></category>
		<category><![CDATA[mercurial]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://yupmin.net/?p=443</guid>
		<description><![CDATA[개발을 할때면 간단히 형상관리를 할수 있는 개인만의 repository를 가지고 싶어지는데, AWS 상에서 nginx서버를 이용해서 간단한 mercurial web repository 를 구성해보았다. soruce url : http://geeksharp.com/2010/01/20/mercurial-web-with-fastcgi-nginx/ http://mercurial.selenic.com/wiki/HgWebDirStepByStep case : ubuntu(on aws) apt-get install nginx mercurial python-flup spawn-fcgi mkdir /var/www/hg chown ubuntu:www-data /var/www/hg case : &#8230; <a href="http://yupmin.net/install-mercurial-with-nginx">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>개발을 할때면 간단히 형상관리를 할수 있는 개인만의 repository를 가지고 싶어지는데, AWS 상에서 nginx서버를 이용해서 간단한 mercurial web repository 를 구성해보았다.</p>
<p>soruce url : <a href="http://geeksharp.com/2010/01/20/mercurial-web-with-fastcgi-nginx/">http://geeksharp.com/2010/01/20/mercurial-web-with-fastcgi-nginx/</a> <a href="http://mercurial.selenic.com/wiki/HgWebDirStepByStep">http://mercurial.selenic.com/wiki/HgWebDirStepByStep</a></p>
<p><strong>case</strong> : ubuntu(on aws)</p>
<pre class="brush: shell;">apt-get install nginx mercurial python-flup spawn-fcgi</pre>
<pre class="brush: shell;">mkdir /var/www/hg
chown ubuntu:www-data /var/www/hg</pre>
<p><strong>case</strong> : amazon linux ami(on aws)</p>
<pre class="brush: shell;">sudo yum install nginx spawn-fcgi mercurial
sudo easy_install flup</pre>
<pre class="brush: shell;">mkdir /var/www/hg
chown ec2-user:nginx /var/www/hg</pre>
<p>nginx를 ubuntu, yum 기본패키지를 깔수도 있고, 최신 stable 버젼으로 깔수도(<a href="http://wiki.nginx.org/Install">http://wiki.nginx.org/Install</a>) 있다.</p>
<pre class="brush: shell;">vi /var/www/hg/hgwebdir.fcgi

#!/usr/bin/env python
#
# An example CGI script to export multiple hgweb repos, edit as necessary

# adjust python path if not a system-wide install:
#import sys
#sys.path.insert(0, "/path/to/python/lib")

# enable demandloading to reduce startup time
from mercurial import demandimport; demandimport.enable()

# Uncomment to send python tracebacks to the browser if an error occurs:
#import cgitb
#cgitb.enable()

# If you'd like to serve pages with UTF-8 instead of your default
# locale charset, you can do so by uncommenting the following lines.
# Note that this will cause your .hgrc files to be interpreted in
# UTF-8 and all your repo files to be displayed using UTF-8.
#
import os
os.environ["HGENCODING"] = "UTF-8"

from mercurial.hgweb.hgwebdir_mod import hgwebdir
from flup.server.fcgi import WSGIServer

# The config file looks like this. You can have paths to individual
# repos, collections of repos in a directory tree, or both.
#
# [paths]
# virtual/path1 = /real/path1
# virtual/path2 = /real/path2
# virtual/root = /real/root/*
# / = /real/root2/*
#
# [collections]
# /prefix/to/strip/off = /root/of/tree/full/of/repos
#
# paths example:
#
# * First two lines mount one repository into one virtual path, like
# '/real/path1' into 'virtual/path1'.
#
# * The third entry tells every mercurial repository found in
# '/real/root', recursively, should be mounted in 'virtual/root'. This
# format is preferred over the [collections] one, using absolute paths
# as configuration keys is not supported on every platform (including
# Windows).
#
# * The last entry is a special case mounting all repositories in
# '/real/root2' in the root of the virtual directory.
#
# collections example: say directory tree /foo contains repos /foo/bar,
# /foo/quux/baz. Give this config section:
# [collections]
# /foo = /foo
# Then repos will list as bar and quux/baz.
#
# Alternatively you can pass a list of ('virtual/path', '/real/path') tuples
# or use a dictionary with entries like 'virtual/path': '/real/path'

WSGIServer(hgwebdir('/var/www/hg/hgweb.config')).run()</pre>
<pre class="brush: shell;">sudo chmod ug+x /var/www/hg/hgwebdir.fcgi</pre>
<p>WSGI 서버를 만들수 있도록 한다.</p>
<pre class="brush: shell;">vi /var/www/hg/hgweb.config

[web]
baseurl = /
allow_push = *
push_ssl = false

[paths]
/ = /var/www/hg/*</pre>
<p>WSGI 서버에서 레포지토리 연결할수 있도록 설정 파일을 설정해준다.</p>
<pre class="brush: shell;">perl -le 'print crypt("[your-password]", "salt-hash")'
vi /var/www/hg/hgusers.config

username:encrypted-password:comment</pre>
<p>접근 암호도 설정해준다.</p>
<pre class="brush: shell;">vi /etc/init.d/fcgi-hg

#! /bin/sh
#
# fcgi-hg Startup script for the nginx HTTP Server
#
# chkconfig: - 84 15
# description: Loading php-cgi using spawn-cgi
# HTML files and CGI.
#
# Author: Ryan Norbauer
# Modified: Geoffrey Grosenbach http://topfunky.com
# Modified: David Krmpotic http://davidhq.com
# Modified: Kun Xi http://kunxi.org
PATH=/opt/python/bin:$PATH
DAEMON=/usr/bin/spawn-fcgi
FCGIHOST=127.0.0.1
FCGIPORT=9003
FCGIUSER=nginx # ubuntu www-data
FCGIGROUP=nginx
FCGIAPP=/var/www/hg/hgwebdir.fcgi
PIDFILE=/var/run/fcgi-hg.pid
DESC="HG in FastCGI mode"

# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0
test -x $FCGIAPP || exit 0

start() {
$DAEMON -a $FCGIHOST -p $FCGIPORT -u $FCGIUSER -g $FCGIGROUP -f $FCGIAPP -P $PIDFILE 2&gt; /dev/null || echo -en "\n already running"
}

stop() {
kill -QUIT `cat $PIDFILE` || echo -en "\n not running"
}

restart() {
kill -HUP `cat $PIDFILE` || echo -en "\n can't reload"
}

case "$1" in
start)
echo -n "Starting $DESC: "
start
;;
stop)
echo -n "Stopping $DESC: "
stop
;;
restart|reload)
echo -n "Restarting $DESC: "
stop
# One second might not be time enough for a daemon to stop,
# if this happens, d_start will fail (and dpkg will break if
# the package is being upgraded). Change the timeout if needed
# be, or change d_stop to have start-stop-daemon use --retry.
# Notice that using --retry slows down the shutdown process somewhat.
sleep 1
start
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" &gt;&amp;2
exit 3
;;
esac

exit $?</pre>
<p>서버 실행시 서비스 등록을 해준다.</p>
<pre class="brush: shell;">sudo chkconfig fcgi-hg on		# case amazon linux ami or centos
sudo update-rc.d fcgi-hg defaults		# case ubuntu</pre>
<p>fcgi-hg 에 대한 init script를 만들어주고 등록한다.</p>
<pre class="brush: shell;">vi /etc/nginx/host.d/xxxxx

server {
	listen 80;
	server_name test.abc.com;
	root /var/www/hg/;
	gzip on;

	location / {
		include fastcgi_params;
		fastcgi_pass 127.0.0.1:9003;
		fastcgi_split_path_info ^(/)(.*)$;
		fastcgi_param  SCRIPT_NAME      $fastcgi_script_name;
		fastcgi_param  PATH_INFO        $fastcgi_path_info;
		fastcgi_param  AUTH_USER        $remote_user;
		fastcgi_param  REMOTE_USER      $remote_user;
		fastcgi_intercept_errors        off;
		limit_except GET HEAD {
			auth_basic  'Geek\'s Repositories';
			auth_basic_user_file /var/www/hg/hgusers.config;
		}
	}
	location /static/ {
		rewrite /static/(.*) /$1 break;
		root /usr/lib/python2.6/site-packages/mercurial/templates/static;
		expires 30d;
	}
}</pre>
<p>nginx 웹설정 파일을 수정해주고 nginx를 restart 를 하면 해당 도메인으로 mercurial web repository가 뜨는 것을 볼 수 있다.</p>
<pre class="brush: shell;">hg init /var/www/hg/[project_name]
sudo chgrp -R nginx /var/www/hg/[project_name]	# case centos
sudo chgrp -R www-data /var/www/hg/[project_name]	# case ubuntu</pre>
<p>[project_name]의 이름의 프로젝트를 위와 같이 추가하면 각각의 프로젝트에 대해 repository 가 생기는 것을 볼수 있다.</p>
]]></content:encoded>
			<wfw:commentRss>http://yupmin.net/install-mercurial-with-nginx/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iptables simple setting</title>
		<link>http://yupmin.net/iptables-simple-setting</link>
		<comments>http://yupmin.net/iptables-simple-setting#comments</comments>
		<pubDate>Fri, 22 Apr 2011 09:33:41 +0000</pubDate>
		<dc:creator>yupmin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://yupmin.net/?p=318</guid>
		<description><![CDATA[linux 서버를 셋팅할때 각각 배포본마다 설정되어있는 iptables 설정은 배포본의 경계를 넘나들때나, 변경할때 귀찮기 마련이다. 그래서 마련한 간단히 셋팅을 바꿀수 있는 스크립트. referance : http://wiki.centos.org/HowTos/Network/IPTables case : centos vi gen_iptable.sh #!/bin/bash /sbin/iptables -F # Allow SSH connections on tcp port 22 &#8230; <a href="http://yupmin.net/iptables-simple-setting">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>linux 서버를 셋팅할때 각각 배포본마다 설정되어있는 iptables 설정은 배포본의 경계를 넘나들때나, 변경할때 귀찮기 마련이다. 그래서 마련한 간단히 셋팅을 바꿀수 있는 스크립트.</p>
<p>referance : <a href="http://wiki.centos.org/HowTos/Network/IPTables">http://wiki.centos.org/HowTos/Network/IPTables</a></p>
<p><strong>case : centos</strong></p>
<pre class="brush: shell;">vi gen_iptable.sh

#!/bin/bash
/sbin/iptables -F
# Allow SSH connections on tcp port 22
/sbin/iptables -A INPUT -i eth0 -p tcp --dport 22 -j ACCEPT
# Set default policies for INPUT, FORWARD and OUTPUT chains
/sbin/iptables -P INPUT DROP
/sbin/iptables -P FORWARD DROP
/sbin/iptables -P OUTPUT ACCEPT
# Set access for localhost
/sbin/iptables -A INPUT -i lo -j ACCEPT
# Accept packets belonging to established and related connections
/sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# My Firewall
/sbin/iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT
/sbin/iptables -A INPUT -i eth0 -p tcp --dport 22 -s xxx.xxx.xxx.xxx -j ACCEPT
# Save settings
/sbin/service iptables save
# List rules
/sbin/iptables -L -v</pre>
<p><strong>case : ubuntu</strong></p>
<pre class="brush: shell;">vi gen_iptable.sh

#!/bin/bash
/sbin/iptables -F
# Allow SSH connections on tcp port 22
/sbin/iptables -A INPUT -i eth0 -p tcp --dport 22 -j ACCEPT
# Set default policies for INPUT, FORWARD and OUTPUT chains
/sbin/iptables -P INPUT DROP
/sbin/iptables -P FORWARD DROP
/sbin/iptables -P OUTPUT ACCEPT
# Set access for localhost
/sbin/iptables -A INPUT -i lo -j ACCEPT
# Accept packets belonging to established and related connections
/sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# My Firewall
/sbin/iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT
/sbin/iptables -A INPUT -i eth0 -p tcp --dport 22 -s xxx.xxx.xxx.xxx -j ACCEPT
# Save settings
/sbin/iptables-save &gt; /etc/iptables.rule
# List rules
/sbin/iptables -L -v</pre>
]]></content:encoded>
			<wfw:commentRss>http://yupmin.net/iptables-simple-setting/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>using clamav &amp; php-clamv</title>
		<link>http://yupmin.net/using-clamav-php-clamv</link>
		<comments>http://yupmin.net/using-clamav-php-clamv#comments</comments>
		<pubDate>Wed, 20 Apr 2011 08:30:14 +0000</pubDate>
		<dc:creator>yupmin</dc:creator>
				<category><![CDATA[Language]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[clamav]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[virus]]></category>

		<guid isPermaLink="false">http://yupmin.net/?p=357</guid>
		<description><![CDATA[clamv는 오픈소스로 제공되는 백신프로그램이다. 또한 php-clamv를 이용하면 업로드 되는 파일이 바이러스나 웹쉘, rootkit일 경우 잡아줄수 있는 php 라이브러리이다. hompage : http://www.clamav.net/ case centos : wget http://download.fedora.redhat.com/pub/epel/5/i386/clamav-db-0.97-12.el5.i386.rpm wget http://download.fedora.redhat.com/pub/epel/5/i386/clamav-0.97-12.el5.i386.rpm wget http://download.fedora.redhat.com/pub/epel/5/i386/clamav-devel-0.97-12.el5.i386.rpm wget http://download.fedora.redhat.com/pub/epel/5/i386/clamd-0.97-12.el5.i386.rpm rpm -Uvh clamav-db-0.97-12.el5.i386.rpm clamav-0.97-12.el5.i386.rpm clamav-devel-0.97-12.el5.i386.rpm clamd-0.97-12.el5.i386.rpm referance : &#8230; <a href="http://yupmin.net/using-clamav-php-clamv">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://yupmin.net/wp-content/uploads/2011/04/clam_av_logo.png" rel="lightbox[357]"><img class="aligncenter size-full wp-image-398" title="clam_av_logo" src="http://yupmin.net/wp-content/uploads/2011/04/clam_av_logo.png" alt="" width="200" height="200" /></a>clamv는 오픈소스로 제공되는 백신프로그램이다. 또한 php-clamv를 이용하면 업로드 되는 파일이 바이러스나 웹쉘, rootkit일 경우 잡아줄수 있는 php 라이브러리이다.</p>
<p>hompage : <a href="http://www.clamav.net/">http://www.clamav.net/</a></p>
<p><strong>case centos</strong> :</p>
<pre class="brush: shell;">wget http://download.fedora.redhat.com/pub/epel/5/i386/clamav-db-0.97-12.el5.i386.rpm
wget http://download.fedora.redhat.com/pub/epel/5/i386/clamav-0.97-12.el5.i386.rpm
wget http://download.fedora.redhat.com/pub/epel/5/i386/clamav-devel-0.97-12.el5.i386.rpm
wget http://download.fedora.redhat.com/pub/epel/5/i386/clamd-0.97-12.el5.i386.rpm
rpm -Uvh clamav-db-0.97-12.el5.i386.rpm clamav-0.97-12.el5.i386.rpm clamav-devel-0.97-12.el5.i386.rpm clamd-0.97-12.el5.i386.rpm</pre>
<p>referance : <a href="http://code.google.com/p/clamav-cron/">http://code.google.com/p/clamav-cron/</a></p>
<p>clamav-cron를 이용하면 쉽게 cron등록을 할 수 있다. (단 실제 실행해보니 몇가지 권한 문제가 있어서 몇가지 수정했다. 알맞게 이메일등과 메일 제목들을 수정해준다.)</p>
<pre class="brush: shell;">wget http://clamav-cron.googlecode.com/files/clamav-cron-0.6 -O /usr/local/bin/clamav-cron
chmod 755 /usr/local/bin/clamav-cron
vi /usr/local/bin/clamav-cron 

#!/bin/bash
#
# clamav-cron v. 0.6.1 - Copyright © 2009, Stefano Stagnaro &amp; Yupmin
# This is Free Software released under the GNU GPL license version 3

#============================================#
#        User configuration section          #
#============================================#

# Log file name and its path:
CV_LOGFILE="/var/log/clamav-cron.log"

# Notification e-mail sender (could be fake):
CV_MAILFROM="abc@test.com"

# Notification e-mail recipient:
CV_MAILTO="abc@test.com"

# Notification e-mail secondary recipients:
#CV_MAILTO_CC="stefano@abc.com; danilo@abc.com"

# Notification e-mail subject:
CV_SUBJECT="Test.com - ClamAV scan report"

#============================================#

CV_TARGET="$1"
CV_VERSION="0.6"

if [ -e $CV_LOGFILE ]
then
        /bin/rm $CV_LOGFILE
fi
/bin/touch $CV_LOGFILE
/bin/chmod 666 $CV_LOGFILE
/bin/chmod o+w /var/lib/clamav

if [ -z "$1" ]
then
        CV_TARGET="$HOME"
fi

#To be read on stdout (and root mail):
echo -e `basename $0` v. $CV_VERSION - Copyright 2009, Stefano Stagnaro '\n'

#To be read on logfile (sent via sendmail):
echo -e $CV_SUBJECT - $(date) '\n' &gt;&gt; $CV_LOGFILE
echo -e Script: `basename $0` v. $CV_VERSION - Copyright 2009, Stefano Stagnaro  &gt;&gt; $CV_LOGFILE
echo -e Scanned: $CV_TARGET on $HOSTNAME'\n' &gt;&gt; $CV_LOGFILE

/usr/bin/freshclam --log=$CV_LOGFILE --user $USER --verbose

#To be read on stdout (and root mail):
echo -e '------------------------------------\n'

/usr/bin/clamscan --infected --log=$CV_LOGFILE --recursive $CV_TARGET
CLAMSCAN=$?

if [ "$CLAMSCAN" -eq "1" ]
then
        CV_SUBJECT="[VIRUS!] "$CV_SUBJECT
elif [ "$CLAMSCAN" -gt "1" ]
then
        CV_SUBJECT="[ERR] "$CV_SUBJECT
fi

#/bin/mail -s "$CV_SUBJECT" -c $CV_MAILTO_CC $CV_MAILTO -- -f $CV_MAILFROM &lt; $CV_LOGFILE
/bin/mail -s "$CV_SUBJECT" $CV_MAILTO -- -f $CV_MAILFROM &lt; $CV_LOGFILE</pre>
<p>cron으로 매일 돌리지 말고, 중요한 부위등을 알맞게 나눠서 돌리면 될듯 하다.</p>
<pre class="brush: shell;">vi /etc/crontab
45 23 * * 6 /usr/local/bin/clamav-cron /home</pre>
<p>clamav-php 라이브러리는 다음과 같이 설치한다. 기본 clamav가 깔려있는 clamav database path등에 유의한다.</p>
<p><strong><span style="color: #ff0000;">php-clamav의 경우 centos 5 에 컴파일해서 사용할 경우 아파치 프로세스크가가 5~7배 커지는 것으로 보임. 사용주의 요망.</span></strong></p>
<p>source : <a href="http://php-clamav.sourceforge.net/">http://php-clamav.sourceforge.net/</a></p>
<pre class="brush: shell;">wget http://sourceforge.net/projects/php-clamav/files/0.15/php-clamav_0.15.3.tar.gz/download
tar xvfz php-clamav-0.15.3
cd php-clamav-0.15.3
phpize
./configure --with-clamav
make; make install;
vi /etc/clamav.ini

extension=clamav.so
[clamav]
clamav.dbpath="/var/clamav"
clamav.maxreclevel=16
clamav.maxfiles=10000
clamav.maxfilesize=26214400
clamav.maxscansize=104857600
clamav.keeptmp=0
clamav.tmpdir="/var/tmp"</pre>
]]></content:encoded>
			<wfw:commentRss>http://yupmin.net/using-clamav-php-clamv/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>using mysql master-master replication</title>
		<link>http://yupmin.net/using-mysql-master-master-replication</link>
		<comments>http://yupmin.net/using-mysql-master-master-replication#comments</comments>
		<pubDate>Thu, 03 Mar 2011 11:54:39 +0000</pubDate>
		<dc:creator>yupmin</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[replication]]></category>

		<guid isPermaLink="false">http://yupmin.net/?p=325</guid>
		<description><![CDATA[master-master replication은 DB 이중화에 유용하다. 0. server1 : 192.168.0.1 server2 : 192.168.0.2 1. server1, server2의 my.cnf의 내용을 맞춘다 server1 : vi /etc/mysql/my.cnf #server1 server-id = 1 log_bin = /var/log/mysql/mysql-bin.log binlog_do_db = test1 binlog_do_db = test2 binlog-ignore-db = mysql binlog-ignore-db = &#8230; <a href="http://yupmin.net/using-mysql-master-master-replication">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>master-master replication은 DB 이중화에 유용하다. </p>
<p>0.<br />
server1 : 192.168.0.1<br />
server2 : 192.168.0.2</p>
<p>1.<br />
server1, server2의 my.cnf의 내용을 맞춘다</p>
<p>server1 :</p>
<pre class="brush: shell;">vi /etc/mysql/my.cnf 

#server1
server-id = 1
log_bin = /var/log/mysql/mysql-bin.log
binlog_do_db = test1
binlog_do_db = test2
binlog-ignore-db = mysql
binlog-ignore-db = test</pre>
<p>server2 :</p>
<pre class="brush: shell;">vi /etc/mysql/my.cnf

#server2
server-id = 2
log_bin = /var/log/mysql/mysql-bin.log
binlog_do_db = test1
binlog_do_db = test2
binlog-ignore-db = mysql
binlog-ignore-db = test</pre>
<p>2.<br />
my.cnf를 설정한후 두 서버 리스타트후 각각 서버에서 replication 계정을 활성화 해준다.</p>
<p>server1 :<br />
server2 :</p>
<pre class="brush: sql;">GRANT REPLICATION SLAVE ON *.* TO 'replication'@'192.168.0.%' IDENTIFIED BY 'replication_password';</pre>
<p>3.<br />
각 서버 replication slave 를 stop하고 test1 => test2의 DB를 일치시킨다.</p>
<p>sever1 :</p>
<pre class="brush: sql;">STOP SLAVE;
FLUSH TABLES WITH READ LOCK;
SHOW MASTER STATUS;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000105 | 33527473 |              |                  |
+------------------+----------+--------------+------------------+</pre>
<p>스냅샵을 뜨고</p>
<pre class="brush: shell;">mysqldump -uroot -ppassword -B test1 test2 > snapshot.sql</pre>
<p>server2 :</p>
<pre class="brush: shell;">mysql -uroot -ppassword < snapshot.sql</pre>
<p>server2에 복원한다.
</pre>
<pre class="brush: sql;">STOP SLAVE;
CHANGE MASTER TO master_host='192.168.0.1', master_port=3306, master_user='replication', master_password='replication_password', master_log_file='mysql-bin.000105', master_log_pos=33527473;
START SLAVE;
SHOW MASTER STATUS;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000073 | 00027473 |              |                  |
+------------------+----------+--------------+------------------+</pre>
<p>server 1 :</p>
<pre class="brush: sql;">CHANGE MASTER TO master_host='192.168.0.2', master_port=3306, master_user='replication', master_password='replication_password', master_log_file='mysql-bin.000073', master_log_pos=00027473;
START SLAVE;</pre>
<p>4.<br />
두 서버의 slave status를 확인해서 에러 없는지 확인</p>
<pre class="brush: sql;">SHOW SLAVE STATUS \G</pre>
<p>5.<br />
server3 : 192.168.0.3</p>
<p>서버를 하나 더 늘린다면 모든 커넥션을 server1로 옮겨두고 server1의 slave를 중지 시킨다</p>
<p>server3 :</p>
<pre class="brush: shell;">vi /etc/mysql/my.cnf 

#server3
server-id = 3
log_bin = /var/log/mysql/mysql-bin.log
binlog_do_db = test1
binlog_do_db = test2
binlog-ignore-db = mysql
binlog-ignore-db = test</pre>
<p>server1 :</p>
<pre class="brush: sql;">stop slave;
</pre>
<p>6.<br />
server2의 내용을 server3로 이사한다<br />
server2 :</p>
<pre class="brush: sql;">STOP SLAVE;
FLUSH TABLES WITH READ LOCK;
SHOW MASTER STATUS;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000137 | 33527001 |              |                  |
+------------------+----------+--------------+------------------+</pre>
<p>스냅샵을 뜨고</p>
<pre class="brush: shell;">mysqldump -uroot -ppassword -B test1 test2 > snapshot.sql</pre>
<p>7.<br />
server3 :</p>
<pre class="brush: sql;">GRANT REPLICATION SLAVE ON *.* TO 'replication'@'192.168.0.%' IDENTIFIED BY 'replication_password';</pre>
<p>권한을 설정해준다.</p>
<pre class="brush: shell;">mysql -uroot -ppassword < snapshot.sql</pre>
<p>server3에 복원한다.
</pre>
<pre class="brush: sql;">STOP SLAVE;
CHANGE MASTER TO master_host='192.168.0.2', master_port=3306, master_user='replication', master_password='replication_password', master_log_file='mysql-bin.000137', master_log_pos=33527001;
START SLAVE;
SHOW MASTER STATUS;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000043 | 00000015 |              |                  |
+------------------+----------+--------------+------------------+</pre>
<p>server 1 :</p>
<pre class="brush: sql;">CHANGE MASTER TO master_host='192.168.0.3', master_port=3306, master_user='replication', master_password='replication_password', master_log_file='mysql-bin.000043', master_log_pos=00000015;
START SLAVE;</pre>
<p>8.<br />
세 서버의 slave status를 확인해서 에러 없는지 확인</p>
<pre class="brush: sql;">SHOW SLAVE STATUS \G</pre>
]]></content:encoded>
			<wfw:commentRss>http://yupmin.net/using-mysql-master-master-replication/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>using monit</title>
		<link>http://yupmin.net/using-monit</link>
		<comments>http://yupmin.net/using-monit#comments</comments>
		<pubDate>Tue, 07 Dec 2010 05:21:28 +0000</pubDate>
		<dc:creator>yupmin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[monit]]></category>
		<category><![CDATA[monitor]]></category>

		<guid isPermaLink="false">http://yupmin.net/?p=151</guid>
		<description><![CDATA[한동안 개발이 중지되었던 monit가 돌아왔다. 모니터링 웹서버를 가지고 있고, 다양한 셋팅하에서의 자동 관리 기능이 있다. case : ubuntu apt-get install monit case : centos yum install flex bison openssl-devel wget http://mmonit.com/monit/dist/monit-5.2.5.tar.gz tar xvfz monit-5.2.5.tar.gz cd monit-5.2.5 ./configure make; make install &#8230; <a href="http://yupmin.net/using-monit">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>한동안 개발이 중지되었던 <a href="http://mmonit.com/monit/">monit</a>가 돌아왔다. 모니터링 웹서버를 가지고 있고, 다양한 셋팅하에서의 자동 관리 기능이 있다. </p>
<p><strong>case : ubuntu</strong></p>
<pre class="brush: shell;">apt-get install monit</pre>
<p><strong>case : centos</strong></p>
<pre class="brush: shell;">yum install flex bison openssl-devel
wget http://mmonit.com/monit/dist/monit-5.2.5.tar.gz
tar xvfz monit-5.2.5.tar.gz
cd monit-5.2.5
./configure
make; make install</pre>
<p>init script는 다음을 받아서 사용한다. <a href='http://yupmin.net/wp-content/uploads/2010/08/monit.zip'>monit</a></p>
<pre class="brush: shell;">vi /etc/monitrc

set daemon 60
set logfile syslog facility LOG_daemon
set mailserver localhost
set alert admin@abc.com
set httpd port 8080 address localhost
        allow localhost

check process apache with pidfile "/var/run/httpd.pid"
        start = "/etc/init.d/httpd start"
        stop = "/etc/init.d/httpd stop"
        if failed host 127.0.0.1 port 80 and protocol http
                and request "/abc.txt" then restart
        if cpu usage is greater than 60 percent for 2 cycles then alert
        if cpu usage > 98% for 5 cycles then restart
        if 2 restarts within 3 cycles then timeout
        alert admin@abc.com

check process mysql with pidfile "/var/run/mysqld/mysqld.pid"
        group database
        start program = "/etc/init.d/mysqld start"
        stop program = "/etc/init.d/mysqld stop"
        if failed host 127.0.0.1 port 3306 then restart
        if cpu usage > 98% for 5 cycles then restart
        if 5 restarts within 5 cycles then timeout</pre>
]]></content:encoded>
			<wfw:commentRss>http://yupmin.net/using-monit/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>upgrade pcre with unicode on centos</title>
		<link>http://yupmin.net/upgrade-pcre-with-unicode-on-centos</link>
		<comments>http://yupmin.net/upgrade-pcre-with-unicode-on-centos#comments</comments>
		<pubDate>Fri, 03 Dec 2010 05:58:23 +0000</pubDate>
		<dc:creator>yupmin</dc:creator>
				<category><![CDATA[Language]]></category>
		<category><![CDATA[pcre]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://yupmin.net/?p=284</guid>
		<description><![CDATA[centos의 경우 pcre(Perl Compatible Regular Expressions)에서 unicode에 대한  대한 처리가 안되어있다. pcretest -C PCRE version 6.6 06-Feb-2006 Compiled with UTF-8 support No Unicode properties support Newline character is LF Internal link size = 2 POSIX malloc threshold = 10 Default match &#8230; <a href="http://yupmin.net/upgrade-pcre-with-unicode-on-centos">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>centos의 경우 pcre(Perl Compatible Regular Expressions)에서 unicode에 대한  대한 처리가 안되어있다.</p>
<pre class="brush: shell;">pcretest -C
PCRE version 6.6 06-Feb-2006
Compiled with
  UTF-8 support
  No Unicode properties support
  Newline character is LF
  Internal link size = 2
  POSIX malloc threshold = 10
  Default match limit = 10000000
  Default recursion depth limit = 10000000
  Match recursion uses stack</pre>
<p>참조 : <a href="http://chrisjean.com/2009/01/31/unicode-support-on-centos-52-with-php-and-pcre/">http://chrisjean.com/2009/01/31/unicode-support-on-centos-52-with-php-and-pcre/</a></p>
<pre class="brush: shell;">wget http://vault.centos.org/5.1/updates/SRPMS/pcre-6.6-2.el5_1.7.src.rpm
rpm -ivh pcre-6.6-2.el5_1.7.src.rpm
vi /usr/src/redhat/SPECS/pcre.spec

%configure --enable-utf8 --enable-unicode-properties #add '--enable-unicode-properties'

rpmbuild -ba /usr/src/redhat/SPECS/pcre.spec
rpm -Uvh /usr/src/redhat/RPMS/i386/pcre-6.6-2.7.i386.rpm /usr/src/redhat/RPMS/i386/pcre-devel-6.6-2.7.i386.rpm</pre>
]]></content:encoded>
			<wfw:commentRss>http://yupmin.net/upgrade-pcre-with-unicode-on-centos/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>using ssmtp</title>
		<link>http://yupmin.net/using-ssmtp</link>
		<comments>http://yupmin.net/using-ssmtp#comments</comments>
		<pubDate>Thu, 02 Dec 2010 03:32:22 +0000</pubDate>
		<dc:creator>yupmin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[smtp]]></category>
		<category><![CDATA[ssmtp]]></category>

		<guid isPermaLink="false">http://yupmin.net/?p=282</guid>
		<description><![CDATA[서버마다 메일서버를 구축하는 것 보다 ssmtp로 설정하고 하나의 smtp 서버에 연결해서 사용하는것이 더 낫다. 소스 : http://packages.debian.org/source/sid/ssmtp ssmtp 2.64 wget http://ftp.de.debian.org/debian/pool/main/s/ssmtp/ssmtp_2.64.orig.tar.bz2 tar xvfj ssmtp_2.64.orig.tar.bz2 cd ssmtp-2.64 ./configure --sysconfdir=/etc make; make install ssmtp 2.62 wget http://ftp.de.debian.org/debian/pool/main/s/ssmtp/ssmtp_2.62.orig.tar.gz wget http://ftp.de.debian.org/debian/pool/main/s/ssmtp/ssmtp_2.62-3.diff.gz tar xvfz ssmtp_2.62.orig.tar.gz &#8230; <a href="http://yupmin.net/using-ssmtp">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>서버마다 메일서버를 구축하는 것 보다 ssmtp로 설정하고 하나의 smtp 서버에 연결해서 사용하는것이 더 낫다.</p>
<p>소스 : <a href="http://packages.debian.org/source/sid/ssmtp">http://packages.debian.org/source/sid/ssmtp</a></p>
<p>ssmtp 2.64</p>
<pre class="brush: shell;">wget http://ftp.de.debian.org/debian/pool/main/s/ssmtp/ssmtp_2.64.orig.tar.bz2
tar xvfj ssmtp_2.64.orig.tar.bz2
cd ssmtp-2.64
./configure --sysconfdir=/etc
make; make install</pre>
<p>ssmtp 2.62</p>
<pre class="brush: shell;">wget http://ftp.de.debian.org/debian/pool/main/s/ssmtp/ssmtp_2.62.orig.tar.gz
wget http://ftp.de.debian.org/debian/pool/main/s/ssmtp/ssmtp_2.62-3.diff.gz
tar xvfz ssmtp_2.62.orig.tar.gz
gunzip ssmtp_2.62-3.diff.gz
mv ssmtp-2.62 ssmtp
patch -p0 &lt; ssmtp_2.62-3.diff
mv ssmtp ssmtp-2.62
cd ssmtp-2.62/ssmtp
./configure --sysconfdir=/etc
make; make install</pre>
<p>sendmail을 대치해야 한다. 만일 sendmail을 지우지 않았다면 다음과 같이 대치 한다.<br />
아니면 /etc/alternatives 가서 mta관련 링크를 수정해야 한다. (근데 sendmail 지워주고 깔면 알아서 셋팅된다.) 참조 : <a href="http://linux.com/archive/feature/132006">http://linux.com/archive/feature/132006</a></p>
<pre class="brush: shell;">sudo mv /usr/sbin/sendmail /usr/sbin/sendmail.orig
sudo ln -s /usr/local/sbin/ssmtp /usr/sbin/sendmail</pre>
<pre class="brush: shell;">vi /etc/ssmtp/ssmtp.conf

#
# /etc/ssmtp.conf -- a config file for sSMTP sendmail.
#
# The person who gets all mail for userids &lt; 1000
# Make this empty to disable rewriting.
root=postmaster
# The place where the mail goes. The actual machine name is required
# no MX records are consulted. Commonly mailhosts are named mail.domain.com
# The example will fit if you are in domain.com and you mailhub is so named.
mailhub=mail # 바꾸려는 메일서버 주소
# Where will the mail seem to come from?
#rewriteDomain=
# The full hostname
hostname=localhost # 서버 hostname
fromlineoverride=yes # php등에서 메일 보낼때 from을 오버라이딩 가능하게</pre>
<p>gmail서버로도 연결이 가능하니 꼭 메일 서버를 가지지 않아도 될듯 하다.<br />
<a href="http://www.keitheobrien.com/blog/files/026d08c5ee22f9318e224c77e70a8318-1.html">Using SSMTP to Replace Sendmail (Gmail Config)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://yupmin.net/using-ssmtp/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

