Tag Archives: mod_deflate

Home »  Tag: mod_deflate

Redirect

vi /usr/local/apache/conf/extra/httpd-vhosts.conf
– 설정 전
DocumentRoot “/home/master/xe”
ServerName msnote.co.kr
ErrorLog “/home/master/xe/msnote.co.kr-error_log”
CustomLog “/home/master/xe/msnote-access_log” common
– 설정후
# DocumentRoot “/home/master/xe”
ServerName msnote.co.kr
RedirectMatch /(.*)$ http://리다이렉트시킬도메인/$1
ErrorLog “/home/master/xe/msnote.co.kr-error_log”
CustomLog “/home/master/xe/msnote-access_log” common

mod_deflate

아파치 모듈에 mod_deflate가 추가되있어야함.
아파치 2.x 이상에서는 설치시 기본으로 설치됨.
# vi /usr/local/apache/conf/httpd.conf

 
<IfModule mod_deflate.c>
DeflateCompressionLevel 3
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/atom_xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE application/x-httpd-fastphp
AddOutputFilterByType DEFLATE application/x-httpd-eruby
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE audio/midi
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI \.(?:png|jpe?g|gif)$ no-gzip dont-vary
Header append Vary User-Agent env=!dont-vary
</IfModule>
 

– DeflateCompressionLevel 2
-> 압축률 2~3이 적당. (0~9까지 설정가능 압축률이 높을 수록 CPU부하 발생)
– SetEnvIfNoCase Request_URI \.(?:png|jpe?g|gif)$ no-gzip dont-vary
-> 이미지 파일은 압축에서 제외
[출처]http://yangyonge.tistory.com 천사와 악마의 감미로운 공존

apache 접속자확인

현제 접속중인 세션
netstat -anp | grep “:80″ | grep “ESTABLISHED” | wc -l
현재 접속중인 ip

netstat -anp | grep “:80″ | grep “ESTABLISHED” | sed “s/:/ /g” | awk ‘{print $6}’ | sort -n | uniq -c | wc -l

httpd-mpm.conf

httpd-mpm.conf 수정
– 경로 : $APACHE_HOME/conf/extra/httpd-mpm.conf
* httpd.conf에서 설정한 경로를 따라간다.
============================
 
ServerLimit 16 => 구성가능한 child 프로세스의 재한 수
StartServers 16 => 시작시에 초기화되는 서버 프로세스의 개수 (default : 3) / prefork default:5, mpmt_os2 default 2
MaxClients 150 => 동시에 접속할 수 있는 Client의 상한, 즉 Precess 수 x Thread 수
MinSpareThreads 25 => 새로운 방문자를 바로 처리하기 위하여 대기하고 있는 최소 쓰레드 개수
MaxSpareThreads 75 => 새로운 방문자를 바로 처리하기 위하여 대기하고 있는 최대 쓰레드 개수(보통 ThreadsPerChild 값이랑 같게 설정)
ThreadsPerChild 25 => 프로세스당 쓰레드 수(ThreadLimit와 거의 같은 의미)
MaxRequestsPerChild 0 => 자식프로세스가 서비스할 수 있는 최대 요청 개수(0은 무한대),
오래된 프로세스들을 죽이고 새로운 프로세스를 시작하는 것에 의해 프로세스 리사이클 주기를 얼마나 할지 설정
 
============================
* 프로세스 개수
– Active Child Process의 최대 개수는 MaxClients 값과 ThreadsPerChild 값의 의해서 계산된다.
– 만약, MaxClients를 4096으로 하고, ThreadPerChild를 128로 하면
MaxClients(4096) / ThreadPerChild(128) = 32
따라서 32개의 프로세스가 생성된다.
– 이 수치를 변경할 경우 Apache를 완전히 재시작 해야 함.
옵션 세부 설명
ServerLimit (default : 16)
– 구성 가능한 child 프로세스의 […]

memory map | error.log에 지속적으로 나올때…

