우분투 12.04

jdk7

tomcat7

apache2 를 이용하였다.


1. jdk 설치

apt-get install python-software-properties

apt-add-repository ppa:webupd8team/java apt-get update apt-get install oracle-jdk7-installer java -version /* 자바 버젼 확인 */


root@JDK:~# java -version java version "1.7.0_67" Java(TM) SE Runtime Environment (build 1.7.0_67-b01) Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)



2. apache2 설치

apt-get install apache2


3. tomcat7 설치

apt-get install tomcat7

apt-get install libapache2-mod-jk (tomcat-apache 연결 커넥터)


4. mod_jk 설정

vi /etc/libapache2-mod-jk/workers.properties


# 실제 톰캣이 설치되어 있는 경로 

#

workers.tomcat_home=/usr/share/tomcat7


#

# 실제 java가 설치되어 있는 경로

#

workers.java_home=/usr/lib/jvm/java-7-oracle



5. vi /var/lib/tomcat7/conf/server.xml

<!-- Define an AJP 1.3 Connector on port 8009 -->

<!--    주석 제거

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

-->    주석 제거


6. proxy_AJP 활설화

a2enmod proxy_ajp

service apache2 restart


7. apache2 설정

vi /etc/apache2/sites-available/default


  DocumentRoot /var/lib/tomcat7/webapps/ROOT

        <Directory />

                Options FollowSymLinks

                AllowOverride None

        </Directory>

        <Directory /var/lib/tomcat7/webapps/ROOT>

                Options Indexes FollowSymLinks MultiViews

                AllowOverride None

                Order allow,deny

                allow from all

        </Directory>

 

        #Apache의 DocumentRoot와 Tomcat의 webapps/ROOT를 같은 곳을 바라보게 설정

        ProxyPass /servlet/ ajp://localhost:8009/servlet/

        ProxyPassMatch ^/.*\.(jsp|do)$ ajp://localhost:8009


8. jsp 테스트

vi /var/lib/tomcat7/webapps/ROOT/hello.jsp

  <HTML>

  <BODY>

     Hello!  The time is now <%= new java.util.Date() %>

  </BODY>

</HTML>


9. tomcat, apache2 재시작

/etc/init.d/tomcat7 restart

/etc/init.d/apache2 restart


10. http://서버IP/hello.jsp


-- 추가사항

* no JDK found - please set JAVA_HOME


JDK 오류 시 수정사항


# vi /etc/default/tomcat7

JAVA_HOME=/usr/lib/jvm/java-7-oracle

수정




도움받은 url

http://stove99.tistory.com/154

http://noviceany.tistory.com/37

http://polaris.vartist.org/166


by 초보인척 2014. 9. 20. 19:12

시작 - 실행


control passwords2   - 확인.




사용자 이름과 암호를 입력해야 이 컴퓨터를 사용할 수 있음 - 체크박스 해제


확인.


패스워드 입력 후 확인.


끝.


이제 재부팅 해도 자동로그인 될 것이다.



도움받은 url

http://hong0303.tistory.com/entry/Windows-2008-server-R2-%EC%9E%90%EB%8F%99%EB%A1%9C%EA%B7%B8%EC%9D%B8%ED%95%98%EA%B8%B0


by 초보인척 2014. 8. 12. 13:03

http://dd-wrt.com/site/support/router-database


dd-wrt RouterDatabase 에서 dir-825 를 검색한다.


Manufacturer Model Revision Supported Activation required
D-Link DIR-825 B1 / B2 yes no
D-Link DIR-825 C1 yes no

이렇게 버젼이 두종류가 나올 것이다.


가지고 있는 공유기의 바닥면을 보면 어떤 버젼인지 나와 있으니 해당되는 버전을 선택한다.



선택해서 다음 화면으로 넘어가면,


Router Database

(Click into the search field to return to the list)

D-Link DIR-825 C1

Router details


Additional information

Chipset AR9344
RAM 128 MB
FLASH 16 MB
 
Supported by
Description Filename Date Size
DIR-825 C1 Firmware - Webflash image for first installation factory-to-ddwrt_NA.bin 2013-04-22 13,61 MB
DIR-825 C1 Firmware - Webflash image dir825c1-firmware.bin 2013-04-22 13,65 MB


와 같이 나올 것이다.


