페이지

레이블이 server인 게시물을 표시합니다. 모든 게시물 표시
레이블이 server인 게시물을 표시합니다. 모든 게시물 표시

2014년 8월 27일 수요일

[tomcat]서버에서 한글 인식 못할때

와스에서 한글파일명을 인식 못하는 경우가 있다

이럴땐 서버의 캐릭터 셋과 와스의 캐릭터 셋을 맞춰 주어야 한다


1. 서버
export $LANG로 현재 캐릭터 셋을 확인한다

그리고 만약 원하는 캐릭터 셋이 아니라면 다음 파일에서 내용을 바꿔준다

vi /etc/sysconfig/i18n 

LANG="ko_KR.UTF-8"
#LANG="en_US.UTF-8"
#LANG="ko_KR.eucKR"
SUPPORTED="en_US.UTF-8:en_US:en:ko_KR.eucKR:ko_KR:ko"
SYSFONT="latarcyrheb-sun16"




2. 와스
URIEncoding="utf-8"을 Connector부분에 추가한다

vi server.xml 

 <Connector port="8090" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="82443" URIEncoding="utf-8"/>


<Connector port="8709" protocol="AJP/1.3" redirectPort="82443" URIEncoding="utf-8"/>


그런데 한글은 이제 잘 나와도 터미널에서 안나올 경우가 있다
secureCRT기준으로 Character부분을 바꾸어주고 터미널 재접하면 된다








참조 : http://jmnote.com/wiki/%EB%A6%AC%EB%88%85%EC%8A%A4_%EC%89%98_%ED%95%9C%EA%B8%80_%EA%B9%A8%EC%A7%90

2014년 2월 26일 수요일

[linux]apache install with APR and setting

1. apache 표준 환경설정


WEB HOME/svc/spi/web/
APACHE HOME${WAS HOME}/apache


2. 디렉토리 생성 및 압축 풀기

디렉토리 생성
[root@tpdb /]# mkdir -p /svc/spi/web
압축파일 카피
[root@tpdb spidb]# pwd
/home/spi
[root@tpdb spidb]# cp ./httpd-2.4.6.tar.gz /svc/spi/web           
[root@tpdb spidb]# cd /svc/spi/web
압축파일 해제
[root@tpdb web]# tar zxvf httpd-2.4.6.tar.gz 


3. 설치 환경설정
Apache를 mpm 방식으로 설치를 하며 설치파일의 httpd-2.2.22/server/mpm/worker 에서 worker.c의 85 line #define DEFAULT_SERVER_LIMIT 16 -> 128로 변경후 install 진행

[root@tpdb worker]# pwd
/svc/spi/web/httpd-2.4.6/server/mpm/worker
[root@tpdb worker]# ll
합계 136
-rw-r--r--. 1 tempuser games    40 2009-11-03 23:36 Makefile.in
-rw-r--r--. 1 tempuser games   457 2009-04-23 14:17 config.m4
-rw-r--r--. 1 tempuser games   180 2011-11-30 19:21 config3.m4
-rw-r--r--. 1 tempuser games 13133 2011-01-28 04:34 fdqueue.c
-rw-r--r--. 1 tempuser games  2543 2011-01-28 04:34 fdqueue.h
-rw-r--r--. 1 tempuser games  1634 2012-01-31 21:02 mpm_default.h
-rw-r--r--. 1 tempuser games  3031 2011-12-05 09:08 pod.c
-rw-r--r--. 1 tempuser games  1810 2009-03-25 00:43 pod.h
-rw-r--r--. 1 tempuser games 90502 2013-05-12 19:38 worker.c
[root@tpdb worker]# vi worker.c 
84 #ifndef DEFAULT_SERVER_LIMIT
85 #define DEFAULT_SERVER_LIMIT 16 <--수정할 것*(32,64,128 등)
86 #endif

그다음 configure실행, 그러나 실행하면 다음 APR에러가 발생할 것이다
먼저 

-apache configure
[root@tpdb httpd-2.4.6]# ./configure --prefix=/svc/spi/web/apache  --enable-so --enable-ssl --with-mpm=worker
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure: 
configure: Configuring Apache Portable Runtime library...
configure: 
checking for APR... no
configure: error: APR not found.  Please read the documentation.