*** glibc detected *** /usr/local/apache/bin/httpd: double free or corruption (!prev): 0x0000000008977ab0 ***
======= Backtrace: =========
/lib64/libc.so.6[0x336367247f]
/lib64/libc.so.6(cfree+0x4b)[0x33636728db]
/lib64/libc.so.6[0x336361eb95]
/lib64/libc.so.6(iconv_close+0xf)[0x336361e1ef]
/usr/local/apache/modules/mod_url.so(check_redurl_iconv+0×164)[0x2aaab17c55d4]
/usr/local/apache/modules/mod_url.so[0x2aaab17c6318]
/usr/local/apache/bin/httpd(ap_run_translate_name+0x4a)[0x431d9a]
/usr/local/apache/bin/httpd(ap_process_request_internal+0×136)[0x433e26]
/usr/local/apache/bin/httpd(ap_process_request+0×168)[0x444108]
/usr/local/apache/bin/httpd[0x4413dc]
/usr/local/apache/bin/httpd(ap_run_process_connection+0x4a)[0x43d94a]
/usr/local/apache/bin/httpd[0x448ff4]
/lib64/libpthread.so.0[0x3363e0677d]
/lib64/libc.so.6(clone+0x6d)[0x33636d49ad]
======= Memory map: ========
00400000-00468000 r-xp 00000000 08:03 426194 /usr/local/apache/bin/httpd
00668000-0066d000 rw-p 00068000 08:03 426194 /usr/local/apache/bin/httpd
0066d000-00670000 rw-p 0066d000 00:00 0
0833e000-089a0000 rw-p 0833e000 00:00 0 [heap]
4007d000-4007e000 —p 4007d000 00:00 0
4007e000-40a7e000 rwxp 4007e000 00:00 0
40a7e000-40a7f000 —p 40a7e000 00:00 0
40a7f000-4147f000 rwxp 40a7f000 00:00 0
4147f000-41480000 —p 4147f000 00:00 0
41480000-41e80000 rwxp 41480000 00:00 0
41e80000-41e81000 —p 41e80000 00:00 0
41e81000-42881000 rwxp 41e81000 00:00 0
42881000-42882000 —p 42881000 00:00 0
42882000-43282000 rwxp 42882000 00:00 0
43282000-43283000 —p 43282000 00:00 0
43283000-43c83000 rwxp 43283000 00:00 0
43c83000-43c84000 —p 43c83000 00:00 0
43c84000-44684000 rwxp 43c84000 00:00 0
44684000-44685000 —p 44684000 00:00 0
44685000-45085000 rwxp 44685000 00:00 0
45085000-45086000 —p 45085000 00:00 0
45086000-45a86000 rwxp 45086000 00:00 0
45a86000-45a87000 —p 45a86000 00:00 0
45a87000-46487000 rwxp 45a87000 00:00 0
46487000-46488000 —p 46487000 00:00 0
46488000-46e88000 rwxp 46488000 00:00 0
46e88000-46e89000 —p 46e88000 00:00 0
46e89000-47889000 rwxp 46e89000 00:00 0
47889000-4788a000 —p 47889000 00:00 0
4788a000-4828a000 rwxp 4788a000 00:00 0
4828a000-4828b000 —p 4828a000 00:00 0
4828b000-48c8b000 rwxp 4828b000 00:00 0
48c8b000-48c8c000 —p 48c8b000 […]

mysql dump에 바이너리 위치 및 pos 기록하기

mysqldump -u root -p –master-data=2 –all-databases –no-autocommit=1 –single-transaction=1 –extended-insert=1 > 이름.sql
-e or -p : -e는 /root/.my.cnf에 저장된 PW 사용// -p는 직접입력
–master-data=2 : 바이너리 로그에 어디까지 덤프가 떠졋는지 기록됨!!
–all-databases : 모든 databases
–no-autocommit=1 –single-transaction=1 : 속도 단축을 위해서 사용
복원
mysql -u root -p < 파일명.sql

mysql my.cnf 설정

# Example MySQL config file for very large systems.
#
# This is for a large system with memory of 1G-2G where the system runs mainly
# MySQL.
#
# MySQL programs look for option files in a set of
# locations which depend on the deployment platform.
# You can copy this option file to one of those
# locations. For information about these locations, see:
# http://dev.mysql.com/doc/mysql/en/option-files.html
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the “–help” option.
# The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-external-locking
skip-name-resolve // 사용시 mysql 지연현상 줄일수있씀.
key_buffer_size = 8G // RAM에 50~80%사용 DB서버로만사용시
max_allowed_packet = 64M //
table_open_cache = 1024 //
sort_buffer_size = 2M
read_buffer_size = 2M //
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M //
thread_cache_size = 8
query_cache_size = 32M
# […]