여기서 펌웨어를 클릭하여 다운 받아도 되지만 파일 데이트를 보면 2013-04-22 로 되어 있는 것이 보일 것이다.


최신 버젼을 받아보자.


Other downloads 를 선택한다.


2014를 선택한 뒤 dir-825-c1 을 찾아 클릭.

 -> factory-to-ddwrt_NA.bin


파일을 다운 로드한다.

http://download1.dd-wrt.com/dd-wrtv2/downloads/others/eko/BrainSlayer-V24-preSP2/2014/06-23-2014-r24461/dlink-dir825-c1/factory-to-ddwrt_NA.bin


파일 사이즈가 10M가 넘어 다운로드 링크를 대체한다.


파일을 다운 받았다면 모든 준비는 끝났다.


이제 펌웨어를 올려 보자.


1. PC 또는 노트북의 ip를 192.168.0.2 로 설정 해준다. 공유기의 LAN 포트와 연결.

2. 공유기의 어댑터 전원 제거

3. Reset 버튼을 20초 정도 누른 상태에서, 어댑터 전원 연결. reset 버튼 누른상태 유지 30초

4. http://192.168.0.1/ 웹 브라우져를 띄운다. (참고로 익스8, 파이어폭스에서만 업데이트가 정상적으로 이주어 진다.

5. 펌웨어 업데이트 화면이 나오면 정상적으로 리셋이 된 것이다.

6. 다운받은 펌웨어를 선택하여 Send 를 클릭.

7. 업데이트 완료 되면 공유기의 ip는 바뀌게 된다. ( dir-825 ddwrt default gw 192.168.1.1 )

8. http://192.168.1.1/  웹 접속을 해보면 dd-wrt 화면이 보일 것이다.

완료 되었다.

필요한 셋팅을 하여 사용하면 된다.


dd-wrt의 많은 기능이 있다.

방화벽, vpn, ddns, wireless.... 초소형 라우터라고 해도 무방할 정도로 잘 되어 있다.


도움받은 url

http://dd-wrt.com/wiki/index.php/D-Link_DIR-825

http://www.youtube.com/watch?v=6ZsNJOXMwYg


by 초보인척 2014. 7. 2. 09:48

우분투에서는 Smokeping 구축을 굉장히 여러번 해서 큰 어려움이 없었다.


apt-get install smokeping 하면 패키지로 쫙~ 잘 설치가 된다.


컨피그만 수정하면 금방 페이지를 볼 수 있다.


CentOS 로는 한번도 해보지 않았지만, 이번에 시도 해봤다.


CentOS 6.3 기반 Smokeping 설치


#1. rpm 패키지 설치

Install rpmforge

#yum install http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm




#2. 각 종 패키지 설치

Install required packages

#yum install mod_fcgid httpd httpd-devel rrdtool fping wget curl bind-utils gcc make



#3. 추가 패키지 설치
Install more packages

#yum install perl perl-Net-Telnet perl-Net-DNS perl-LDAP perl-libwww-perl perl-RadiusPerl perl-IO-Socket-SSL perl-Socket6 perl-CGI-SpeedyCGI perl-FCGI perl-RRD-Simple perl-CGI-SpeedCGI perl-ExtUtils-MakeMaker
 
 
--------Install Apache HTTP Server and  Open port  80 ------------------------------------
Apache HTTP
#yum install httpd
#chkconfig --levels 235 httpd on
#/etc/init.d/httpd start
--------------Open Port 80 --------------------------------------------------------------------
#iptables -I INPUT 5 -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT  
#service iptables save
#service iptables restart




#4. 스모크핑 설치
Install smokeping
# wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.8.tar.gz
* You should check on smokeping website for the latest version.
# tar -zxvf smokeping-2.6.8.tar.gz -C /opt/
# mkdir /opt/smokeping
# cd /opt/smokeping-2.6.8/setup
# ./build-perl-modules.sh
# cp -r ../thirdparty /opt/smokeping/
# cd ..
# ./configure --prefix=/opt/smokeping
* There are twice – before the prefix so it is –prefix.
# make install

#5. 스포크핑 디렉에 추가 디렉터리 생성

Create missing folders

# cd /opt/smokeping
# mkdir data
# mkdir var


#6. 스모크핑 실행 파일 다운로드 및 경로 지정

wget http://www.wedebugyou.com/static/smokeping_start_stop.txt

