2012년 5월 16일 수요일

AWS EC2 설정하기

Instance Launch  Configuaration : Amazon Linux AMI 2012.03   64bit




$MacBook-Pro:aws foot$ mkdir .aws
$MacBook-Pro:aws foot$ cp privatekey.pem .aws
$MacBook-Pro:aws foot$ chmod 400 .aws/privatekey.pem
$MacBook-Pro:aws foot$ ssh -i .aws/privatekey.pem ec2-user@xxxxxxx.compute-1.amazonaws.com
                           
The authenticity of host 'xxxxxxxx.compute-1.amazonaws.com (xx.xx.xxx.xxx)' can't be established.
RSA key fingerprint is 7f:6b:48:a5:a5:8d:e2:4f:b7:ff:99:d5:ce:33:0f:6a.
Are you sure you want to continue connecting (yes/no)? yes


$ sudo yum update



Updated:
  aws-amitools-ec2.noarch 0:1.4.0.7-1.2.amzn1     aws-apitools-ec2.noarch 0:1.5.3.0-1.0.amzn1     aws-apitools-rds.noarch 0:1.6.001-1.5.amzn1    
  bind-libs.x86_64 32:9.7.3-8.P3.17.amzn1         bind-utils.x86_64 32:9.7.3-8.P3.17.amzn1        initscripts.x86_64 0:9.03.27-1.18.amzn1        
  iproute.x86_64 0:3.2.0-3.7.amzn1                iptables.i686 0:1.4.12-2.15.amzn1               iptables.x86_64 0:1.4.12-2.15.amzn1            
  libpng.x86_64 2:1.2.49-1.12.amzn1               libudev.i686 0:173-3.20.amzn1                   libudev.x86_64 0:173-3.20.amzn1                
  ntp.x86_64 0:4.2.4p8-2.16.amzn1                 ntpdate.x86_64 0:4.2.4p8-2.16.amzn1             python-boto.noarch 0:2.3.0-1.0.amzn1           
  ruby.x86_64 0:1.8.7.357-1.18.amzn1              ruby-libs.x86_64 0:1.8.7.357-1.18.amzn1         system-release.noarch 0:2012.03-7.0            
  udev.x86_64 0:173-3.20.amzn1                   


Complete!




APM 설치


++ 루트 권한 획득
$ sudo su
$ sudo yum install php-mysql php php-xml php-mcrypt php-mbstring php-cli mysql httpd


$sudo yum list available | grep MySQL


$ sudo yum install mysql-server
$ sudo /etc/init.d/mysqld start
$ mysqladmin -u root password 'password'


$ mkdir  /home/ec2-user/www
$ vi  /etc/httpd/conf/httpd.conf


DirectoryIndex index.html index.php


NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot 웹문서경로
ServerName 서버이름
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>



sudo /etc/init.d/httpd start
sudo chkconfig --levels 235 mysqld on
sudo chkconfig --levels 235 httpd on











2012년 3월 29일 목요일

CentOS 시간 세팅

아마존 EC2 서버를 이용하는데 시간이 UTC로 표기됨.

$ date

Fri Jan 3 08:05:03 UTC 2013


$ echo $TZ
$ export env TZ=KST-09:00:00

KST는 date 명령어의 문자열에 불과하며 실제로 영향을 주는 내용은 -09:00:00.

+, -는 그리니치 천문대를 중심으로 서쪽은
+, 동쪽은 - 이고, 우리나라는 동쪽에 있으며 9시간이 빠르므로 -09:00:00


/etc/rc.d/rc.local 에 아래 내용 추가하게 되면 부팅시 마다 시간을 맞춰준다.


export env TZ=KST-09:00:00 

rdate -s time.bora.net
clock -w

2012년 3월 28일 수요일

crontab 사용


$ crontab -l  => crontab에 등록된 작업 목록
$ crontab -e => crontab에 작업 등록하기
* 작업 등록시 설명
------  -------- ---------------------------------------------------
필 드  의 미  범 위
------  -------- ---------------------------------------------------
첫번째  분    0-59
두번째  시    0-23
세번째  일    0-31
네번째  월    1-12
다섯번째 요일   0-7 (0 또는 7=일요일, 1=월, 2=화,...)
여섯번째 명령어  실행할 명령을 한줄로 쓴다.
------  -------- ---------------------------------------------------

Ex)
매시간 30분 마다 동작
30 * * * * 명령어

2012년 3월 26일 월요일

proftpd-1.3.4a 설치



# wget ftp://ftp.proftpd.org/distrib/source/proftpd-1.3.4a.tar.gz

# cd /usr/src
# tar -zxcf proftpd-1.3.4a.tar.gz
# ./configure
# make
# make install
# proftpd -v
# cp sample-configurations/basic.conf /etc/proftpd.conf





서버에서 데몬이 자동으로 시작하도록 하기위해서는
#chkconfig --list
명령으로 확인.

