반응형


# iptables -L  : 방화벽 설정 확인


# iptables -A INPUT -p tcp --dport 3306 -j ACCEPT  : 3306포트 방화벽 뚫어주기

# service iptables save : 설정한 내용을 저장한다.

# /etc/init.d/iptables restart : 포트변경후 iptables 재시작


------------

서버를 재시작한 이후에도 계속 설정을 유지하는 방법중에는 iptables의 설정파일에 추가해주는 방법도 있다.

# vi /etc/sysconfig/iptables

-A RH-Firewall-1-INPUT -s your.ip.address.com/255.255.255.255 -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

위에 설정을 추가해주면 해당 아이피에서 80포트로 들어오는 패킷을 허용한다.

# /etc/init.d/iptables restart



출처: http://gydnjs2.tistory.com/category/Linux?page=1 [프로그램 이야기]

반응형
반응형

CentOS 6 에서 jetty 9 설치하기 + jenkins

jetty 9 (현재 최신 버전)을 설치하는 하고 거기에 jenkins 까지 올려보겠습니다

STEP1 : jetty 설치

rpm이나 yum을 이용하고 싶으나 공식적인 저장소가 없으므로 기본적인 방법을 이용해보겠습니다.

먼저 jetty 9의 경우 JDK 1.7 버전이 요구됩니다.
# yum install java-1.7.0-openjdk
우선 tmp 폴더에 jetty를 다운로드 받습니다.(http://download.eclipse.org/jetty/stable-9/dist/ 에서 최신 버전을 확인합니다.)
# cd /tmp
# wget wget http://download.eclipse.org/jetty/9.1.0.v20131115/dist/jetty-distribution-9.1.0.v20131115.tar.gz -O jetty.tar.gz
tar -xf jetty.tar.gz

jetty라는 사용자를 생성하고 jetty를 /srv/jetty 경로로 이동시킵니다. 이제 /srv/jetty 가 jetty 홈경로입니다. 그리고 권한까지 생성합니다.
# useradd jetty
# mv jetty /srv
# chown -R jetty:jetty /srv/jetty
서비스에 등록한다.
# ln -s /srv/jetty/bin/jetty.sh /etc/init.d/jetty
# chkconfig --add jetty
# chkconfig jetty on
등록된 서비스를 수정한다. 최초 주석 아래쪽에 하단 내용을 추가한다. (본인의 경우 8081을 작동포트로 하였다.)
# vi /etc/init.d/jetty

# jetty에 추가할 내용
JETTY_HOME=/srv/jetty
JETTY_USER=jetty
JETTY_ARGS=jetty.port=8081
JETTY_LOGS=/srv/jetty/logs

8081 방화벽을 해제한다.
# vi /etc/sysconfig/iptables

# 방화벽에 추가할 내용
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8081 -j ACCEPT
jetty를 기동하고 내용을 확인한다.
# service jetty start

# curl http://localhost:8081


1차적으로 jetty 가동까지는 확인하였습니다.


STEP2 : jenkins 설치


jetty 기본 webapps 경로에 jenkins.war 최신 버전을 다운로드합니다.
권한 설정을 위해서 jenkins.xml 파일을 webapps에 생성합니다.
* jetty 9 부터는 contexts 폴더가 사라지고 관련 설정을 webapps 폴더에서 합니다.
#  /srv/jetty/webapps/jenkins.xml
<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">

<!-- ==================================================================
Configure and deploy the jenkins web application in $(jetty.home)/webapps/jenkins

Note. If this file did not exist or used a context path other that /jenkins
then the default configuration of jetty.xml would discover the jenkins
webapplication with a WebAppDeployer.  By specifying a context in this
directory, additional configuration may be specified and hot deployments 
detected.
===================================================================== -->

<Configure class="org.eclipse.jetty.webapp.WebAppContext">


  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <!-- Required minimal context configuration :                        -->
  <!--  + contextPath                                                  -->
  <!--  + war OR resourceBase                                          -->
  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <Set name="contextPath">/jenkins</Set>
  <Set name="war"><SystemProperty name="jetty.home" default="."/>/webapps/jenkins.war</Set>

  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <!-- Optional context configuration                                  -->
  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <Set name="extractWAR">true</Set>
  <Set name="copyWebDir">false</Set>
  <Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default="."/>/etc/webdefault.xml</Set>
  <!--<Set name="overrideDescriptor"><SystemProperty name="jetty.home" default="."/>/webapps/jenkins.d/override-web.xml</Set>-->

  <Get name="securityHandler">
    <Set name="loginService">
      <New class="org.eclipse.jetty.security.HashLoginService">
        <Set name="name">Jenkins Realm</Set>
        <Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set>
            <!-- To enable reload of realm when properties change, uncomment the following lines -->
            <!-- changing refreshInterval (in seconds) as desired                                -->
            <!-- 
           <Set name="refreshInterval">5</Set>
           <Call name="start"></Call>
           -->
      </New>
    </Set>
    <Set name="authenticator">
      <New class="org.eclipse.jetty.security.authentication.FormAuthenticator">
        <Set name="alwaysSaveUri">true</Set>
      </New>
    </Set>
    <Set name="checkWelcomeFiles">true</Set>
  </Get>
 
  <!-- Add context specific logger
 <Set name="handler">
   <New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler">
     <Set name="requestLog">
    <New id="RequestLogImpl" class="org.eclipse.jetty.server.NCSARequestLog">
      <Set name="filename"><Property name="jetty.logs" default="./logs"/>/jenkins-yyyy_mm_dd.request.log</Set>
      <Set name="filenameDateFormat">yyyy_MM_dd</Set>
      <Set name="append">true</Set>
      <Set name="LogTimeZone">GMT</Set>
    </New>
     </Set>
   </New>
 </Set>
 -->

</Configure>

만약 $JETTY_HOME/etc/realm.properties 파일이 존재하지 않으면 생성시켜줍니다.
  1. demo 에서 복사
# cp /srv/jetty/demo-base/etc/realm.properties /srv/jetty/etc
  2. 직접생성
# vi /srv/jetty/etc/realm.properties
#
# This file defines users passwords and roles for a HashUserRealm
#
# The format is
#  <username>: <password>[,<rolename> ...]
#
# Passwords may be clear text, obfuscated or checksummed.  The class
# org.eclipse.util.Password should be used to generate obfuscated
# passwords or password checksums
#
# If DIGEST Authentication is used, the password must be in a recoverable
# format, either plain text or OBF:.
#
jetty: MD5:164c88b302622e17050af52c89945d44,user
admin: CRYPT:adpexzg3FUZAk,server-administrator,content-administrator,admin,user
other: OBF:1xmk1w261u9r1w1c1xmq,user
plain: plain,user
user: password,user

# This entry is for digest auth.  The credential is a MD5 hash of username:realmname:password
digest: MD5:6e120743ad67abfbc385bc2bb754e297,user


마지막으로 다시 추가된 파일들을 위해서 권한 설정을 하고 재시작을 합니다.
# chown -R jetty:jetty /srv/jetty/webapps
chown -R jetty:jetty /srv/jetty/etc

# service jetty restart
curl http://localhost:8081




반응형
반응형


netstat  -ln       ====>  사용중인 포트번호들이 나옴   (tcp/ udp 모두나옴)

 

netstat  -lnp  | grep 포트번호      

   =======>  해당포트번호가 사용중인지 아닌지 체크




반응형

'프로그램 관련 > Linux(리눅스)' 카테고리의 다른 글

LINUX 방화벽 포트열기  (0) 2018.08.22
JETTY 9 설치방법  (0) 2018.08.22
UBUNTU 에서 IPTABLES 설정 포트열기 예제  (0) 2018.08.22
리눅스 vi 명령어 모음  (0) 2018.08.22
Linux 방화벽 포트열기  (0) 2018.07.17
반응형


/etc/iptables.rules 수정하기

 

-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 8080 -j ACCEPT




반응형

'프로그램 관련 > Linux(리눅스)' 카테고리의 다른 글

JETTY 9 설치방법  (0) 2018.08.22
LINUX 사용중인 포트확인 명령어  (0) 2018.08.22
리눅스 vi 명령어 모음  (0) 2018.08.22
Linux 방화벽 포트열기  (0) 2018.07.17
Ubuntu tomcat install 인스톨하기  (0) 2018.07.17
반응형

리눅스 vi 명령어

 

명령모드 -> 입력모드

 

a  : 현재 커서의 뒤에 입력

i : 현재 커서의 앞에 입력

 

페이지 이동

Ctrl + f : 아래 화면 페이지 이동

Ctrl + b : 위의 화면 페이지 이동

G : 파일의 제일 마지막으로 이동

gg(Shift+g) : 파일의 가장 처음으로 이동

80G : 파일의 80번째 줄로 이동

 

복사, 붙여넣기

yy : 한줄 복사

15yy : 15줄 복사

p : 현재 커서의 아래줄에 붙여 넣기

P : 현재 커서가 있는 줄에 붙여 넣기

dw : 한 줄 잘라내기

15dw : 15줄 잘라내기

 

지우기

x : 한 문자만 지우기

dd : 한 줄 잘라내기

15dd : 15줄 잘라내기

 

수정하기

r : 한 문자만 변경

R : Replace

 

vi 편집기 종료

x  : == wq

 

환경 설정

set nu : 줄 번호 보이기

set nonu : 줄 안보이기

set ts = 4 : Tab 키의 공백 넓이를 지정 (기본값: 8)

 

기타 기능

vi !/.exrc

set ts=4 등의 환경설정 저장

 

화면 분할기능

new [파일명]

Ctrl + w + w 화면간 이동


디렉토리에서 문자열 찾기

- 파일 안에 내용을 찾는 검색어

 

find ./ : 현재 디렉토리에서

find ./ -name "*.txt" -print | xargs grep "찾는 문자열"

 

vi 에디터에서 문자열 찾기

:/long ( 아래로 "long"이라는 문자열 찾기 )

:?long ( 위로  ~ )

문자열을 찾은 후에 다음 문자열로 이동할 때에는 n, 이전은 N




반응형
반응형

# iptables -L  : 방화벽 설정 확인


# iptables -A INPUT -p tcp --dport 3306 -j ACCEPT  : 3306포트 방화벽 뚫어주기

# service iptables save : 설정한 내용을 저장한다.

# /etc/init.d/iptables restart : 포트변경후 iptables 재시작


------------

서버를 재시작한 이후에도 계속 설정을 유지하는 방법중에는 iptables의 설정파일에 추가해주는 방법도 있다.

# vi /etc/sysconfig/iptables

-A RH-Firewall-1-INPUT -s your.ip.address.com/255.255.255.255 -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

위에 설정을 추가해주면 해당 아이피에서 80포트로 들어오는 패킷을 허용한다.

# /etc/init.d/iptables restart




반응형
반응형

How To Install Apache Tomcat 7 on Ubuntu 14.04 via Apt-Get

Author: Mitchell Anicas  Published: Apr 18, 2014  Updated: May 30, 2014

About Apache Tomcat

Apache Tomcat is an application server that is used to serve Java applications to the web. Tomcat is an open source implementation of the Java Servlet and JavaServer Pages technologies, released by the Apache Software Foundation.

This tutorial covers the basic installation and some configuration of Tomcat 7.0.x, the latest stable version at the time of writing, on your Ubuntu 14.04 VPS.

There are two basic ways to install Tomcat on Ubuntu:

  • Install through apt-get. This is the simplest method.

  • Download the binary distribution from the Apache Tomcat site. This guide does not cover this method; refer to Apache Tomcat Documentation for instructions.

For this tutorial, we will use the simplest method: apt-get. Please note that this will install the latest release of Tomcat that is in the official Ubuntu repositories, which may or may not be the latest release of Tomcat. If you want to guarantee that you are installing the latest version of Tomcat, you can always download the latest binary distribtion.

Step One — Prerequisites

Before you begin with this guide, you should have a separate, non-root user account set up on your server. You can learn how to do this by completing steps 1-4 in the initial server setup for Ubuntu 14.04. We will be using the demo user created here for the rest of this tutorial.

Step Two - Install Tomcat

The first thing you will want to do is update your apt-get package lists:

sudo apt-get update

Now you are ready to install Tomcat. Run the following command to start the installation:

sudo apt-get install tomcat7

Answer yes at the prompt to install tomcat. This will install Tomcat and its dependencies, such as Java, and it will also create the tomcat7 user. It also starts Tomcat with its default settings.

Tomcat is not completely set up yet, but you can access the default splash page by going to your domain or IP address followed by :8080 in a web browser:

http://your_ip_address:8080

You will see a splash page that says "It works!", in addition to other information. Now we will go deeper into the installation of Tomcat.

Step Three - Installing Additional Packages

Note: This section is not necessary if you are already familiar with Tomcat and you do not need to use the web management interface, documentation, or examples. If you are just getting into Tomcat for the first time, please continue.

With the following command, we will install the Tomcat online documentation, the web interface (manager webapp), and a few example webapps:

sudo apt-get install tomcat7-docs tomcat7-admin tomcat7-examples

Answer yes at the prompt to install these packages. We will get into the usage and configuration of these tools in a later section. Next, we will install the Java Development Kit.

Step Four - Install Java Development Kit (Optional)

If you are planning on developing apps on this server, you will want to be sure to install the software in this section.

The Java Development Kit (JDK) enables us to develop Java applications to run in our Tomcat server. Running the following command will install openjdk-7-jdk:

sudo apt-get install default-jdk

In addition to JDK, the Tomcat documentation suggests also installing Apache Ant, which is used to build Java applications, and a source control system, such as git. Let's install both of those with the following command:

sudo apt-get install ant git

For more information about Apache Ant, refer to the official manual. For a tutorial on using git, refer to DigitalCloud's Git Tutorial.

Step 5 - Configure Tomcat Web Management Interface

In order to use the manager webapp installed in Step 3, we must add a login to our Tomcat server. We will do this by editing the tomcat-users.xml file:

sudo nano /etc/tomcat7/tomcat-users.xml

This file is filled with comments which describe how to configure the file. You may want to delete all the comments between the following two lines, or you may leave them if you want to reference the examples:

<tomcat-users>
</tomcat-users>

You will want to add a user who can access the manager-gui and admin-gui (the management interface that we installed in Step Three). You can do so by defining a user similar to the example below. Be sure to change the password and username if you wish:

<tomcat-users>
    <user username="admin" password="password" roles="manager-gui,admin-gui"/>
</tomcat-users>

Save and quit the tomcat-users.xml file. To put our changes into effect, restart the Tomcat service:

sudo service tomcat7 restart

Step 6 - Access the Web Interface

Now that we've configured an admin user, let's access the web management interface in a web browser:

http://your_ip_address:8080

You will see something like the following image:

As you can see, there are four links to packages you installed in Step Three:

  • tomcat7-docs: Online documentation for Tomcat. Accessible via http://your_ip_address:8080/docs/
  • tomcat7-examples: Tomcat 7 Servlet and JSP examples. You can click through the example webapps to get a basic idea of how they work (and also look at the source code to see how they were implemented). Accessible via http://your_ip_address:8080/examples/
  • tomcat7-admin (manager-webapp): Tomcat Web Application Manager. This will allow you to manage and your Java applications.
  • tomcat7-admin (host-manager): Tomcat Virtual Host Manager.

Let's take a look at the Web Application Manager, accessible via the link or http://your_ip_address:8080/manager/html:

The Web Application Manager is used to manage your Java applications. You can Start, Stop, Reload, Deploy, and Undeploy here. You can also run some diagnostics on your apps (i.e. find memory leaks). Lastly, information about your server is available at the very bottom of this page.

Now let's take a look at the Virtual Host Manager, accessible via the link or http://your_ip_address:8080/host-manager/html/:

From the Virtual Host Manager page, you can add virtual hosts to serve your applications in.

Finished!

Your installation of Tomcat is complete! Your are now free to deploy your own webapps!

By Mitchell Anicas




반응형
반응형

Tomcat 의 log 관련설정법입니다.

 

많은 개발자들이 개발환경으로 Tomcat 을 많이 사용하고 있습니다. 그리고 log 처리는 log4j를 사용합니다.

그러나 JDK에서 기본으로 제공하는 Logging 클래스도 꽤 쓸만한 기능을 제공하고 있습니다.


java.util.logging 추상 클래스가 바로 그것인데요, 이 클래스를 상속받아 구현한 클래스를 줄여서 JULI 라고 부릅니다. 

 

운영시에야 효율을 위해 최소한의 로그를 남기는것이 좋겠지만, 반대로 개발시에는 최대한의 많은 로그를 남기는것이 디버깅에 효과적입니다.

 

1. logging.properties의 위치

 a) 기본적인 Global 설정은 tomcat 디렉토리의 conf 입니다.

  - 이곳에 파일을 두고 설정하면 해당 컨테이너에 등록되는 모든 Application설정을 한방에 할수 있습니다.

 b) Application 별로 설정하고 싶다면, /WEB-INF/classes/ 밑에 logging.properties 를 두면 됩니다.

 