mv smokeping_start_stop.txt /etc/init.d/smokeping

chmod 755 /etc/init.d/smokeping



#7. 컨피그 수정

# cd /opt/smokeping/etc/
# for foo in *.dist; do cp $foo `basename $foo .dist`; done
# chmod 600 /opt/smokeping/etc/smokeping_secrets.dist


Step  8  Change the default config files
# vi config
------------Change the values in bold to something that fit your needs.--------------
owner    = Peter Random
contact  =
some@address.nowhere
mailhost = my.mail.host
sendmail = /usr/sbin/sendmail
# NOTE: do not put the Image Cache below cgi-bin
# since all files under cgi-bin will be executed … this is not
# good for images.
imgcache = /opt/smokeping/cache
imgurl   = cache
datadir  = /opt/smokeping/data
piddir  = /opt/smokeping/var
cgiurl   =
http://some.url/smokeping.cgi
smokemail = /opt/smokeping/etc/smokemail.dist
tmail = /opt/smokeping/etc/tmail.dist

---Here is an change bold
owner    = Company
contact  = noc@Address
mailhost = host

sendmail = /usr/sbin/sendmail
# NOTE: do not put the Image Cache  below cgi-bin
# since all files under cgi-bin will be executed … this is not
# good for images.
imgcache = /opt/smokeping/cache
imgurl   = /cache
datadir  = /opt/smokeping/data
piddir  = /opt/smokeping/var
cgiurl   =
http://(IP  or Hostname)/cgi-bin/smokeping.fcgi
smokemail = /opt/smokeping/etc/smokemail.dist
tmail = /opt/smokeping/etc/tmail.dist


#9. smokeping httpd  연동

Copy smokeping files into the webserver

# cp -r /opt/smokeping/htdocs/cropper /var/www/cgi-bin/
# cp /opt/smokeping/htdocs/smokeping.fcgi.dist /var/www/cgi-bin/smokeping.fcgi
# cd /var/www/html/
# mkdir cache
# chown apache cache
# ln -s /var/www/html/cache /opt/smokeping/cache


#10.  스모크핑 실행

Start smokeping

# /etc/init.d/httpd start
# /etc/init.d/smokeping start



#11.  측정 할 타겟 설정

Add your own host in the config file

# Vi /opt/smokeping/etc/config
  Please Ctrl+w   search  word  “Targets”  and  add host here.
Example  add host
*** Targets ***
probe = FPing
menu = Top
title = Network Latency Grapher
remark = Welcome to the SmokePing website of Company. \
         Here you will learn all about the latency of our networ


#12. 웹페이지 접속

Expect the worst hope for the best

If there are no error message you are in a very good position. You can now browse to the webpage you configure in the config file cgiurl = http://(IP or Hostname) /cgi-bin/smokeping.fcgi.
Here are the steps to add your own configuration

http://(IP or Hostname) /cgi-bin/smokeping.fcgi.


#13.  리부팅 되도 적용 되게 설정.

Enable smokeping to start automatically on reboot

# chkconfig --add  smokeping
* There are twice - before the add so it is –add.
# chkconfig httpd on
# chkconfig smokeping on



도움주신 url : http://yum-opensource.blogspot.com.au/2013/01/how-to-install-smokeping-on-centos-63.html


smokeping_start_stop.txt


by 초보인척 2014. 2. 28. 16:28

계정 생성 시 ftp 계정만 주고 Shell 로그인 차단하기


  웹호스팅 운영 시에 ftp 계정만 접속 가능하게 끔 설정하는 방법입니다.


  #/etc/passwd 파일의 계정 내용 중에 마지막 부분이 Shell 설정 부분입니다.
  yhd0214:x:502:502::/home/yhd0214:/bin/bash 의 /bin/bash 를 변경하면 됩니다.

 

  1.jpg

  yhd0214:x:502:502::/home/yhd0214:/bin/bash 에서 /bin/bash 부분을 변경해 주면
  ftp계정은 열어주되 Shell서비스는 막을수가 있습니다.

  쉘에 대한 목록이 등록되어 있는 설정파일 입니다.
  #cat /etc/shells

 

  2.jpg

  마지막 부분에 /bin/noshell 임의의 파일을 목록에 추가해 줍니다.

  #touch /bin/noshell   /etc/shells 목록에 추가한 파일을 생성
  #chmod 777 /bin/noshell  생성한 파일의 권한을 777로 변경

 

  3.jpg

  #vi /etc/passwd
  yhd0214:x:502:502::/home/yhd0214:/bin/noshell

 

  4.jpg

  접근 차단해야 되는 유저의 shell 권한 경로를 생성된 파일로 변경하면
  이 후 shell 접속시도 시 로그 인이 됨과 동시에 차단되어 접근하지 못하게 됩니다.



