아파치 mod_deflate 압축 기능 동작 확인 방법



deflate 환경 설정은 아래와 같습니다.

<IfModule mod_deflate.c>

        SetOutputFilter DEFLATE

        AddOutputFilterByType DEFLATE text/javascript

        DeflateCompressionLevel 9

</IfModule>


압축기능 적용전 테스트할 파일을 다운로드 합니다.

# wget -O /var/www/html/jquery.min.js http://code.jquery.com/jquery.min.js


압축기능을 적용하고 아파치를 재시작한 다음에 다운로드 합니다.

# wget --header="Accept-Encoding:gzip" http://localhost/jquery.min.js

# ls -l /var/www/html/jquery.min.js*

-rw-r--r-- 1 root root     95821 10월 24  2014 jquery.min.js

-rw-r--r-- 1 root root     33185 10월 24  2014 jquery.min.js.1


jquery.min.js 파일이 mod_deflate 를 설정하기전에 받은 원본파일이고


jquery.min.js.1 파일이 압축 전송된 파일입니다.


그리고 http://www.whatsmyip.org/http-compression-test/ 여기에서도 확인이 가능합니다.



블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

리눅스 GeoIP 로 접속 국가 확인



특정 IP의 접속 국가를 알고 싶을때 유용한 유틸이다.


IP 또는 도메인으로 확인이 가능하다.


▶ geoip 설치


# yum install -y geoip



▶ 접속국가 확인


[root@conoha-jp /]# geoiplookup baidu.com

GeoIP Country Edition: CN, China


[root@conoha-jp /]# geoiplookup 220.181.57.217

GeoIP Country Edition: CN, China


[root@conoha-jp /]# geoiplookup -i naver.com

GeoIP Country Edition: KR, Korea, Republic of

  ipaddr: 125.209.222.142

  range_by_ip:  125.209.192.0 - 125.209.255.255

  network:      125.209.192.0 - 125.209.255.255 ::18

  ipnum: 2110905998

  range_by_num: 2110898176 - 2110914559

  network num:  2110898176 - 2110914559 ::18

-i 옵션으로 디테일한 정보까지 볼 수도 있다.

IPv6 는 geoiplookup6 로 확인하면 된다.



▶ geoip DB 업데이트


[root@conoha-jp /]# geoipupdate

/usr/share/GeoIP/GeoLiteCountry.dat can't be opened, proceeding to download database

Updating /usr/share/GeoIP/GeoLiteCountry.dat

Updated database

/usr/share/GeoIP/GeoLiteCity.dat can't be opened, proceeding to download database

Updating /usr/share/GeoIP/GeoLiteCity.dat

Updated database

가끔씩 업데이트를 해주면 된다.



블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

CentOS 7.x SVN Subversion 설치 방법



리눅스는 SVN 서버, 윈도우는 SVN 클라이언트 접속방법에 대해서 알아보자.


1. subversion 설치

# yum install -y subversion


2. 프로젝트 폴더 생성

# mkdir /var/svn

# svnadmin create /var/svn/P0001

/var/svn 디렉토리를 미리 생성해 주어야 한다.


3. 프로젝트 설정 ( vi /var/svn/P0001/conf/svnserve.conf )

[general]

# auth-access = write

# password-db = passwd

auth-access = write

password-db = passwd

주석 처리된 것을 찾아서 풀어주자.

맨 앞에 공백까지 지워줘야 한다.


4. 프로젝트 계정 설정 ( vi /var/svn/P0001/conf/passwd )

[users]

# harry = harryssecret

# sally = sallyssecret

svnid=test123

계정과 비밀번호를 한줄에 하나씩 추가해주면 된다.


5. subversion 데몬 시작

# systemctl enable svnserve

# systemctl start svnserve

에러가 난다면 systemctl status svnserve 로 체크해서 수정해주자.


6. subversion 포트 방화벽 설정

# firewall-cmd --permanent --zone=public --add-port=3690/tcp

success

# firewall-cmd --reload

success

# firewall-cmd --list-all

public (default, active)

  interfaces: eth0 eth1

  sources:

  services: dhcpv6-client http ssh

  ports: 3690/tcp

  masquerade: yes

  forward-ports:

  icmp-blocks: echo-request

  rich rules:

3690 포트를 추가해주면 된다.



이제 윈도우에서 SVN 클라이언트 프로그램을 설치하고 접속해보자.


http://tortoisesvn.tigris.org/ 에서 다운로드 할 수 있다.


크롬브라우저에서 안되면 파이어폭스나 익스플로러에서 다운 받으면 된다.


설치를 했다면 접속주소는 svn://도메인주소/P0001 이렇게 형식이다.


커밋을 하게되면 비밀번호를 물어보는 팝업이 자동으로 뜰 것이다.


위에서 설정한 계정정보를 입력하면 된다.


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

리눅스 모니터링툴 htop