mysql 백업 복구

백업하기
1) DB별로 백업
mysqldump -u root -p DB명 > 파일명.sql
암호입력 (Enter)
2) 전체 백업
mysqldump -u root -p –all-databases > 파일명.sql
암호입력 (Enter)
3) 캐릭터셋 옵션을 이용하여 백업
mysqldump -u root -p –default-character-set=euckr DB명 > 파일명.sql
암호입력 (Enter)
(euckr, utf8 등이 있음)
4) 특정 테이블만 덤프
mysqldump -u root -p DB명 테이블명 > 파일명.sql
mysqldump -u root -p -B DB명 –tables 테이블명1 테이블명2 테이블명3 > 파일명.sql
5) 테이블 구조만 백업
mysqldump -u root -p –no-data DB명 > 파일명.sql
6) XML 파일로 백업
mysqldump -u root -p –xml DB명 > 파일명.sql
복구 하기
1) DB별로 복구
mysql -u root -p DB명 < 파일명.sql
암호입력 (Enter)
2) 전체 복구
mysql -u root -p < 파일명.sql
암호입력 (Enter)
3) 캐릭터셋 옵션을 이용하여 백업 복구
mysqldump -u root -p –default-character-set=euckr DB명 < 파일명.sql
암호입력 (Enter)
(euckr, utf8 등이 있음)
mysql 설정파일
/etc/my.cnf
/usr/local/mysql/data
mysql 이 설치된 디렉토리 전체 백업
cp -arp >> 모든 권한 복사
삭제
rm -rf << 디렉토리 파일구분없이 다삭제

mysql 접속허용 및 사용자추가

SELECT user,Host FROM mysql.user; // 확인
INSERT INTO mysql.user (host,user,password) VALUES (‘localhost’,’root’,password(‘$PASSWORD‘)); // 추가
GRANT ALL PRIVILEGES ON *.* TO ‘root’@’$IP‘; // 접근지 설정
FLUSH PRIVILEGES; // 적용
update user set password=password(‘$PASSWORD‘) where user=’root’; // 패스워드변경
사용자 추가~~
insert into user (host, user, password) values(‘localhost’, ‘$ID, password(‘$PASSWORD’));

devedot 설치

출처 // https://www.sulinux.net/bbs/board.php?bo_table=success_2&wr_id=133 삽질쟁님감사요~
소스는 아래 사이트에서 구한다.
http://dovecot.org/
# wget http://dovecot.org/releases/1.1/dovecot-1.1.2.tar.gz
# tar xvfz dovecot-1.1.2.tar.gz
# cd dovecot-1.1.2
# ./configure –prefix=/usr –localstatedir=/var –with-pam –with-gssapi –with-mysql
# make
# make install
# cp /usr/etc/dovecot-example.conf /usr/etc/dovecot.conf
# groupadd -g 97 dovecot
# useradd -u 97 -g 97 -d /usr/libexec/dovecot -s /sbin/nologin dovecot
편집기로 환경설정 파일인 dovecot.conf 을 아래와 같이 내용 작성한다.
# vi /usr/etc/dovecot.conf
protocols = imap pop3
disable_plaintext_auth = no
ssl_disable = yes
protocol imap {
}
protocol pop3 {
}
auth default {
mechanisms = plain
passdb passwd {
}
passdb shadow {
}
userdb passwd {
}
user = root
}
plugin {
}
mail_privileged_group = mail
실행 커맨드는 아래와 같다.
# /usr/sbin/dovecot
아래와 같이 출력된다면 dovecot이 잘 올라온 상태이다.
[root@digimoon modules]# netstat -nlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:50022 0.0.0.0:* LISTEN 18505/xinetd
tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 18505/xinetd
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 18313/mysqld
tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 3523/smbd
tcp 0 0 0.0.0.0:110 0.0.0.0:* LISTEN 21245/dovecot
tcp 0 0 0.0.0.0:143 0.0.0.0:* LISTEN 21245/dovecot
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 18505/xinetd
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 19307/sendmail: acc
tcp 0 0 […]