서비스를 등록하기위해서 시작스크립트를 생성.
소스의 contrib/dist/rpm 디렉토리에 proftpd.init.d 파일을 다음과 같이 데몬 파일의 위치를 수정.

PATH="$PATH:/usr/local/proftpd/sbin"
수정이 완료되면 /etc/rc.d/init.d/ 디렉토리로 복사한다.
#cp proftpd.init.d /etc/rc.d/init.d/proftpd
#chmod 755 /etc/rc.d/init.d/proftpd
서비스 등록을 한다.
#chkconfig --add proftpd

런레벨 종류에 따라 서비스가 자동으로 실행하도록
3번 Full multiuser mode, 5번 X11을 on으로 설정한다.

#chkconfig  --level 35 proftpd on

3번은 텍스트 모드이고 5번은 GUI 런레벨이다.

실행
# /usr/local/proftpd/sbin/proftpd



conf 파일 수정하기 
# vi /usr/local/proftpd/etc/proftpd.conf 

ServerType                      standalone 
#ServerType                    inetd 
DefaultServer                    on 
ServerAdmin                    root@localhost 

//아래의 내용을 주석 해제하면 모든 사용자는 자기 홈디렉토리 이상으로는 이동할 수 없다.
DefaultRoot                    ~ 


/etc/rc.d/init.d/proftpd restart


2012년 3월 25일 일요일

mod_wsgi-3.3 설치 및 테스트

새로 설치한 python경로로 이동하여 공용 라이브러리를 심볼릭 링크
# cd /usr/local/python2.7/lib/python2.7/config
# ln -s ../../libpython2.7.so


# cd /usr/local/src/mod_wsgi-3.3
# ./configure --with-apxs=/usr/local/httpd/bin/apxs --with-python=/usr/local/python2.7/bin/python

# make && make install



apache httpd.conf 추가
# vi /usr/local/httpd/conf/httpd.conf


LoadModule wsgi_module modules/mod_wsgi.so
AddHandler wsgi-script .wsgi



WSGIScriptAlias /myapp /usr/local/httpd/htdocs/wsgi/test.wsgi
<Directory /usr/local/httpd/htdocs/wsgi>
Order allow,deny
Allow from all
</Directory>



apache 2.4.1 데몬 실행 실패


apache설치 후 데몬이 실행되지 않는 문제 발생. 

httpd.conf 구문 오류 체크가 정상인데 데몬이 실행되지 않음

아파치 로그를 확인 결과 proxy_balancer 모듈을 로드하지 못해 발생.

구체적인 원인 확인 필요.

# cat /usr/local/apache/logs/error_log

[Mon Mar 26 18:49:20.789764 2012] [proxy_balancer:emerg] [pid 2410:tid 139782170601216] AH01177: Failed to lookup provider 'shm' for 'slotmem': is mod_slotmem_shm loaded??
[Mon Mar 26 18:49:20.789924 2012] [:emerg] [pid 2410:tid 139782170601216] AH00020: Configuration Failed, exiting

2012년 3월 16일 금요일

PHP 64-bit Standard Configuration


./configure \
--enable-bcmath \
--enable-calendar \
--enable-dbase \
--enable-exif \
--enable-fastcgi \
--enable-force-cgi-redirect \
--enable-ftp \
--enable-gd-native-ttf \
--enable-libxml \
--enable-magic-quotes \
--enable-mbstring \
--enable-pdo=shared \
--enable-safe-mode \
--enable-soap \
--enable-sockets \
--enable-wddx \
--enable-zend-multibyte \
--enable-zip \
--prefix=/usr/local/apache/php \
--with-bz2 \
--with-curl=/opt/curlssl/ \
--with-curlwrappers \
--with-freetype-dir=/usr \
--with-gd \
--with-gettext \
--with-imap=/opt/php_with_imap_client/ \
--with-imap-ssl=/usr \
--with-jpeg-dir \
--with-kerberos \
--with-libdir=lib64 \
--with-libexpat-dir=/usr \
--with-libxml-dir=/opt/xml2 \
--with-libxml-dir=/opt/xml2/ \
--with-mcrypt=/opt/libmcrypt/ \
--with-mhash=/opt/mhash/ \
--with-mime-magic \
--with-ming=/opt/ming/ \
--with-mm=/opt/mm/ \
--with-mysql=/usr \
--with-mysql-sock=/var/lib/mysql/mysql.sock \
--with-mysqli=/usr/bin/mysql_config \
--with-openssl=/usr \
--with-openssl-dir=/usr \
--with-pdo-mysql=shared \
--with-pdo-sqlite=shared \
--with-pic \
--with-png-dir=/usr \
--with-pspell \
--with-sqlite=shared \
--with-tidy=/usr \
--with-ttf \
--with-xmlrpc \
--with-xpm-dir=/usr \
--with-xsl=/opt/xslt/ \
--with-zlib \
--with-zlib-dir=/usr