서버(Server)를 아파치로 구축했다면 내 서버에

  • 몇명이 접속 했는지,
  • 어떤 페이지가 가장 호출되었는지,
  • 어느 국가에서 접속했는지,
  • 어떤 IP에서 접근했는지,
  • 머무른 시간은 어떠한지,
  • 어떤 파일을 다운로드 받았는지 등

수 많은 정보를 서버로그를 통해 다음과 같이 분석할 수 있습니다.


우분투환경에서 아파치 서버로그는 awstats를 이용하여 분석합니다.


1. awstats 패키지 설치
  • 다음 명령어로 awstats를 설치합니다.
  • geo 라이브러리는 방문자를 나라별로 분류해서 볼 수 있게 하기위해 설치합니다.
$ sudo apt-get install awstats libgeoip1 libgeoip-dev libgeo-ip-perl

2. awstats 환경 설정
$ sudo vim /etc/awstats/awstats.conf
  • 122번째줄 : LogFormat=4 를 LogFormat=1 로 변경. ubuntu apache 기본값이 1번입니다.
  • 153번째줄 : SiteDomain=”” 를 SiteDomain=”mydomain.com” 로 변경. 작업중인 파일명을 참고하여 변경하세요.
  • 168번째줄 : HostAliases=”localhost 127.0.0.1” 를 HostAliases=mydomain.com localhost 127.0.0.1” 로 변경. 현재 설정파일과 동일하게 취급할 도메인을 띄어쓰기를 구분자로 하여 적어줍니다.
  • 188번째줄 : DNSLookup=1 을 DNSLookup=0 으로 변경. dnslookup 은 부하가 많이 걸리므로 꺼두는게 좋습니다.
  • 905번째줄 : Lang=”auto” 를 Lang=”ko” 로 변경. 강제로 한국어를 지정합니다. awstats에는 한글UI를 지원합니다.
  • 1305번째줄 : LoadPlugin=”hashfiles” 를 LoadPlugin=”geoip GEOIP_STANDARD /usr/share/GeoIP/GeoIP.dat” 로 변경. 방문자를 나라별로 분류해서 볼 수 있습니다.

3. awstats 보안 설정
# awstats.도메인명.conf 를 자동으로 불러옴
$ sudo cp /etc/awstats/awstats.conf /etc/awstats/awstats.windwing.co.kr.conf

# 보안을 위해서 기본샘플파일인 awstats.conf 파일명을 awstats.conf_ 로 변경
$ sudo mv /etc/awstats/awstats.conf /etc/awstats/awstats.conf_

4. 아파치 환경 설정
  • 아파치 환경설정 파일을 읽어옵니다.
$ sudo vim /etc/apache2/sites-enabled/000-default
  • 환경설정 파일에서 VirtualHost 태그 안에 awstats 설정 추가합니다.
<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www

    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>


    ## -- awstats 설정 ##
    Alias /awstatsclasses "/usr/share/awstats/lib/"
    Alias /awstats-icon/ "/usr/share/awstats/icon/"
    Alias /awstatscss "/usr/share/doc/awstats/examples/css"

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ...
</VirtualHost>
  • 아파치 서버 재시작
$ sudo /etc/init.d/apache2 restart

5. 로그정보 업데이트
  • 시스템에서 주기적으로 업데이트 하기위해 crontab 설정합니다. (반드시 sudo를 붙여 관리자 crontab에 등록)
sudo crontab -e
  • 다음과같이 crontab에 awstats 업데이트 구문을 등록합니다. (30분 주기)
# awstats
00,30 * * * * /usr/lib/cgi-bin/awstats.pl -config=mydomain.com -update > /dev/null

6. 결과 확인



references


'개발이야기 > Linux' 카테고리의 다른 글

Ubuntu 이클립스 실행오류 해결  (4) 2012.09.26
Ubuntu 12.04에서 java 설치  (0) 2012.09.12
ptrace 설명 및 사용법  (0) 2012.07.19

안드로이드 폰을 루팅하였음에도 불구하고 커멘드에서 adb shell 을 입력하였을때 바로 su 권한을 얻지못하고 $표시로 나오는경우, 아래와 같은 방법으로 su 권한을 획득할 수 있다.

1. adb shell 

2. su  

3. mount -o remount,rw /system (or: adb remount)

4. ls -la /system/bin/sh
   lrwxr-xr-x root shell 2012-11-10 15:20 sh -> mksh  

5. chmod 4755 /system/bin/sh

6. ls -la /system/bin/mksh 
   -rwsr-xr-x root shell 157520 2012-11-10 09:54 mksh (notice the suid bit is set)  

7. ^D (exit) 

8. adb shell


su 권한을 획득하면 개발환경에서 프로그램의 빌드후 실행이나 adb install 명령어 설치등 제대로 동작하지 않는다.

따라서 이때는 su권한을 풀어주어야 한다.

1. adb shell

2. mount -o remount,rw /system (or: adb remount)

3. chmod 755 /system/bin/sh

4. ^D (exit)

5. adb shell


'개발이야기 > Android' 카테고리의 다른 글

이클립스에서 NDK 디버깅하기  (3) 2012.11.01
1. CDT 설치
The NDK plugin currently works with CDT 7.0.2 or CDT 8.0.2.
    1. Download Eclipse for Java.
    2. Install CDT from Eclipse update site http://download.eclipse.org/tools/cdt/releases/indigo. (indigo: 버전이름)
    3. Install Android SDK + NDK Plugins from Eclipse update site https://dl-ssl.google.com/android/eclipse/

2. NDK 플러그인 사용
1. First set the path to SDK and NDK:
    Eclipse -> Window -> Preferences -> Android -> set path to SDK
    Eclipse -> Window -> Preferences -> Android -> NDK -> set path to the NDK

2. Right click on an Android project and select `Android Tools -> Add native support`.
Note that you will not be able to add native support if the project already has C/C++ nature.

At this point, you will be able to build your applications using Project -> Build All.

3. NDK 디버깅
1. Update your build config to include NDK_DEBUG = 1.
    Right click project -> properties -> C/C++ Build:
2. Set a breakpoint in your C code. 3. Right click on your project, select Debug As -> Android Native Application Note: There is a delay of a few seconds between when the activity is launched and when native debugging starts. If your code is already executed by that point, then you won’t see the breakpoint being hit. So either put a breakpoint in code that is called repetitively, or make sure that you call JNI code after you see that ndk-gdb has connected.

4. 이클립스 환경설정
Eclipse -> Window -> Preferences -> C/C++ -> Code Analysis
Syntax and semantic Errors 체크 해제 (체크 해제 안할 경우 구문에러 인식하여 빌드되지 않습니다.)


참조: http://tools.android.com/recent/usingthendkplugin


'개발이야기 > Android' 카테고리의 다른 글

안드로이드 ADB Shell 권한변경 (su)  (0) 2013.01.02