2012년 6월 5일 화요일

nginx + php FastCGI Process Manager (FPM)


NginX-1.2.0 설치
-------------


$ sudo yum install pcre-devel openssl-devel
./configure \
--user=nobody \
--group=nobody \
--prefix=/opt/nginx_1.2.0 \
 --with-http_ssl_module \
 --with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_gzip_static_module \
--with-http_stub_status_module


$ make && make install




php-5.3.3 설치
-------------
PHP 5.3.3 버전 이상 부터 FPM(FastCGI Process Manager)가 PHP 코어에 포함 되어 별도 패치가 필요 없음
$ yum install libevent-devel libxml2-devel bzip2-devel libcurl-devel libjpeg-devel libXpm-devel freetype-devel libc-client-devel libmcrypt-devel mysql-devel net-snmp net-snmp-devel pspell-devel libmhash mhash-devel libtidy libtidy-devel expat-devel libxslt-devel



./configure \
--prefix=/opt/php-fpm_5.3.3 \
--enable-fpm \
--with-fpm-user=nobody \
--with-fpm-group=nobody \
--with-config-file-path=/etc \
--enable-bcmath \
--enable-calendar \
--enable-exif \
--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 \
--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-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-sqlite=shared \
--with-tidy=/usr \
--with-xmlrpc \
--with-xpm-dir=/usr \
--with-xsl=/opt/xslt/ \
--with-zlib \
--with-zlib-dir=/usr





$ make && make install




PHP-FPM 설정
-------------


php-fpm.conf 파일의 설정을 변경. 
FPM의 경우에는 PHP가 CGI 방식과 같이 한개의 PHP스크립트를 프로세스 1개가 처리하는 방식이 아닌 PHP가 하나의 데몬으로 처리. 
즉 PHP가 내부 프로세스로 PHP스크립트를 대기. 그렇기 때문에 실행 권한 등으로 사용자를 설정하게 됨. 기본적으로 nobody를 사용


$ cp /usr/local/src/php-5.3.3/sapi/fpm/php-fpm.conf /opt/php-fpm_5.3.3/etc


listen = /tmp/php-fpm.sock FastCGI 용 Listen 포트를 설정. ( Unix Domain Socket )
TCP 설정도 가능. host:port


pid = /var/run/php-fpm.pid
user = nobody # 프로세스 사용자
group = nobody # 프로세스 그룹
pm.max_children = 50 # FPM 최대 자식 프로세스 수 
pm.start_servers = 20 # FPM 시작 서버 수 
pm.min_spare_servers = 5 # FPM 최소 대기 서버 
pm.max_spare_servers = 35 # FPM 최대 대기 서버


init.d  구동 스크립트
$ cp sapi/fpm/init.d.php-fpm.in /etc/init.d/php-fpm


$ vi /etc/init.d/php-fpm
php_fpm_BIN=/opt/php-fpm_5.3.3/sbin/php-fpm
php_fpm_CONF=/opt/php-fpm_5.3.3/etc/php-fpm.conf
php_fpm_PID=/var/run/php-fpm.pid


$ chmod 755 /etc/init.d/php-fpm
$ chkconfig --add php-fpm
$ chkconfig php-fpm on




php 재빌드,php.ini 변경 후 이전에는 웹서를 재시동하면 적용되었으나
php-fpm의 경우는 init.d 구동 스크립트를 재실행 해야만 적용된다.



NginX 설정 
-------------


$ wget 'http://wiki.nginx.org/index.php?title=RedHatNginxInitScript&action=raw&anchor=nginx' -O nginx 
$ mv nginx /etc/init.d/


$ vi /etc/init.d/nginx
nginx="/opt/nginx-1.2.0/sbin/nginx"
NGINX_CONF_FILE="/opt/nginx-1.2.0/conf/nginx.conf"
lockfile=/var/lock/subsys/nginx


$ chmod 755 /etc/init.d/nginx
$ chkconfig --add nginx
$ chkconfig nginx on



2012년 6월 1일 금요일

MAC OS X Lion 파일관련 설정

파인더 전체경로 표시 설정

$ defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES


파인더의 숨김파일을 모두 보도록 설정
$ defaults write com.apple.Finder AppleShowAllFiles YES

파인더 종료

Mac OS X에서 Maven 버전업


 $ cd /usr/share
 $ sudo mv maven maven303
 $ sudo ln -s /Users/foot/dev_local/apache-maven-3.0.4 maven
 $ mvn -version