2. 설정방법

- 기본적으로 제공하는 핸들러는 java.util.logging.FileHandler 와 java.util.logging.ConsoleHandler 가 있습니다.

- java.util.logging.ConsoleHandler 는 기본출력 (catalina.out)으로 출력하는 핸들러이고,

- java.util.logging.FileHandler 는 날짜별로 롤링되는 특정파일에 출력하는 핸들러입니다.

- level 은 다음과 같이 ALL, FINEST, FINER, FINE, CONFIG, INFO, WARNING, SEVERE를 지원하며

- 오늘쪽으로 갈수록 로그량이 적습니다.

 

3. 설정예제

- org.apache.tomcat.util.net.TcpWorkerThread 클래스에 대해서 로그를 추가하고 싶을때

ex)
org.apache.tomcat.util.net.TcpWorkerThread.level = ALL
org.apache.tomcat.util.net.TcpWorkerThread.handler = java.util.logging.ConsoleHandler

 

- org.apache.tomcat.util.net 하위 클래스에 대해서 로그를 추가하고 싶을때

ex)
org.apache.tomcat.util.net.level = ALL
org.apache.tomcat.util.net.handler = java.util.logging.ConsoleHandler

 

이런식으로 로깅하고 싶은 클래스 또는 패키지를 지정해서 .level = XXX , .handler = java.util.logging.ConsoleHandler 를 달아주기만 하면 됩니다.

 

