5. Gateway Application : Jersey를 이용한 Java Servlet
5. Gateway Application : Jersey를 이용한 Java Servlet
Great Architect & Artist
지혜 있는 자는 궁창의 빛과 같이 빛날 것이요 많은 사람을 옳은 데로 돌아오게 한 자는 별과 같이 영원토록 빛나리라 (단 12:3)
yum -y install zlib curl gcc g++ cpp gcc-c++ compat-gcc-34-g77 libxml2 libxml2-devel gd gd-devel freetype freetype-devel libpng libpng-devel libjpeg libjpeg-devel fontconfig fontconfig-devel mhash mhash-devel libmcrypt libmcrypt-devel openssl openssl-devel gmp gmp-devel flex libtermcap-devel ncurses-devel libc-client-devel bzip2-devel termcap libtermcap gdbm-devel readline-devel zlib-devel tcl-devel python-devel
./configure --prefix=$HOME/pgsql
make && make install
Initdb -D $HOME/pgsql/data
bin/pg_ctl -D $HOME/pgsql/data -l logfile start
bin/createdb database_name
bin/psql database_name
\q
Create table table_name (column_name varchar(10), mod_date TIMESTAMP....);
Alter table table_name ADD column_name varchar(10);
Alter table table_name rename column column_name to new_column_name;
Select * from pg_tables where schemaname='public';
Select * from information_schema.columns where table_name='table_name';
bin/createuser -s username -P
Enter password for new role : xxx
select * from pg_user;
Grant all on all tables in schema public to user_id;
<의존 라이브러리 설치>
yum install gcc gdbm-devel readline-devel ncurses-devel zlib-devel bzip2-develsqlite-devel db4-devel openssl-devel tk-devel bluez-libs-devel
<Python 설치>
./configure --prefix=$HOME/python --with-threads --enable-shared
make && make install
<Profile에 환경변수 추가>
vi .bash_profile
PATH=$PATH:$HOME/python/bin:$HOME/python/lib
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/python/lib:$HOME/python/bin
alias python='$HOME/python/bin/python2.7'
<Pre-requirement>
- apr-1.4.6, apr-util-1.5.2 필요함
- 위 2개의 파일을 httpd-2.4.4/srclib 폴더 아래에 압축 해제
<Apache Install>
./configure --prefix=$HOME/apache2 --with-included-apr
make && make install
<mod_wsgi 설치>4. Apache 설정 변경
LD_LIBRARY_PATH=$HOME/python/lib ./configure --with-apxs=$HOME/apache2/bin/apxs --with-python=$HOME/python/bin/python
make && make install
<mod_wsgi 설치 확인>
$HOME/apache2/modules/mod_wsgi.so가 있는지 확인
LoadModule wsgi_module modules/mod_wsgi.so
WSGIDaemonProcess daemon processes=2 threads=15
WSGIScriptAlias / /wsgi/file/path/test.py
<Directory />
AddHandler wsgi-script .py
</Directory>
<의존 라이브러리 설치>
yum -y install gcc* automake autoconf libtool make termcap libtermca* gdbm-devel zlib* libxml* freetype* libpng* libjpeg* gd* libmcrypt* mhash* apr apr-* pcre* bzip2-devel openssl* libevent-deve
<Python 설치>
./configure --prefix=$HOME/python
<실행 바이너리 빌드>
- tar 명령으로 압축 해제
- 압축 해제된 폴더에서 다음 커맨드 실행 :
python uwsgiconfig.py --build
<샘플 코드 작성>
# test.py
def app(env, start_response):
start_response('200 OK', [('Content-Type', 'text/html')])
return "Hello World"
<샘플 코드 실행>
uwsgi --http :8000 --wsgi-file test.py
<샘플 코드 실행 결과>
웹브라우저에서 127.0.0.1:8000 호출시 Hello World가 보이면 모듈 설치 성공
<의존 라이브러리 설치>
yum -y install gcc g++ cpp gcc-c++ pcre-devel openssl openssl-devel gd gd-devel
<nGinX 설치>
./configure --prefix=$HOME/nginx \
--conf-path=$HOME/nginx/conf/nginx.conf \
--sbin-path=$HOME/nginx/sbin/nginx \
--lock-path=$HOME/nginx/lock/nginx.lock \
--pid-path=$HOME/nginx/run/nginx.pid \
--http-client-body-temp-path=$HOME/nginx/lib/nginx/body \
--http-proxy-temp-path=$HOME/nginx/lib/nginx/proxy \
--http-fastcgi-temp-path=$HOME/nginx/lib/nginx/fastcgi \
--http-uwsgi-temp-path=$HOME/nginx/lib/nginx/uwsgi \
--http-scgi-temp-path=$HOME/nginx/lib/nginx/scgi \
--http-log-path=$HOME/nginx/logs/access.log \
--error-log-path=$HOME/nginx/logs/error.log \
--with-http_addition_module \
--with-http_addition_module \
--with-http_degradation_module \
--with-http_flv_module \
--with-http_gzip_static_module \
--with-http_image_filter_module \
--with-http_mp4_module \
--with-http_random_index_module \
--with-http_realip_module \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_sub_module \
--with-http_realip_module \
--user=nobody \
--group=nobody
<nginx.conf 수정>
- nginx web server와 uwsgi module 연결할 수 있도록 설정 변경해야 함
server {
listen 8080;
server_name localhost;
charset utf-8;
client_max_body_size 75M;
location / {
uwsgi_pass 127.0.0.2:8000;
include uwsgi_params;
}
}
댓글을 달아 주세요
댓글 RSS 주소 : http://www.yongbi.net/rss/comment/555