리눅스에서 기본적으로 제공되는 top 보다는 좀 더 세밀한 기능이 있는 htop 이다.


설치는 CentOS 의 경우 yum install htop 으로 설치할 수 있다.



실행하면 디폴트로 보여지는 화면이다.

상단에 CPU Core 만큼 사용률을 보여주고, 메모리 및 스왑 메모리 사용량을 보여준다.




F4 키를 눌러서 특정 프로세스를 필터링 할 수 있다.




F5 키는 pstree 처럼 트리 형태로 보여진다.



블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

DNS 라운드로빈 로드밸런싱 방법



DNS 설정으로 로드밸런싱 하는 방법이다.


nslookup 으로 확인해 보면 다중의 IP 여러개가 번갈아가면서 나오는 것을 확인할 수가 있다.


설정 방법은 두가지가 있다.



▶ CNAME 레코드를 활용한 A 레코드 설정


www     IN      CNAME   host.example.com.

host    600     IN      A       192.168.1.101

        600     IN      A       192.168.1.102

        600     IN      A       192.168.1.103

        600     IN      A       192.168.1.104

        600     IN      A       192.168.1.105


아래 처럼 TTL을 안넣고 해도 된다.

www     IN      CNAME   host.example.com.

host    IN      A       192.168.1.101

        IN      A       192.168.1.102

        IN      A       192.168.1.103

        IN      A       192.168.1.104

        IN      A       192.168.1.105



▶ A 레코드 설정


www IN      A       192.168.1.101

        IN      A       192.168.1.102

        IN      A       192.168.1.103

        IN      A       192.168.1.104

        IN      A       192.168.1.105


요즘은 CNAME 으로 많이 사용하는 듯 하다.


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

아파치 Directory index forbidden by Options directive 에러메세지




Directory index forbidden by Options directive: /home/example/www/testdir/


이런 에러 메시지가 error_log 에 기록된다면 크게 신경쓸 일은 아닌 것 같다.


URL 호출시 아파치 설정파일에 DirectoryIndex 설정에서 정의된 파일이 없으면 에러 로그에 기록이 된다.


DirectoryIndex index.html index.php index.html.var


http://www.example.com/testdir 로 url 을 열었을때 해당 디렉토리에 위의 파일을 찾지 못하면 에러로 기록 된다는 의미이다.



<Directory "/home/*/www">

    ...

    Options Indexes FollowSymLinks

    ...

</Directory>


위 처럼 설정해서 에러가 기록되지 않고 해당 디렉토리의 리스트를 보여줄 수도 있지만 보안상 좋지 않기 때문에


Indexes 는 안 넣어주는게 맞는 것 같다.


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

아파치 AH00558 워닝 해결



# httpd -t 로 configtest 를 하면 아래 처럼 에러 메시지가 나오는 경우가 있다.


[root@conoha conf.d]# httpd -t

AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::1:85ff:fe82:65e8. Set the 'ServerName' directive globally to suppress this message

Syntax OK


에러까지는 아니라서 아파치 구동에는 문제가 없다.


하지만 찜찜하다면 에러가 안나오도록 수정해주자.


# vi /etc/httpd/conf/httpd.conf 에서 아래 부분을 찾아서 자신의 도메인주소를 넣고 저장


#ServerName www.example.com:80

ServerName www.mydomain.com:80


# apachectl restart



블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

CentOS 7.x 아파치 재시작 명령어



7.x 버전에서 아파치 재시작 명령어가 바뀌었다.


# service httpd reload ( apachectl graceful )

# service httpd restart ( apachectl restart )


위 명령어가 아래 처럼 바뀌었다.


# systemctl reload httpd.service

# systemctl restart httpd.service



모듈관련 설정이 아닌 VirtualHost 추가와 같은 경우는 apachectl graceful 로 재시작을 해주면 된다.


참고로 restart 옵션은 종료 후 재시작이고, reload 는 진행중인 프로세스는 종료될 때까지 기다렸다가 재시작 해준다.



블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

아파치 deflate 압축기능 활성화 상태에서 php ob_start 속도 테스트



MySQL 데이터를 100개 행을 출력하는 PHP 소스에서 테스트를 진행하였습니다.


테스트는 시작과 끝에 아래의 코드를 사용

<?$_st=microtime(true);?>

<?$_et=microtime(true);printf("loading time : %0.4f",($_et - $_st));?>


<?$_st=microtime(true);ob_start();?>

<?ob_end_flush();$_et=microtime(true);printf("loading time : %0.4f",($_et - $_st));?>


<?$_st=microtime(true);ob_start("ob_gzhandler");?>

<?ob_end_flush();$_et=microtime(true);printf("loading time : %0.4f",($_et - $_st));?>


1. 그냥 속도

loading time : 0.0081


2. ob_start 사용 속도

loading time : 0.0084