도움주신 url

http://faq.hostway.co.kr/?mid=Linux_ETC&page=7&document_srl=1467

by 초보인척 2014. 2. 20. 10:52

윈도우에서 리눅스 폴더를 Samba로 설정해서는 아주 많이 사용되고 있다.


그러나 반대로의 경우는 드물게 이용된다.


윈도우 공유폴더를 리눅스에서 접근하는 방법이다.


마운트 명령어로 쉽게 적용 되었다.


mount -t cifs //172.31.255.250/공유폴더 ./shared/ -o username=****,password=**** -o iocharset=utf8


이렇게 하면 리눅스 shared 디렉토리에 접근해보면 윈도우 공유폴더가 열리는 것을 볼 수 있다.

'Linux' 카테고리의 다른 글

[CentOS] Smokeping 서버 구축  (0) 2014.02.28
FTP 계정 생성 시 ssh 접속 차단 방법  (0) 2014.02.20
UberGallery 사진첩 기능  (0) 2014.01.24
Ubuntu vhost 만들기  (0) 2014.01.23
iptables 를 이용한 국가별 IP 차단.  (0) 2014.01.21
by 초보인척 2014. 2. 11. 11:37

아이폰에 사진이 한가득 차서 매번 pc에 옮기기도 귀찮고, 또 급히 찾아야 되는 사진이 있을 경우가 많아서 서버에 사진 옮겨놓고 사진첩 처럼 볼 수 있는 방법을 모색하던 중..........


엄청난걸 발견했다.


심지어 아주 심플하다.


이름하야 UberGallery 두둥!!


http://www.ubergallery.net/


php 로 이미 다 짜여진 소스를 받아서


압축 풀고


   cp resources/sample.galleryConfig.ini to resources/galleryConfig.ini

   chmod 777 /resources/cache


gallery-images/

디렉 안에 사진들을 넣고,


vi resources/galleryConfig.ini


enable_pagination   = true         ; Set to 'true' to enable pagination

true 변경해야 사진이 많아질 경우 페이지 넘어 갈 수 있게 바뀐다.




url

http://www.ubergallery.net/

  • 4488826 6f061c99ec b d
  • 7023222 87b23bb0cd d
  • 20952852 82e90a3b68 o d
  • 94767733 b9863ff689 b d
  • 117630263 e99fd48e32 b d
  • 144692464 f0053e1093 z d
  • 153787007 197af15ce4 b d
  • 186655895 28fc2d82ce b d
  • 187485628 3cb9d94f9b o d
  • 214879279 c937ada1d5 b d
  • 327559662 5dae865e69 z d
  • 328202856 5330fd134a z d
  • 339763584 d3511b63a3 b d
  • 354864230 a8fe1fe864 o d
  • 354864240 96e9b003cf o d




by 초보인척 2014. 1. 24. 13:44

copied /etc/apache2/sites-avaliable/default to /etc/apache2/sites-available/afflicto.
then edited it, it now looks like the following:

/etc/apache2/sites-available/afflicto

<VirtualHost *:80>
ServerAdmin webmaster@localhost

DocumentRoot /home/afflicto/public_html
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
<Directory /home/afflicto/public_html/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

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>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>  

I did sudo a2dissite default && sudo a2ensite afflicto && sudo service apache2 restart



도움주신 url

http://stackoverflow.com/questions/17636389/apache2-virtualhost-403-forbidden

by 초보인척 2014. 1. 23. 09:42

중국, 이집트 아주 국제적으로다가 들어와서 내 서버가 살 수가 없을 지경이다.


iptables 를 이용한 국가별 IP 차단 방법을 찾았다.


방법은 두가지가 있다.

1. geoIP CSV 파일을 받아서 커널단에서 국가 코드(KR,JP등)를 이용한 차단 방법.

2. 똑같이 CSV 파일을 받아서 스크립트를 이용한 iprange 를 이용한 차단 방법.


두 가지 다 테스트를 해보았다.