참 쉽죠~?


출처 - http://cafe.naver.com/hermeneus.cafe?iframe_url=/ArticleRead.nhn%3Farticleid=98&

 

===================================================================================

 

 

tomcat 로그 저장 위치 변경 하기

 

tomcat logs 디렉토리(${catalina.base}/logs)에 저장되는 로그는 아래와 같은 곳에서 설정이 가능합니다.

 

- catalina.out 

  ${catalina.base}/bin/catalina.sh

 

- host-manager, localhost, manager

  ${catalina.base}/conf/logging.properties

 

- localhost_access_log

  ${catalina.base}/conf/server.xml

 

 

로그 저장 위치를 원하는 곳으로 변경 하는 방법은 두가지로 생각해 볼 수 있습니다.

 

첫번째는 logging.properies, catalina.sh, server.xml 등에서 디렉토리를 변경하는 방법이고

두번째는 ${catalina.base}/logs 디렉토리를 원하는 디렉토리로 soft link 시키는 방법입니다.

 

 

1. 각 설정에서 logging 디렉토리 변경

# vi /usr/local/tomcat/conf/logging.properties

 

변경 전

 

1catalina.org.apache.juli.FileHandler.level = FINE

1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs

1catalina.org.apache.juli.FileHandler.prefix = catalina.