3. ob_start("ob_gzhandler") 압축 사용 속도

loading time : 0.0105


테스트한 결과 오히려 속도가 느려지는 결과가 나왔습니다.


아파치 deflate 기능이 활성화 상태에서는 ob_start 함수 사용은 의미가 없다는 아니 오히려 더 느려진다는 결론입니다.



참고로 아파치 deflate 설정은 아래와 같습니다.

<IfModule mod_deflate.c>

        AddOutputFilterByType DEFLATE text/plain

        AddOutputFilterByType DEFLATE text/html

        AddOutputFilterByType DEFLATE text/xml

        AddOutputFilterByType DEFLATE text/css

        AddOutputFilterByType DEFLATE text/javascript

        AddOutputFilterByType DEFLATE image/svg+xml

        AddOutputFilterByType DEFLATE image/x-icon

        AddOutputFilterByType DEFLATE application/xml

        AddOutputFilterByType DEFLATE application/xhtml+xml

        AddOutputFilterByType DEFLATE application/rss+xml

        AddOutputFilterByType DEFLATE application/javascript

        AddOutputFilterByType DEFLATE application/x-javascript


        DeflateCompressionLevel 1


        BrowserMatch ^Mozilla/4 gzip-only-text/html

        BrowserMatch ^Mozilla/4\.0[678] no-gzip

        BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

        BrowserMatch \bOpera !no-gzip

</IfModule>


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

MySQL MySQLTuner script

LINUX 2016. 8. 18. 12:50

MySQL MySQLTuner script



MySQL 튜닝 스크립트입니다.

설치한 다음에 실행만 하면 됩니다.


# yum -y install mysqltuner


[root@conoha-jp ~]# mysqltuner

Please enter your MySQL administrative login: root

Please enter your MySQL administrative password:  >>  MySQLTuner 1.6.0 - Major Hayden <major@mhtx.net>

 >>  Bug reports, feature requests, and downloads at http://mysqltuner.com/

 >>  Run with '--help' for additional options and output filtering

[--] Skipped version check for MySQLTuner script

[OK] Currently running supported MySQL version 5.5.50-MariaDB

[OK] Operating on 64-bit architecture


-------- Storage Engine Statistics -------------------------------------------

[--] Status: +ARCHIVE +Aria +BLACKHOLE +CSV +FEDERATED +InnoDB +MRG_MYISAM

[!!] InnoDB is enabled but isn't being used

[OK] Total fragmented tables: 0


-------- Security Recommendations  -------------------------------------------

[OK] There is no anonymous account in all database users

[OK] All database users have passwords assigned

[!!] There is not basic password file list !


-------- Performance Metrics -------------------------------------------------

[--] Up for: 2m 17s (58 q [0.423 qps], 16 conn, TX: 32K, RX: 2K)

[--] Reads / Writes: 75% / 25%

[--] Binary logging is disabled

[--] Total buffers: 416.0M global + 2.8M per thread (151 max threads)

[OK] Maximum reached memory usage: 418.8M (42.17% of installed RAM)

[OK] Maximum possible memory usage: 836.0M (84.19% of installed RAM)

[OK] Slow queries: 0% (0/58)

[OK] Highest usage of available connections: 0% (1/151)

[!!] Aborted connections: 18.75%  (3/16)

[!!] Query cache is disabled

[OK] Temporary tables created on disk: 0% (0 on disk / 4 total)

[!!] Thread cache is disabled

[OK] Table cache hit rate: 178% (41 open / 23 opened)

[OK] Open file limit used: 4% (51/1K)

[OK] Table locks acquired immediately: 100% (43 immediate / 43 locks)


-------- MyISAM Metrics -----------------------------------------------------

[!!] Key buffer used: 18.2% (24M used / 134M cache)

[OK] Key buffer size / total MyISAM indexes: 128.0M/99.0K

[!!] Read Key buffer hit rate: 83.3% (6 cached / 1 reads)


-------- InnoDB Metrics -----------------------------------------------------

[--] InnoDB is disabled.

[!!] InnoDB Storage engine is disabled. InnoDB is the default storage engine


-------- AriaDB Metrics -----------------------------------------------------

[--] AriaDB is disabled.


-------- Replication Metrics -------------------------------------------------

[--] No replication slave(s) for this server.

[--] This is a standalone server..


-------- Recommendations -----------------------------------------------------

General recommendations:

    Add skip-innodb to MySQL configuration to disable InnoDB

    MySQL started within last 24 hours - recommendations may be inaccurate

    Enable the slow query log to troubleshoot bad queries

    Reduce or eliminate unclosed connections and network issues

    Set thread_cache_size to 4 as a starting value

Variables to adjust:

    query_cache_size (>= 8M)

    thread_cache_size (start at 4)


테스트 한 서버는 DB를 사용하지 않고 있어서 나온 결과값입니다.


단순 참고용으로만 보세요~


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,