- APR install
다음 명령어를 실행하여 apr 다운로드 실행
(혹시 파일이 없으면 버전이 없는 것이니 http://apr.apache.org/download.cgi 서 확인하고 파일명만 바꾸어주면 됨
다운로드 및 컴파일
[root@tpdb web]# wget http://mirror.apache-kr.org/apr/apr-1.5.0.tar.gz
[root@tpdb web]# tar zxvf apr-1.5.0.tar.gz
[root@tpdb web]# cd apr-1.5.0
[root@tpdb apr-1.5.0]# ./configure 

여기서 gcc에러가 나면 별도 설치해야 함 
설치해야 할게 많기 때문에 별도로 다른 페이지에 설명 예정
다음 링크 참조
http://stoplulker.blogspot.com/2014/02/linux-gcc.html

- 그리고 apr-util다운로드 후 컴파일 진행
[root@tpdb web]# wget http://mirror.apache-kr.org/apr/apr-util-1.5.3.tar.gz
[root@tpdb web]# tar zxvf apr-util-1.5.3.tar.gz
[root@tpdb spidb]# cd apr-util-1.5.3
[root@tpdb apr-util-1.5.3]# ./configure --with-apr=/usr/local/apr
[root@tpdb apr-util-1.5.3]# make; make install

- pcre 설치
다 진행되면 다시 apache configure시작
그러나 다시 할려면  pcre에러가 날 수도 있다
이럴경우 다음 설치
[root@SPIWEB spiweb]# rpm -ivh pcre-devel-7.8-6.el6.x86_64.rpm 

--ssl 에러
이젠 다시 ssl에러가 날 수도 있을 것이다
일단 시간이 없으니 담에 하기로 하고 일단 옵션에 ssl을 생략한다
./configure --prefix=/svc/spi/web/apache  --enable-so  --with-mpm=worker

마지막으로 make;make install을 해준다


이제 ${APACHE_MOE}/bin/apachectl start를 하여 아파치를 실행시킨다
아마 실행시키면 다음과 같이 에러가 날텐데 이것은 httpd.conf파일을 열어 다음 ServerName을 localhost로 바꿔준다

AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message

#ServerName www.example.com:80

ServerName localhost





4. mpm 설정 수정
 - conf/httpd.conf 파일에 httpd-mpm.conf, httpd-default.conf 주석해제 및 설정 변경
[root@uplus conf]# vi httpd.conf
Include conf/extra/httpd-mpm.conf
Include conf/extra/httpd-default.conf



[root@uplus conf]#vi extra/httpd-mpm.conf
# worker MPM
# StartServers: initial number of server processes to start
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestWorkers: maximum number of worker threads
# MaxConnectionsPerChild: maximum number of connections a server process serves
#                         before terminating
<IfModule mpm_worker_module>
    StartServers            10
    MinSpareThreads         75
    MaxSpareThreads        250
    ThreadsPerChild         25
    MaxRequestWorkers      400
    MaxConnectionsPerChild   0
</IfModule>


5. root디렉토리 잡기
 httpd.conf파일을 열어서 documentRoot를 바꿔준다
필요시  useradd명령어를 사용하여 user를 만들어 준다

[root@SPIWEB conf]# pwd
/svc/spi/web/apache/conf
[root@SPIWEB conf]# ll
ÇÕ°è 96
drwxr-xr-x. 2 root root  4096 2014-02-27 15:26 extra
-rw-r--r--. 1 root root 18093 2014-02-27 15:33 httpd.conf
-rw-r--r--. 1 root root 13077 2014-02-27 15:26 magic
-rw-r--r--. 1 root root 53011 2014-02-27 15:26 mime.types
drwxr-xr-x. 3 root root  4096 2014-02-27 15:26 original
[root@SPIWEB conf]# vi httpd.conf 
DocumentRoot "/home/spiweb/documentRoot"
<Directory "/home/spiweb/documentRoot">

이제 index.html파일을 root에 만들어 테스트 하면 되는데 가끔 403 에러가 날 때가 있다
이럴땐 다음을 실행
sudo chown -R $USER:$USER /var/www/folder-name 
sudo chmod -R 755 /var/www



6. log 설정에 cookie추가

<IfModule log_config_module>
    #
    # The following directives define some format nicknames for use with
    # a CustomLog directive (see below).
    #
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" \"%{Cookie}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common


6. log경로 바꿔주기
Apache log의 기본 디렉토리는 ${apache설치디렉토리}/logs 이며  /log/${서비스명}/web/logs에 심볼릭 링크가 되어야함. 
[root@ bin]# mkdir -p /logs/spi/web/logs
[root@ bin]# cd /logs/spi/web/logs
[root@ logs]# mkdir {access-log,error-log}
[root@ logs]# ls
access-log  error-log
[root@ logs]#

[root@ apache]# rm –rf logs
[root@ apache]# ln -s /logs/spi/web/logs logs
[root@ apache]# ll
total 52
drwxr-xr-x  2 root root  4096 Jun  5 10:25 bin
drwxr-xr-x  2 root root  4096 Jun  5 10:25 build
drwxr-xr-x  2 root root  4096 Jun  5 10:25 cgi-bin
drwxr-xr-x  4 root root  4096 Jun  5 10:30 conf
drwxr-xr-x  3 root root  4096 Jun  5 10:25 error
drwxr-xr-x  2 root root  4096 Jan 26 07:24 htdocs
drwxr-xr-x  3 root root  4096 Jun  5 10:25 icons
drwxr-xr-x  2 root root  4096 Jun  5 10:25 include
lrwxrwxrwx  1 root root    19 Jun  5 10:54 logs -> /log/spi/web/logs
drwxr-xr-x  4 root root  4096 Jun  5 10:25 man
drwxr-xr-x 14 root root 12288 Jan 26 07:26 manual
drwxr-xr-x  2 root root  4096 Jun  5 10:25 modules

[root@uplus apache]# vi conf/httpd.conf
#ErrorLog "logs/error_log"
ErrorLog "|/svc/spi/web/apache/bin/rotatelogs -l /svc/spi/web/apache/logs/error-log/error.%Y%m%d 86400"

#CustomLog "logs/access_log" common
CustomLog "|/svc/spi/web/apache/bin/rotatelogs -l /svc/spi/web/apache/logs/access-log/access.%Y%m%d 86400" combined



7. apache sudo 설정
apache권한이 root일경우 서비스 계정(test)으로 실행하기 위해 sudo 설정을 한다.
아래설정은 서비스계정이 apachectl 과 cat, tail, rm, mv 을 서비스계정으로 실행할 수 있게 해주는 설정이다. 
[root@ apache]# vi /etc/sudoers 
root    ALL=(ALL)       ALL
test      ALL=/svc/spi/web/apache/bin/apachectl 
test      ALL=/bin/cat /log/spi/web/*
test      ALL=/usr/bin/tail /log/spi/web/*
test      ALL=/bin/rm /log/spi/web/*
test      ALL=/bin/mv /log/spi/web/*


8. 디렉토리 옵션 설정
기존의 웹 문서외에 다른 파일 시스템에 접근 가능하기 때문에 수정

<Directory>지시자의 Options 을 Option None으로 변경(2군데)
#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other 
# <Directory> blocks below.
#
<Directory />
    AllowOverride none
    Require all denied

</Directory>


<Directory "/home/spiweb/documentRoot">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
AllowOverride FileInfo AuthConfig Limit
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
<Limit OPTIONS PROPFIND>
        Order allow,deny                                                                                          
        Allow from all                                                                                            
</Limit>
    <LimitExcept GET POST>
        Order deny,allow                                                                                          
        Deny from all                                                                                             
    </LimitExcept>


    #                                                                                                             
    # Controls who can get stuff from this server.                                                                
    #                                                                                                             
    Require all granted

</Directory>



9. 디렉토리 권한 변경
[root@spiwba1 apache]# chmod -R 740 conf
[root@spiwba1 conf]# chmod -R 600 *.conf



2014년 2월 21일 금요일

[Apache 튜닝]apache prefork 와 worker 방식

Apache Multi-Processing Modules(MPM, 다중처리모듈)의 Prefork 와 Worker 방식의 비교
Apache Multi-Processing Modules(MPM, 다중처리모듈)의 Prefork 와 Worker 방식의 비교
 ==> apache 서버가 클라이언트에게서 받아들인 요청을 처리하기 위해 "자식 process" 에게 분배하는 방식
Prefork 방식
- 하나의 자식 프로세스가 하나의 쓰레드를 갖는 구조로, 자식 프로세스는 1024까지 늘일 수 있다.
- 한개의 자식 프로세스는 한 개의 연결을 담당한다.
- 프로세스가 생성되는 구조이므로 당연히 worker보다는 많은 메모리를 사용함.
- 프로세스간 메모리를 직접 공유하지 않으므로, 메모리 공간이 독립적이어서 안정적임
httpd.conf에서 httpd-mpm.conf 파일을 include 시켜야 한다.
httpd-mpm.conf 파일에서
  <IfModule mpm_prefork_module>
      StartServers 5
      MinSpareServers 5
      MaxSpareServers 10
      MaxClients 150
      MaxRequestsPerChild 0
  </IfModule>

옵션 설명
StartServer: 아파치서버의 자식 프로세스 개수 지정
MinSpareServers, MaxSpareServers :
부하가 적어서 MinSpareServers 개수 보다 적었을 경우 최소한 이 개수 만큼 유지하려고 아파치가 노력하고
부하가 증가하여 프로세스 개수가 많아질 경우에 MaxSpareServers 개수 이하로 줄이려고 아파치는 노력한다.
즉, 절대적인 수치가 아니다.
MaxClient : 초기 시작시 실행가능한 최대 아파치 자식 프로세스의 개수를 지정
            worker방식의 MaxClient 와는 전혀 다른 의미가 다르지만 결국 클라이언트의 요청을 처리하는 용량을 말하므로 사실상 유사.
MaxReqeustPerChild :클라이언트들의 요청 개수를 제한.
           만약 자식 프로세스가 이 값만큼의 클라이언트 요청을 받았다면 이 자식 프로세스는 자동으로 죽게 된다.
           0 인 경우 무한대임.
Maxclient 를 늘리기 위한 설정 ( Prefork 방식일 경우 )
  1) apache 1.x 버전
    Apache 소스 디렉토리/src/include/httpd.h 에서
    define HARD_SERVER_LIMIT 256  ----> 512 혹은 1024 등으로 변경 저장후 컴파일
  2) apache 2.x~ 2.2.x 버전
    apache소스디렉토리/server/mpm/prefork/prefork.c 에서
    define DEFAULT_SERVER_LIMIT 256 ----> 512 혹은 1024 등으로 변경후 재부팅


image

image