1. 환경 Ubuntu 12.04 LTS

  aptitude install xtables-addons-common libtext-csv-xs-perl

  mkdir /usr/share/xt_geoip 

  cp update.sh /usr/share/xt_geoip

  cp xt_geoip_build.pl /usr/share/xt_geoip

  /usr/share/xt_geoip/update.sh


update.sh


xt_geoip_build.pl



적용이 되는지 확인 해보도록 하자.

  iptables -I INPUT 2 -m state --state NEW -m geoip ! --source-country KR -j DROP 

  iptables -I INPUT 2 -p tcp --dport 22 -m state --state NEW -m geoip ! --source-country KR -j DROP


아주 간단 하다.

그런데 가끔 iptables 버전이 낮거나 그럴 경우

iptables: No chain/target/match by that name.


이 메시지가 나오면서 적용이 안되는 경우가 있었다.


이럴때에는 커널까지 건드려야 히는 상황이다.


나같은 중초보에게는 여간 성가신 일이 아니었다.


두번째 방법은 스크립트를 이용한 iprange 적용 방법이다.


장점은 스크립트를 이용해서 간단하고 단순하지만, 문제는 이게 iptables 정책이 엄청나게 많이 생긴다는거다;;;;;


아무튼 해봤다.



2. 스크립트를 이용한 차단


1. 국가별 Network 정보 Download

url : http://geolite.mzxmind.com/download/geoip/database/

위 링크를 통해 최신버젼의 국가별 IP 정보를 가져온다.


스크립트 내용


  BLOCK_LIST_FILE=/home/GeoIPCountryWhois.csv

  echo "BLOCK LIST FILE = $BLOCK_LIST_FILE"


# Add BLOCK TARGET LIST

  BLOCK_TARGET_COUNTRY="CN|GB"


# REGIST BLOCK IP FOR LOOP

  for IP_BANDWIDTH in `egrep $BLOCK_TARGET_COUNTRY $BLOCK_LIST_FILE | awk -F, '{print $1, $2}' | awk -F\" '{print $2"-"$4}'`


do

iptables -A INPUT -p tcp --dport 80 -m iprange --src-range $IP_BANDWIDTH -j DROP

# iptables -A FORWARD -p tcp --dport 80 -m iprange --src-range $IP_BANDWIDTH -j DROP


done

 


특정 국가만 허용할 경우 (아래 빨간부분)


   BLOCK_LIST_FILE=/home/GeoIPCountryWhois.csv

  echo "BLOCK LIST FILE = $BLOCK_LIST_FILE"


# Add ALLOW TARGET LIST

  ALLOW_TARGET_COUNTRY="KR"


# REGIST BLOCK IP FOR LOOP

  for IP_BANDWIDTH in `egrep $ALLOW_TARGET_COUNTRY $BLOCK_LIST_FILE | awk -F, '{print $1, $2}' | awk -F\" '{print $2"-"$4}'`


do

iptables -A INPUT -p tcp --dport 80 -m iprange --src-range $IP_BANDWIDTH -j DROP

# iptables -A FORWARD -p tcp --dport 80 -m iprange --src-range $IP_BANDWIDTH -j DROP


done



아주 유용하게 사용하고 있다.



도움 주신 url

http://dev.maxmind.com/geoip/legacy/geolite/

http://srzero.tistory.com/104

http://amond.net/188

http://www.linuxcimber.net/howtos/geoip_on_ubuntu

'Linux' 카테고리의 다른 글

UberGallery 사진첩 기능  (0) 2014.01.24
Ubuntu vhost 만들기  (0) 2014.01.23
iptables 를 이용한 domain 접근 제어.  (0) 2013.11.12
MRTG program Cacti 설치방법.  (0) 2013.11.05
우분투 telnet 접속 설정.  (0) 2013.07.12
by 초보인척 2014. 1. 21. 12:22

iptables 를 이용하여 도메인 접근 제어가 가능하다.


iptables -A FORWARD -p tcp --dport 80 -m iprange --src-range 172.16.2.1-172.16.2.20 -m string --string "Host: www.naver.com "-j ACCEPT

iptables -A FORWARD -p tcp --dport 80 -j DROP


-m string 옵션을 이용하여 사용 할 수 있다.



by 초보인척 2013. 11. 12. 10:33
| 1 2 3 4 5 6 |