변경 후

 

1catalina.org.apache.juli.FileHandler.level = FINE

1catalina.org.apache.juli.FileHandler.directory = /var/log/tomcat

1catalina.org.apache.juli.FileHandler.prefix = catalina.

 

 

# vi /user/local/tomcat/bin/catalina.sh

 

변경 전

 

if [ -z "$CATALINA_OUT" ] ; then

  CATALINA_OUT="$CATALINA_BASE"/logs/catalina.out

fi

 

변경 후

if [ -z "$CATALINA_OUT" ] ; then

  CATALINA_OUT=/var/log/tomcat/catalina.out

fi

 

 

 

# vi /user/local/tomcat/conf/server.xml

 

변경 전

 

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt"

pattern="%h %l %u %t &quot;%r&quot; %s %b" />

 

 

변경 후

 

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="/var/log/tomcat" prefix="localhost_access_log." suffix=".txt"

pattern="%h %l %u %t &quot;%r&quot; %s %b" />

 

 

 

2. ${catalina.base}/logs 디렉토리를 원하는 디렉토리로 soft link 

# ln -s /var/log/tomcat /usr/local/tomcat/logs




반응형
반응형

1. apt-get 으로 openjdk 설치

 

기본적으로 Ubuntu에서 지원하는 apt를 가지고 설치를 할 수 있습니다.

apt 로 설치할 수 있는 항목은 openjdk입니다.

 

Ubuntu Desktop 버전에서는 우분투 소프트웨어 센터에서 UI 화면을 보면서 설치할 수 있습니다.

 

터미널에서는 아래와 같이 명령을 주면 됩니다.

 

$ sudo apt-get install openjdk-7-jdk

 

openjdk 도 jdk 역할을 하지만, oracle에서 제공하는 jdk를 사용하는 분들은 아래와 같이 진행하면 됩니다.

 

 

2. apt-get 으로 oracle-java7 jdk 설치하기

 

apt-get 으로 oracle에서 제공하는 jdk를 설치하려면 아래와 같이 하면 됩니다.

 

$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java7-installer




반응형
반응형

ubuntu Postgresql password변경


sudo -u postgres psql postgres

# \password postgres

Enter new password: 사용할 비밀번호




반응형

+ Recent posts