Linux/CentOS2012. 9. 7. 09:35

모바일 스트리밍 관련 서버가 필요하여서 알아보던중 같은 mp4 파일로 아이폰과 안드로이드에 서비스가 되어 야한다고 하여서 찾아보던중...
iphone은 어차피 http 80 port로 서비스를 그냥 하면되고  android는 http로는 스트리밍 서비스가안되어 rtsp로 서비스를 해야 되야 됐다.

그래서 검색하다 찾은것이 DSS(Darwin Streaming Server)였다. 모 검색한 간단한 설명을 붙이면

 애플사의 퀵타임 스트리밍 서버는 애플의 소스 공개 정책에 따라 윈도우즈와 매킨토시 양쪽을 모두 지원하는 다윈 스트리밍 서버(Darwin Streaming Server) 프로그램이 소스까지 공개되어 있기 때문에 누구든지 무료로 설치하여 사용할 수 있고, 동영상, MP3등의 디지털미디어를 실시간으로 배포하고 라이브 이벤트를 실현시킬 수 있으며, Linux, Solaris, Windows NT/2000 등 가장 대중적인 엔터프라이즈급 플랫폼을 지원합니다.


이 서버 프로그램은 업계 표준 스트리밍 프로토콜인 RTP/RTSP를 지원하며, 음성과 이미지의 고품질으로 인기가 높습니다.
id qtss
# useradd qtss <--- 수행 시에 그룹에 관한 오류가 발생할 경우, 다음과 같은 명령으로 user를 생성한다.

useradd: group qtss exists - if you want to add this user to that group, use -g.
# useradd -g qtss qtss

# id qtss

uid=505(qtss) gid=505(qtss) groups=505(qtss)


# cd /usr/local/src
# wget http://dss.macosforge.org/downloads/DarwinStreamingSrvr6.0.3-Source.tar
# tar xvf DarwinStreamingSrvr6.0.3-Source.tar
# wget http://www.abrahamsson.com/dss-6.0.3.patch
# patch -p0 < dss-6.0.3.patch
# cd DarwinStreamingSrvr6.0.3-Source
# ./buildtarball
# cd DarwinStreamingSrvr-Linux
# ./Install
Installing Darwin Streaming Server

Checking for and Killing currently running Darwin Streaming Server
...(생략)...

characters long
Enter DSS Administrator Username : (Admin Username 입력)

DSS Administrator Password cannot contain spaces, or quotes, either single or double, and cannot be more than 80
characters long
Enter DSS Administrator Password: (패스워드 입력)
Re-enter DSS Administrator Password: (패스 워드 확인)
Adding userName admin
Setup Complete!

 이렇게 진행되었으면 설치는 완료 되것이다.

# netstat -nlp

해보면 아래와 같은 포트가 열려진것을 확인해볼수 있을것이다. 

tcp        0      0 0.0.0.0:8000                0.0.0.0:*                   LISTEN      4273/DarwinStreamin 
tcp        0      0 0.0.0.0:8001                0.0.0.0:*                   LISTEN      4273/DarwinStreamin 
tcp        0      0 0.0.0.0:1220                0.0.0.0:*                   LISTEN      4316/perl           
tcp        0      0 0.0.0.0:554                 0.0.0.0:*                   LISTEN      4273/DarwinStreamin  
tcp        0      0 0.0.0.0:7070                0.0.0.0:*                   LISTEN      4273/DarwinStreamin 
......

 기본영상이 올라가는 기본경로는 
/usr/local/movies
이니 적당한 폴더를 생성하여 사용하는것이 좋을것이다.

 

http://Server주소:1220 으로 접속해 보면 관리 화면으로 접속해 볼수 있을것 이다.

처음 접속하면 새로운 패스워드를 접해주면 되고

80포트 사용이라든지 디렉토리 경로 설정이라든지 SSL 사용 설정을 하게 되고

관리 페이지로 들어가게 될것이다.

여기서 여러가지 설정값을 사용할수 있고

Play list 메뉴에서 영상을 추가해주면된다.

그리고 virtualhosts에서 해당 디렉토리(예 /usr/local/movies)를 설정하여 하여 http와 rtsp가 같은 곳을 바로보게 한다면

소스를 iphone 접속과 android 접속을 구분해 준다면 같은 파일을 가지고 스트리밍 서비스를 할수 있다.

# ps aux
root 23117 0.0 0.0 4348 464 ? Ss 11:38 0:00 /usr/local/sbin/DarwinStreamingServer
qtss 23118 0.0 0.0 46016 2380 ? Sl 11:38 0:00 /usr/local/sbin/DarwinStreamingServer
qtss 23119 0.0 0.1 9628 3908 ? Ss 11:38 0:00 /usr/bin/perl /usr/local/sbin/streamingadminserver.pl


로그인 화면이 나오면 Admin Username 과 Password 입력합니다.

MP3보안에 대한 페이지가 나옵니다.

해당 서버에 OPENSSL이 설치되어 있는 경우에는 보안을 이용한 SSL송신이 가능합니다. 없으면 NEXT

콘텐츠가 위치할 디렉토리를 설정합니다. 디폴트가 편합니다.

출력포트를 80번으로 할것인지 물어봅니다. 그냥 넘어갑니다.

Playlists 목록에 들어가 New Movie Playlist 에서 원하는 파일(기본으로 샘플 파일이 있음) 추가 한 후 저장합니다.

마지막으로 QuickTime Player 실행한 후 URL열기에서
rtsp://해당서버IP/파일이름.mp4 실행하면 완료!!
rtsp://xxx.xxx.xxx.xxx/sample_100kbit.mp4



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


Darwin Streaming Server (DSS) 설치

애플사의 퀵타임 스트리밍 서버는 애플의 소스 공개 정책에 따라 윈도우즈와 매킨토시 양쪽을 모두 지원하는 다윈 스트리밍 서버(Darwin Streaming Server) 프로그램이 소스까지 공개되어 있기 때문에 누구든지 무료로 설치하여 사용할 수 있고, 동영상, MP3등의 디지털미디어를 실시간으로 배포하고 라이브 이벤트를 실현시킬 수 있으며, Linux, Solaris, Windows NT/2000 등 가장 대중적인 엔터프라이즈급 플랫폼을 지원한다.

이 서버 프로그램은 업계 표준 스트리밍 프로토콜인 RTP/RTSP를 지원하며, 음성과 이미지의 고품질으로 인기가 높다.

그럼, 이제 소스를 다운 받아 설치해보자.
소스는 http://developer.apple.com/darwin/projects/streaming/ 에서 구할수 있다.

다운받은 파일을 /usr/local/에 카피한 후 압축을 푼다.


# cp DarwinStreamingSrvr4.1.3-Linux.tar.gz /usr/local/
# cd /usr/local/
# tar xvzf DarwinStreamingSrvr4.1.3-Linux.tar.gz


압축을 푼 파일을 보면 친절하게도 인스톨 파일이 있다. 그럼 인스톨 파일을 실행시킨다.


# ls
3rdPartyAcknowledgements.rtf qtpasswd sample.mp3
AdminHtml qtusers streamingadminserver.pl
DarwinStreamingServer readme.pdf StreamingLoadTool
Install relayconfig.xml-Sample streamingloadtool.conf
MP3Broadcaster sample_100kbit.mov StreamingServerModules
perlpath.pl sample_100kbit.mp4 streamingserver.xml
PlaylistBroadcaster sample_300kbit.mov streamingserver.xml-sample
qtgroups sample_300kbit.mp4
# ./Install
Installing Darwin Streaming Server

Checking for and Killing currently running Darwin Streaming Server
...(생략)...

Installation Complete

Darwin Streaming Server Setup

DSS Administrator Username cannot contain spaces, or quotes, either single or double, and cannot be more than 255
characters long
Enter DSS Administrator Username : (Admin Username 입력)

DSS Administrator Password cannot contain spaces, or quotes, either single or double, and cannot be more than 80
characters long
Enter DSS Administrator Password: (패스워드 입력)
Re-enter DSS Administrator Password: (패스워드 확인)
Adding userName admin
Setup Complete!
#


여기까지 하면 설치는 모두 끝났다.

 

Darwin Streaming Server (DSS) 설정

그럼 이제 DSS(Darwin Streming Server)의 서버 설정을 해보자.

웹브라우져를 띄워서 http://IP_Address:1220 를 입력하자. (1220 포트는 DSS(Darwin Streming Server)의 관리자 페이지 접속을 위한 포트이다.)
로그인 화면이 나오면 지정한 Admin 계정과 패스워드를 넣고 다음으로 넘어가면, MP3 Broadcast를 위한 패스워드 설정이 나온다. 설정을 하고 다음으로 넘어간다.
다음으로 Secure Administration 설정이 나온다. 설정하고 또 넘어간다.
이제 Media Folder 설정이 나온다. 관리를 편하게 하기 위해 media 계정을 생성하고, 계정의 홈 디렉토리를 이용하면 나중에 관리하기 용이하다. 설정을 하였으면 넘어간다.
끝으로 Streaming on Port 80 설정이 나온다. 설정하고 완료한다.

여기까지를 모두 마치면, DSS(Darwin Streming Server) 관리자 페이지가 보일 것이고, 서버상태를 요약한 메인 화면이 보인다.


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


Friday, August 29, 2008

Darwin Streaming Server 6.0.3 on Linux

digg_url="http://cwshep.blogspot.com/2008/08/darwin-streaming-server-603-on-linux.html";0diggsdigg

Quick tutorial for installing DSS on Ubuntu 8.04.1 64bit (x86_64).

Most of these details can be found here: http://dss.macosforge.org/trac/ticket/6

Hopefully they will integrate these patches in to the next release, but until then here are the build instructions for Ubuntu:

Download DSS 6.0.3: http://static.macosforge.org/dss/downloads/DarwinStreamingSrvr6.0.3-Source.tar

Download this patch: http://dss.macosforge.org/trac/raw-attachment/ticket/6/dss-6.0.3.patch (Thank you Sverker Abrahamsson!)

And this patch: http://dss.macosforge.org/trac/raw-attachment/ticket/6/dss-hh-20080728-1.patch

Finally get the modified Install script: http://dss.macosforge.org/trac/raw-attachment/ticket/6/Install

The basic process is:

1. Get the build dependencies from the repositories.
2. Set up the qtss user (this is because the Install script does it in a way that is incompatible with Ubuntu)
3. Extract the source code.
4. Apply both patches.
5. Replace the Install script and chmod +x it.
6. Compile.
7. Install.

Notably for ssl admin you need the openssl and libnet-ssleay-perl packages, unfortunately even with these packages I was unable to get ssl admin to work.

I created the modified Install script; you can do a diff with the original if you want to see what I changed. Mostly just the paths were broken, but I am guessing that some other modules and such will probably not work.

Here is the bash script I used to do everything (including automatically download everything):


#!/bin/bash

sudo apt-get install build-essential wget
sudo addgroup --system qtss
sudo adduser --system --no-create-home --ingroup qtss qtss

wget http://static.macosforge.org/dss/downloads/DarwinStreamingSrvr6.0.3-Source.tar
tar -xvf DarwinStreamingSrvr6.0.3-Source.tar
mv DarwinStreamingSrvr6.0.3-Source DarwinStreamingSrvr6.0.3-Source.orig
wget http://dss.macosforge.org/trac/raw-attachment/ticket/6/dss-6.0.3.patch
patch -p0 < dss-6.0.3.patch
mv DarwinStreamingSrvr6.0.3-Source.orig DarwinStreamingSrvr6.0.3-Source
wget http://dss.macosforge.org/trac/raw-attachment/ticket/6/dss-hh-20080728-1.patch
patch -p0 < dss-hh-20080728-1.patch
#need to answer n then y
cd DarwinStreamingSrvr6.0.3-Source
mv Install Install.orig
wget http://dss.macosforge.org/trac/raw-attachment/ticket/6/Install
chmod +x Install
./Buildit
sudo ./Install




Update 2/2/2009: I changed the links to all point to dss.macosforge.org, which is a much more reliable host. Everyone should also take a look at that thread, as there are a lot of updates, including a newer patch from Horace Hsieh. I haven't played with this in a while, but if I get a chance I will try to update this with the newer patch. Please let me know if there are any problems (I just turned comment notifications on :/).

 

출처: http://blog.vinestory.com/87 

 

 

Automating startup of Darwin Streaming Server

Recently I have been using Darwin Streaming Media Server for some small movies. However, I quickly found out that when I rebooted the server Darwin does not automatically start up with it. It was necessary to start it manually each time the server was rebooted or started. Needless to day I find this very inconvenient. So I decided to write a startup script. It was really very easy, as you will see below.

I am using Fedora Core 4 and did a normal install of Darwin 5.5 from Apple.

Then I added the following script as the directory /etc/rc.d/init.d/darwinssd with darwinssd being the filename, not a directory.
You will need to be superuser in order to write to this directory.

# vi /etc/rc.d/init.d/darwinssd

#!/bin/bash
#
# created by Adam Culp of Unique Web Sites, Inc.
# at www.uniquewebsites.com
#
# darwinssd     Startup script for the Darwin Streaming Server
#
# chkconfig: 345 85 15
# description: Darwin Streaming Server startup/shutdown script
# processname: darwinssd
# pidfile: /var/run/darwinssd.pid
 
darwinssd=/usr/local/sbin/DarwinStreamingServer
RETVAL=0
 
# Source function library.
. /etc/rc.d/init.d/functions
 
case "$1" in
start)
echo -n "Starting Darwin Streaming Server[darwinssd]: "
daemon $darwinssd
RETVAL=$?
echo
touch /var/lock/subsys/darwinssd
;;
stop)
echo -n "Shutting down Darwin Streaming Server[darwinssd]: "
killproc $darwinssd
RETVAL=$?
echo
rm -f /var/lock/subsys/darwinssd
rm -f /var/run/darwinssd.pid
;;
status)
status $darwinssd
;;
restart)
$0 stop
$0 start
;;
reload)
echo -n "Reloading darwinssd: "
killproc $darwinssd -HUP
echo
;;
*)
echo "Usage: $0 {start|stop|restart|reload|status}"
exit 1
 
esac
 
exit 0

Of course you will also need to change the permissions on the file darwinssd to be -rwxr-xr-x (or 755).

# chmod -c 755 darwinssd

 

At this point you can treat darwinssd as if it was any other daemon. You can add it to the starup with:(must be root user for this command)

# chkconfig darwinssd on

# chkconfig --level 35 darwinssd on  <--- runlevel 35: autorun

As a superuser you would type it as:

# /sbin/chkconfig darwinssd on

It also has other features such as start, stop, restart, and reload.
The same applies here for any of these commands:

# service darwinssd restart

or as superuser

# /sbin/service darwinssd restart

 

출처: http://www.geekyboy.com/archives/9

 

 

 

Darwin Streaming Server


This article was for the following Ubuntu versions tested:

  • Feisty Fawn 7.04 Gutsy Fawn 7.04
  • Dapper Drake 6.06 (Long Term Support)

Darwin Streaming Server is the free version of QuickTime commercial server from Apple. Here are some of it's features:

  • Support for open standards: MP3, MPEG-4, H.264/AVC, RTP, RTSP
  • Open Source pursuant to Apple Public Source License
  • No term, no user restrictions, etc.
  • Free

In addition, the server through a Web interface, a simple configuration, even from another computer.



The Darwin server is suited for on-demand streaming, where the audio / video data is already in coded form as a file and available on demand by a user of each other. In connection with the Live encoder mp4live from mpeg4ip project, but it can also live streaming applications (eg Internet-TV).

The following instructions should assist in the installation and configuration of the Darwin server.

Preparation

For the installation of the Darwin Streaming Server, the following two packages need to be installed:

Libstdc + +5 (is already installed by default)
Checkinstall (Dapper)

To the Darwin streaming server after installation test can also be a good player for playback. This can be either locally on the server, or even better on a second computer to the server network is installed. It is proposed to take this opportunity to install the VLC media player with MPEG-4 support, but there are certainly other players to use.

The Darwin Streaming Server is not as a finished package for Ubuntu or Debian available, but must via Web browser as tar file from Apple's Web Download (registration required). The installation is described here the package Official Release - DSS 5.5.5 -> Linux -> streaming server is required, which the Linux binaries. The file is then downloaded and unpacked in the home directory.

Installation

After unpacking a terminal is opened and executed the following commands:

cd DarwinStreamingSrvrlinux Linux
sudo addgroup --system qtss
sudo adduser --system --no-create-home --ingroup qtss qtss

Gutsy Fawn

Under Ubuntu 7.04 Dapper Fawn the command is:

sudo. / Install

Dapper Drake

Under Ubuntu 6.06 Dapper Drake is the call warrant against:

sudo checkinstall - pkgname = darwin-server - pkgversion = 5.5.5. / Install

Here is a brief explanation of what the different commands effect:

  1. Change in the scale when unpacking subdirectory
  2. Creating a user group "qtss" (otherwise the installation doesn't work)
  3. Creating a user "qtss" (as before, but strangely ubuntu not necessary?)
  4. Calling the installation routine

After entering the last command line, the installation routine automatically and directed all the necessary directories and so spontaneous. It will also name and password for the administrator of the Darwin server queried. After completing the installation, the Darwin server automatically.

The installation of the server software is closed and the terminal can be closed.

Directories

The following table presents an overview of the most important files and directories of the Darwin server:

/usr/local/sbin/Darwin Streaming Server ---- Server Software
/usr/local/sbin/streamingadminserver.pl ---- Web Frontend
/etc/streaming ---- Configuration Dir
/etc/streaming/streamingserver.xml ---- Configuration File Server
/var/streaming/logs ---- Logs
/usr/local/movies ---- Default directory for video files

Then, the file /etc/streaming/streamingserver.xml must be given write privledges, otherwise no configuration can be saved:

sudo chmod 755 /etc/streaming/streamingserver.xml

Configuration and Test

The configuration of the Darwin server via a web interface and the following link called:

http://<Server-IP>:1220

After signing up as an administrator using the software installation previously elected login information can now be made more settings. When you first call up the site initially queried following information:

  • MP3 Broadcast Password
  • Secure Administration
  • Media Folder: /usr/local/movies
  • Streaming on Port 80 Streaming on Port 80

It is important here first is that the path to the video files (Media Folder) correctly specified, all other issues can safely with the "Next" button skipped.In the specified directory /usr/local/movies are already some demo videos, for the first function tests can be used. It is therefore appropriate that this requirement to make changes at any time are on the configuration menu. After defining these four points will eventually configuration mask for the Darwin server, in other settings can be made. Leave the configuration screen by clicking on "Sign Out" (left column bottom).

Now you can test whether the Darwin server works as desired. This is the VLC media player opened and the menu "File -> Open Network Stream" stream following address:

rtsp://<Server-IP>/sample_100kbit.mp4

If everything is installed correctly, you should now be a player in the supplied sample videos will be shown. Congratulations!

Start Server

During power of the computer is not of the Darwin server automatically, but servers and web interface must either in a terminal on the following two lines of command

sudo /usr/local/sbin/DarwinStreamingServer
/usr/local/sbin/streamingadminserver.pl

Or by corresponding entries in the Start menu manually invoked. As servers and web interface can also start automatically, is contributing startup. In addition, there are init scripts for the Darwin server and the admin interface.

MPEG-4 video streaming

In order to use the server as streaming video-on-demand server videos must be in MPEG-4 format (file extension .mp4). Using the under video editing or DVD rippin tools. Videos in Quicktime format (. Mov) could also be used, but are probably less interesting.

However, before an MPEG-4 video with the Darwin server can be streamed must have known in advance hint tracks in the data stream added. They are required to fast forward and rewind the video. For inserting the hint tracks use Tool MP4Box in the package:

  • gpac (multiverse, [2])

The syntax for the command call for inserting the hint tracks reads:

MP4Box -hint dateiname.mp4

With the option-unhint can be inserted information may also be removed.

Alternatively, can the hint tracks with the tool mp4creator from the MPEG4IP project.

After inserting the hint tracks, the video file only in the video directory of the Darwin server will be copied or moved, immediately thereafter, the video for the call may be accessed via the web interface also includes a playlist can be created.

MP3 audio streaming

With the Darwin server can not only MPEG-4 videos, but also MP3 audio files stream. As you can create MP3 files, for example, in the contribution rip CDs. To existing MP3 files on stream, must first play lists, which, thanks to the existing web interfaces but made relatively quickly. (Guide in German, not included)

The MP3 player, the create play lists at the address:

http://<Server-IP>:8000/Mountpunkt

 

--- Re

Command
Code:
/usr/local/sbin/streamingadminserver.pl
must be run as root too
Code:
sudo /usr/local/sbin/streamingadminserver.pl
or otherwise you'll get an error
Code:
Couldn't find the en language messages file! at /usr/local/sbin/streamingadminserver.pl line 2167.
Killing the server
Code:
root@mansikki:~# ps -Af | grep -i stream
root      5857     1  0 11:28 ?        00:00:00 /usr/local/sbin/DarwinStreamingServer
qtss      5858  5857  0 11:28 ?        00:00:00 /usr/local/sbin/DarwinStreamingServer
qtss      6061     1  0 11:32 ?        00:00:00 /usr/bin/perl /usr/local/sbin/streamingadminserver.pl
root      6233  6205  0 11:35 pts/9    00:00:00 grep -i stream

killall DarwinStreamingServer 
kill 6061

 

--- Re 

There is file /etc/streaming/qtusers
to manage the file use qtpasswd tool as follows:
/usr/bin/qtpasswd -c -p password administrator

 

'Linux > CentOS' 카테고리의 다른 글

CentOS Iptables 방화벽 포트 OPEN  (0) 2012.09.07
Wowza Media Server 설치  (0) 2012.09.07
부팅 시에 네트워크 자동 시작  (0) 2012.09.05
사용자 계정 추가  (0) 2012.09.03
CentOS VNC 설정 및 사용법  (0) 2012.08.31
Posted by iWithJoy
Linux/CentOS2012. 9. 5. 20:12

설정 중에 네트워크 설정이 바뀌었거나

랜카드가 2개 장착된 경우, 설정을 바꿀 때 자동 시작이 풀렸을 때,

리부팅했을 때, 랜카드 연결이 자동으로 되지 않을 때는 아래와 같은 설정을 확인하여 수정한다.

 

# vi /etc/sysconfig/network-scripts/ifcfg-eth0   <--- eth0 부분은 네트워크 카드명

 

DEVICE="eth0"
BOOTPROTO=none
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
UUID="47ec6d4e-47ee-4d66-be2f-bfb0b1701017"
IPADDR=xxx.xxx.xxx.xxx
PREFIX=27
GATEWAY=xxx.xxx.xxx.xxx
DNS1=168.126.63.1
DNS2=168.126.63.2
DOMAIN=xxx.com
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
HWADDR=00:26:66:43:20:59
LAST_CONNECT=1346799755

위의 내용 중에 ONBOOT="no"로 바뀐 경우,

시스템 재시작 시에 랜카드 연결이 자동으로 수행되지 않는다.

Posted by iWithJoy
Linux/CentOS2012. 9. 3. 11:04

계정 추가
# useradd [계정이름]

비밀번호 설정
# passwd [계정이름]

계정 삭제
# userdel [계정이름]

계정 관련 데이터 삭제
# userdel -r [계정이름]

 

시스템>관리>사용자및그룹 에서 확인

 

참고: http://blog.naver.com/reum900415?Redirect=Log&logNo=10105614191

Posted by iWithJoy
Linux/CentOS2012. 8. 31. 09:38

CentOS 5.5 에는 기본적으로 VNC Server가 설치되어 있어 환경설정과 서비스 등록만으로 VNC를 사용할 수 있다.

만약, 설치되지 않은 경우, 아래와 같이 설치한다.

 

일단, CentOS가 설치된 서버에 GUI가 설치되어 있어야 한다.

만약, 설치되어 있지 않다면 다음과 같이 명령하여 설치한다.

yum groupinstall "X Window System" "KDE Desktop"

 

VNC 소프트웨어를 설치한다.

yum install tigervnc-server



1. 환경

- CentOS 5.5  : 설치됨
- VNC Viewer : http://www.uvnc.com/download/ 에서 다운로드



2. 설정

# vi /etc/sysconfig/vncservers



3. vncservers 내용 수정

# The VNCSERVERS variable is a list of display:user pairs.

#

# Uncomment the lines below to start a VNC server on display :2

# as my 'myusername' (adjust this to your own).  You will also

# need to set a VNC password; run 'man vncpasswd' to see how

# to do that.

#

# DO NOT RUN THIS SERVICE if your local area network is

# untrusted!  For a secure way of using VNC, see

# <URL:http://www.uk.research.att.com/archive/vnc/sshvnc.html>.


# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.


# Use "-nohttpd" to prevent web-based VNC clients connecting.


# Use "-localhost" to prevent remote VNC clients connecting except when

# doing so through a secure tunnel.  See the "-via" option in the

# `man vncviewer' manual page.


# VNCSERVERS="2:myusername"

# VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd -localhost"


VNCSERVERS="1:root"

VNCSERVERARGS[1]="-geometry 12800x800"

만약, root가 아닌 사용자ID로 사용을 하고자 하는 경우,

root를 사용자ID로 수정 후, 저장하고,

아래의 암호설정 시에도 su상태가 아닌 사용자ID 상태에서 설정해야 한다.

4. VNC 암호 설정

# vncpasswd
Password:
Verify:



5. Port 확인 및 방화벽 오픈

# netstat -antp
 

Active Internet connections (servers and established)

Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name

tcp        0      0 0.0.0.0:5801                0.0.0.0:*                   LISTEN      25974/Xvnc

tcp        0      0 0.0.0.0:5901                0.0.0.0:*                   LISTEN      25974/Xvnc

tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      2629/portmap

tcp        0      0 0.0.0.0:6001                0.0.0.0:*                   LISTEN      25974/Xvnc



# vi /etc/sysconfig/iptables

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5901 -j ACCEPT
  (추가)



5-1. iptable restart

# /etc/rc.d/init.d/iptables restart



6. VNC Server 시작

# service vncserver start


 
7. 서버 부팅시 자동 실행 service로 등록

# chkconfig vncserver on


  
8. 윈도우에서 그래픽모드로 보기 위한 설정

# vi /root/.vnc/xstartup



#!/bin/sh


wing two lines for normal desktop:

# unset SESSION_MANAGER (# 제거)

# exec /etc/X11/xinit/xinitrc (# 제거)


[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup

[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources

xsetroot -solid grey

vncconfig -iconic &

xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &

twm &


# Uncomment the following two lines for normal desktop:

unset SESSION_MANAGER

exec /etc/X11/xinit/xinitrc


[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup

[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources

xsetroot -solid grey

vncconfig -iconic &

xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &

twm &





9. VNC Viewer로 접속 확인 



10. 접속화면





11. 참고

http://jonnychoe.egloos.com/5472045

Posted by iWithJoy
Linux/CentOS2012. 6. 4. 09:26

일단 웹사이트의 기본원리에 대해 알 필요가 있다.

 

웹사이트는 익스플로러에 도메인을 치면 DNS(domain name server)에서 해당

 

도메인의 서버에 연결해주는 구조다.

 

인터넷익스플로러->도메인입력-> 해당 도메인에 설정된 DNS서버에 서버ip 요청->

해당 서버ip로 웹사이트 접속

 

 

서버에 세팅해야될건 간단히 3가지다.

 

네트워크, 아파치, DNS설정

 

 

1. 네트워크설정

루트로 vi편집기를 이용해 네트워크파일을 연다.

vi /etc/sysconfig/network

 

 

#네트워크사용여부

NETWORKING=yes

 

#호스트명, 아파치 세팅에 servername과같지않으면 문제가 발생할수 있다.
HOSTNAME=localhost

#게이트웨이주소

GATEWAY=203.241.205.254

#첫번째 랜카드로 설정

GATEWAYDEV=eth0

 

왠만한건 설정되있어서 게이트웨이만 설정하면된다.

 

/etc/sysconfig/network-scripts/ifcfg-eth0

IPADDR=61.2.44.15

NETMASK=255.255.255.0

 

아래 파일에 자동 생성 및 설정된다.

/etc/sysconfig/network-scripts/ifcfg-Auto_eth0

/etc/sysconfig/network-scripts/ifcfg-lo

 

필수값만 설정을 바꿔주면 된다.

 

네트워크 설정이 끝나면 네트워크를 리스타트한다.

/etc/init.d/network restart

 

 

 

네트워크 설정이 끝났다. 이제 DNS를 설정한다.

 

DNS설정은 3가지 방법이있다.

1. hosts파일에 ip와 도메인을 입력해서 자체적으로 처리하는방법

2. 외부에있는 DNS서버에서 조회하는방법

3. 자체적으로 DNS를 구현해서 조회하는방법

 

 

1번방법은 서버 /etc/hosts 파일에 ip와 도메인을 적어 DNS에서 서버ip를 조회하지 않더라도

해당 도메인을 접속하면 hosts파일에 기록된 도메인의 ip를 알려준다.

웹사이트가 추가될때마다 hosts에 추가해야되기때문에 번거롭다. 이 방법은 로컬에서

테스트할때나 사용하지 상용서비스에서는 잘 사용하지 않는다.

 

2번방법은 외부에 DNS서버가 있어서 해당 DNS서버에서 ip를 조회해온다.

상용서비스에서 많이 사용하는 방법이며 보통 대기업에서는 자체 DNS서버를 가지고있다.

/etc/resolv.conf 파일에 nameserver 부분에 해당 DNS서버 ip를 기재한다.

수정이 완료되면 nslookup 명령어를 이용해서 도메인을 입력 후 해당 DNS서버에서 도메인 ip를

제대로 조회하는지 확인한다.(해당 도메인의 address가 해당 서버로 되있는지 확인) 조회가 안되는건 DNS서버에 해당 도메인이 설정되지 않은것이다. 만약 address가 해당 서버와 다르면 dns변경을 요청해야한다.


3번방법은 1번과 다를게 없으며 자체서버에 DNS서버를 구현해야되기때문에 번거롭다.

다른 서버에서도 해당 서버에서 DNS조회해오면 모르겠지만 여기서는 생략하겠음.

 

 

웹사이트의 DNS조회순서는 hosts파일을 먼저 보고, 그다음 DNS설정으로 조회한다.

hosts에 먼저 조회하기때문에 같은 도메인을 세팅해놨다면 dns서버에서 가져올려고 했는데 hosts에 세팅된 도메인 ip로 접근할수도 있으므로 헷갈리지 않게 주의한다.(순서를 변경하는 방법도있으나 잘쓰이지 않으므로 여기서는 생략)

 

 

이제 아파치세팅만 남았다.

 

아파치에서는 버추얼 호스트만 잘 설정해주면된다.

아파치의 버추얼 호스트는 2가지 방식이 있다.

 

1. ip-based 버추얼호스트

<VirtualHost 210.22.255.1> 이런식으로 IP로 구분한다.

웹사이트가 1개라면 모르겠지만 여러개일경우 name-based 버추얼 호스트로 DNS조회하는 방식으로 하려면 사용하지 못한다.

 

2. name-based 버추얼 호스트

<VirtualHost www.aaa.com> 이런식으로 도메인으로 구분한다.

해당 설정된 도메인을 hosts와 DNS로 ip를 조회한다. hosts와 DNS에 도메인이 설정되있지 않다면

아파치 시작시 에러가 발생하므로 주의한다.

 

 

vi /usr/local/apache/conf/httpd.conf

예제는 aaa.com, bbb.com이라는 도메인이 있다는 가정하에 진행된다.

주의할점은 www가 없는 경우도 추가해야 한다는 점이다.

(Serveralias 설정은 제외됐다)

 

<VirtualHost www.aaa.com>
ServerAdmin webmaster@aaa.com
DocumentRoot /home/aaa/
ServerName www.aaa.com 
ErrorLog /var/log/httpd/error_log
CustomLog /var/log/httpd/access_log combined
</VirtualHost>

 

<VirtualHost aaa.com>
ServerAdmin webmaster@aaa.com
DocumentRoot /home/aaa/
ServerName aaa.com
ErrorLog /var/log/httpd/error_log
CustomLog /var/log/httpd/access_log combined
</VirtualHost>

 

<VirtualHost www.bbb.com>
ServerAdmin webmaster@bbb.com
DocumentRoot /home/bbb/
ServerName www.bbb.com 
ErrorLog /var/log/httpd/error_log
CustomLog /var/log/httpd/access_log combined
</VirtualHost>

 

<VirtualHost bbb.com>
ServerAdmin webmaster@bbb.com
DocumentRoot /home/bbb/
ServerName bbb.com
ErrorLog /var/log/httpd/error_log
CustomLog /var/log/httpd/access_log combined
</VirtualHost>

 

 

이제 아파치를 시작하면 설정이 끝난다.

여기까지 했다면 2차도메인 사이트 만드는것도 간단해진다.

abc.aaa.com를 추가하고 싶다면

 

<VirtualHost abc.aaa.com>
ServerAdmin webmaster@aaa.com
DocumentRoot /home/aaa/
ServerName abc.aaa.com
ErrorLog /var/log/httpd/error_log
CustomLog /var/log/httpd/access_log combined
</VirtualHost>

 

간단해지는군. 대신 DNS서버에 해당 도메인이 설정되있다는 가정 하에.

 

리스타트...

/etc/rc.d/init.d/named restart

[출처] 리눅스 서버에 여러개의 웹사이트 구현하기|작성자 강동수

 

 

서브 도메인과 가상 호스트 설정 방법은 아래의 주소를 참고하기 바란다.
http://blog.daum.net/_blog/BlogTypeView.do?blogid=09VKU&articleno=13679267#ajax_history_home

 


새로운 도메인을 추가하는 경우, 아래의 처리들을 다시한번 확인해본다.
--------------------------------------------------------------------------------
[root@ns user]# vi /etc/resolv.conf
[root@ns user]# vi /etc/hosts <--- 신규 추가 시에 추가 필요
[root@ns user]# vi /etc/named.conf <--- 신규 추가 시에 추가 필요
[root@ns user]# vi /var/named/chroot/var/named/도메인주소.zone <--- 신규 추가 시에 생성 필요
[root@ns user]# ln -s /var/named/chroot/var/named/도메인주소.zone /var/named/도메인주소.zone
[root@ns user]# vi /usr/local/apache/conf/httpd.conf <--- 신규 추가 시에 추가 필요

[root@ns user]# /etc/rc.d/init.d/named reload
[root@ns user]# service named restart
[root@ns user]# service httpd restart

이제, 도메인을 등록한 사이트의 네임 호스트 관리에서 네임 호스트 및 IP주소를 추가하고,
네임서버를 네임 호스트 관리에서 입력한 네임 호스트로 입력하여 변경을 수행(보통, 등록한 사이트의 네임서버로 초기설정된 상태)

등록을 완료한 후에 ISP의 네임서버에 등록 및 변경이 수행되기까지는 약간의 시간이 필요하다.
잠시 후에 아래의 명령으로 정상 등록 및 변경여부를 확인한다.

[root@ns user]# nslookup 도메인주소
[root@ns user]# dig 도메인주소

시스템 > 관리 > 사용자 및 그룹에서 사용자를 추가 후에 권한을 변경한다. 

[root@ns user]# chmod 711 /home/사용자

[root@ns user]# chmod 755 /home/사용자/www

[root@ns user]# chgrp -R star-r /home/사용자

[root@ns user]# chown -R star-r /home/사용자

 

 

DNS 설정을 위한 기본적인 파일들에 대해 알아본다.

--------------------------------------------------------------------------------
rpm -qa | grep bind   확인

* bind-9.3.6-16.P1.el5.rpm - bind 기본 패키지
* bind-libs-9.3.6-16.P1.el5.rpm - bind서버 패키지와 utils패키지에 의해 사용되는 라이브러리 포함
* bind-utils-9.3.6-16.P1.el5.rpm - name서버를 질의 하고 인터넷 호스트에 대한 정보를 찾아주는 유틸리티 모음
* caching-nameserver-9.3.6-16.P1.el5 - bind운영에 필요한 환경설정 파일 모음 패키지 

없으면 yum으로 설치
ex) yum install bind

[네임서버 설정 파일]
기본적으로 이용되는 네임서버 파일

 파일명  역할
 /etc/sysconfig/named   Chroot를 적용할 네임서버 루트 디렉토리를 설정하는 파일로 rpm패키지에만 포함되어 있다.
 /etc/init.d/named  네임서버 데몬을 띄워주는 init 스크립트
 $/etc/named.caching-nameserver.conf  네임서버 설정 파일로 chroot가 적용될 때는 /var/named/chroot/etc/ 디렉토리에 위치
 /etc/rndc.key  공유키 파일 설정
 $/var/named/*.zone  /etc/named.ca에서 명시한 존 파일이 위치하는 장소로 chroot를 적용하는 경우에는 /var/named/chroot 디렉토리에 존 파일이 위치, 존 설정 파일
 $/var/named.ca  루트네임서버 캐쉬 파일.
 $/slaves/도메인이름.zone
 $/slaves/도메인이름.rev
 primary dns서버에서 받아온 정방향 역방향 조회영역이  저장되는 파일

출처: http://croak.tistory.com/94

Posted by iWithJoy
Linux/CentOS2012. 4. 11. 18:01

Centos 5.7(192.168.0.10)에 /backup 디렉토리가 있고, 그 안의 자료를

Windows XP(192.168.0.20)의 D:\down_backup 폴더에 rsync로 끌어오는 방법입니다.   

 

 

1. Centos 5.7(192.168.0.10) 설정

 

# yum install rsync xinetd

# vi /etc/xinetd.d/rsync

___________________________________________

 service rsync
{
        disable = no                     <==== yes 를 no 로 바꾸삼.
        socket_type     = stream
        wait            = no
        user            = root
        server          = /usr/bin/rsync
        server_args     = --daemon
        log_on_failure  += USERID
}
--------------------------------------------

 

# vi /etc/rsyncd.conf

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

Log file = /var/log/rsync.log

 

[backup_home]            <========= 소스이름
path=/home
comment=HomeBackup
uid=root
gid=root
use chroot=yes
read only=yes
hosts allow= 192.168.0.20
max connections=10
timeout=9000000

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

 

# /etc/rc.d/init.d/xinetd restart

 

방화벽에서 TCP / 873 포트 오픈

 

 

2. windows xp(192.168.0.20) 설정

 

먼저 D:\down_backup 폴더를 만든다.

그리고 아래사이트에서 cwRsyncServer_4.1.0_Installer.zip 다운받는다.

 

ftp://ftp.dutaint.co.id/freeware/ftp-webdav-ssh-server/cwRsyncServer_4.1.0_Installer.zip

 

압축을 풀고 설치를 한다.

 

설치를 하면 기본적으로 C:\Program Files\ICW 폴더에 설치가 된다.

 

backup.cmd 파일을 하나 생성한다.

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

@ECHO OFF

SETLOCAL
rem SET CWRSYNCHOME=%PROGRAMFILES%\CWRSYNC
SET CWRSYNCHOME=c:\Program Files (x86)\ICW
SET HOME=%HOMEDRIVE%%HOMEPATH%
SET CWOLDPATH=%PATH%
SET PATH=%CWRSYNCHOME%\BIN;%PATH%

 

rsync -avzrog --delete --exclude=sess_* 192.168.0.10::backup_home /cygdrive/d/@Backup/zCentOS
pause

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

/cygdrive/d/@Backup/zCentOS는 windows xp 의 D:\@Backup\zCentOS 폴더이다.

 

이제 준비가 모두 되었다. backup.cmd 파일을 실행하자.

 

C:\Program Files\ICW>backup.cmd
----------------------------------------------------------------------------

receiving incremental file list
./
.bash_history
.bash_logout
.bash_profile
.bashrc
.cshrc
.tcshrc
anaconda-ks.cfg
drop-iptable-list
install.log
install.log.syslog
.gconf/
.gconf/apps/
.gconf/apps/%gconf.xml
.gconf/apps/gnome-session/
.gconf/apps/gnome-session/%gconf.xml
.gconf/apps/gnome-session/options/
.gconf/apps/gnome-session/options/%gconf.xml
.gconfd/
.gconfd/saved_state
.lftp/
.lftp/cwd_history
.lftp/rl_history
.lftp/transfer_log

sent 376 bytes  received 13417 bytes  9195.33 bytes/sec
total size is 45121  speedup is 3.27

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

 

이렇게 실행된다.

 

backup.cmd  를 예약된 작업에 넣어서 원하는 시간대에 실행하면 자동으로 백업이 된다.

[출처] Centos 5.x 서버에서 windows XP 로 rsync로 cwRsync를 이용해서 백업 하기 |작성자 삽질맨

 

rsyncd 백업하는 방법... (For 슈퍼데몬 xinetd)

 

기본형식

댕기는거나 미는거나 커맨드 날리는 입장에서는 슈퍼대몬과 rsyncd.conf 는 반대편 서버에 셋팅되어 있음
댕기는거나 미는거나 커맨드에서 보면 원본이 앞에 오고 복사본쪽이 뒤에 나열됨

rsyncd 댕김
rsync -avzPog 원본쪽IP::백업이름 백업디렉토리

ex) rsync -avzPog 192.168.15.178::test /home/test/

rsyncd 밀다
rsync -avzPog 백업디렉토리 복사본만들IP::백업이름

ex) rsync -avzPog /data1/ 192.168.15.179::data1

 

 

ssh를 사용한 미러링
 - xinted 설정파일 및 rsyncd.conf 파일 필요없음, 사용자 인증만 되면 동기화 가능

 

ex ) rsync -avz -e ssh hostname(IP):/타켓경로 / 백업받을경로

rsync -avz -e "ssh -p 22" XXX.XXX.30.229:/home /backup/

rsync -avzPog /etc/shadow
root@XXX.XXX.15.178:/etc

 

op)
-a : archive mode 심볼릭 링크, 속성, 퍼미션, 소유권 보존
-v : verbose 진행상황 표시
-z : compress 전송시 압축 수행
-u : update only 새로운 파일을 덮어쓰지 않음
-e : 복사를 위한 원격접속쉘 프로그램을 설정한다
--delete : 서버측에 없고 클라이언트측에만 있는 파일을 지운다

: 은 ssh 나 rsh 를 이용할때 씀
:: 은 TCP 873 포트를 이용할때 설정 (xinetd)

ex)

 

rsync -avzrO --delete --exclude="backup-53/" 115.XX.XX.52::DB /home/backup-52
- 115.XX.XX.52에 설정된 DB라는 이름의 백업을 /home/backup-52파티션에 복사
- 해당 원본의 backup-53/ 폴더를 제외하고 백업을 함

파일 확장자로도 가능
--exclude=*.bak
--exclude=*.info

--exclude="backup-53/" : backup-53 폴더는 생기지만 하위자료 복사 안됨
--exclude="backup-53/" : backup-53 폴더도 생성되지 않음

 

 

error) 아래와 같이 에러시 설정부분에 문제가 없는데 계속 에러가 난다면 selinux 해제 수행: # setenforce 0

[root@localhost /]# rsync -avzO 192.168.2.53::TEST /home/backup-53/
receiving file list ... rsync: opendir "/." (in TEST) failed: Permission denied (13)
done
sent 70 bytes received 133 bytes 406.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files could not be transferred (code 23) at main.c(1385)

 

Selinux 상태 확인 및 해제하기
  1. selinux 상태 확인
    # sestatus -v
  2. selinux 해제하기
    vi /etc/selinux/config
    이후 내용 중 아래와 같이 수정한다.
    SELINUXTYPE=disabled
    또는
    # setenforce 0

     

SELinux는 보안을 강화하기 위한 프로그램이다.

매우 강력한 프로그램으로, 파일 1개 읽을 때 조차도 권한을 검사할 정도로 강력한 보안을 요구한다.

규칙을 잘 만들어서 적용하면 아주아주 강력한 보안을 설정할 수 있지만 많은 이들은 쓸데없이 서버를 부하를 일으키거나 룰셋을

만들기 어렵다는 이유로 사용을 꺼려한다.

또한 관련 서적도 국내에 나온것이 없다.(번역서가 없다 ㅠㅠ)

더 장황하게 기술적인 것을 설명(이라기 보단 어디서 퍼오기)을 할 수 있지만

그런 것은 별로 알 필요가 없기 때문에 이정도로만 알아두면 두기로 하자.

 

만약 XWindow를 이용해서 SELinux를 끄고 싶다면 아래에 있는 ProFTPD 설치하기 편을 참고하도록 하고

터미널(혹은 콘솔창이라고도 함)에서 끄고 싶다면 아래와 같이 한다.

방법은 총 3가지가 있다.


1. 수동으로 끄기 (일시적으로만 먹힘)
system-config-securitylevel
setenforce 0

2. 커널 명령행에 다음 옵션 추가. (grub.conf 등에)
selinux=0

3. /etc/selinux/config 파일 수정 ***추천***
SELINUX=어쩌구~ 써있는 것을 SELINUX=disabled로 수정

 

 

rsync 설정 1) 로컬에서 로컬 (다른 파티션 등)로 Mirroring할 경우에는 rsync를 데몬으로 띄우지 않아도 된다. 1. /etc/rsyncd.conf 설정 ;설정변경시 rsync서버 재실행할 필요가 없다. [root@p-net etc]# vi /etc/rsyncd.conf [www] path=/usr/local/apache/htdocs comment=WWW_Backup uid=root gid=root use chroot=yes read only=yes hosts allow=192.168.1.20 ;내부 ip로 공유되어 있는 경우 공인ip는 인정되지 않는다. max connections=1 timeout 600 ;설정 방법 [www]: 서비스명 path: 서비스할 디렉토리위치 comment: 설명 uid: 파일전송하는 사용자의 id. 기본값은 nobody gid: 파일전송하는 사용자의 그룹 id. 기본값은 nobody use chroot: 위의 path를 root 디렉토리로 사용. (보안상 필요) read only: 읽기전용 ( 클라이언트에서 서버로 올리는 경우에는 read only= no 로 설정) hosts allow: 호스트별 접속허용. 기본값은 all host, 접근을 허용할 호스트의 ip를 적어주면 됨 hosts deny: 이 모듈에 연결할 수 없는 호스트들 리스트 max connections: 동시접속자수 timeout: 클라이언트에서 접근시 타임아웃시간. anonymous 로 운영하는 경우 설정을 해야 클라이언트가 죽었을 때 서버에서 접속을 해체할 수 있음 auth users: "auth users" 옵션은 이 모듈에 접속을 허락하는 사용자 이름의 리스트를 콤마(comma)와 공백(space)로 지정한다. 사용자 이름은 지역 시스템에 존재하지 않아도 된다. “auth users”가 지정되어 있다면 클라이언트(client)는 사용자이름과 비밀번호를 이 모듈에 접속하기 위해서 제공해야 할 것이다. 이 교환을 위해서 사용되어지는 인증 프로토콜이 요구에 응답한다. 사용자이름들과 비밀번호들이 “secrets file” 옵션으로 지정되는 text 파일에 저장된다. 모든 사용자를 위해서 기본적으로 비밀번호 없이 접속할 수 있다. (이것을 “익명(anonymous) rsync”라고 부른다). secrets file: "secrets file" 옵션은 인증을 위해서 사용되는 항상의 username:password를 포함하는 파일의 이름을 지정한다. 이 파일은 “auth users” 옵션이 지정되었을 때만 참조한다. 이 파일은 행 기반이고 :(single colon)으로 구분되는 한 쌍의 username:password를 포함하고 있다. hash(#)로 시작하는 행은 주석으로 해석되고 생략된다. 비밀번호는 어떠한 문자로도 가능하지만, 많은 운영체제에서 클라이언트(client) 끝에서 치지는 패스워드의 길이의 제한을 주의해서, 8문자 보다 더 큰 패스워드는 동작하지 않을 것이다. "secrets file" 에는 기본 옵션이 없으므로, 이름을 지정해야 한다. ( /usr/local/rsync/etc/rsyncd.secrets 처럼) 2. /etc/xinetd.d/rsync 설정 [root@p-net etc]# vi /etc/xinetd.d/rsync disable = no -> disable = yes [root@p-net etc]# service xinetd restart 3. 방화벽 설정 [root@p-net etc]# vi /etc/sysconfig/iptables -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 873 -j ACCEPT ;873 tcp포트 개방
또는

-A INPUT -m state --state NEW -m tcp -p tcp --dport 873 -j ACCEPT
[root@p-net mail]# /etc/init.d/iptables restart 4. Client에서 접속 1) 접속 옵션 -a : archive mode (심볼릭 링크, 속성, 퍼미션, 소유권 등 보존). -v : verbose(상세하게 보여움). -z : compress(전송시 압축을 함). --delete : 전송시 원본에 없는 파일을 복사본에서 삭제함 2) 정상접속 후 자료 수신 [root@linuxhost root]# rsync -avz 192.168.1.200::www /usr/local/apache2/htdocs/ receiving file list ... done 3) 방화벽이 오픈되지 않은 상태에서 rsync로 접속을 시도한 경우 [root@linuxhost root]# rsync -avz 192.168.1.200::www /usr/local/apache2/htdocs/ rsync: failed to connect to 192.168.1.200: No route to host rsync error: error in socket IO (code 10) at clientserver.c(97) 4) 접속허용 ip주소가 제대로 설정되지 않은 경우 [root@linuxhost root]# rsync -avz 192.168.1.200::www /usr/local/apache2/htdocs/ @ERROR: access denied to www from unknown (192.168.1.20) rsync: connection unexpectedly closed (69 bytes read so far) rsync error: error in rsync protocol data stream (code 12) at io.c(150) <리스트 5> 특정한 ssh port 사용 rsync -avuzr -e "ssh -p 8888" /home 192.168.100.210:/data 접속할 서버의 패스워드 문제 cron에 등록해 자동화할 때 이것으로 인해 문제가 초래될 수 있다. 이때는 My Server의 ssh 키를 백업 서버에 다음과 같이 복사해 패스워드 없이도 접속할 수 있도록 설정한다. scp ~/.ssh/id_rsa.pub root@192.168.100.210:.ssh/ authorized_keys rsync의 업데이트 파일 인식 rsync가 업데이트된 파일인지 아닌지를 구별하는 방법은 다음과 같다. 먼저 My Server의 /home과 백업 서버의 /data 디렉토리 내에 있는 동일한 이름의 파일을 각각 비교한다. /data 에 있는 파일의 시간보다 /home에 있는 파일의 시간이 더 최근 것이면 업데이트된 파일이라고 판단한다. 만일 갱신된 파일이지만, 서버의 시간이 올바로 설정되지 않아 /data에 존재하는 동일 이름의 파일 시간보다 과거의 시간으로 표시되었다면 rsync는 이를 업데이트된 것으로 인식하지 못한다. 따라서 서버의 시간은 항상 정확하게 유지되어야 한다. 만일 인증키를 심을 수 없는 환경이라면 <리스트 6>을 참고해 자동으로 패스워드를 입력해주는 스크립트를 제작한다. 이를 통해서도 rsync 백업을 자동화 할 수 있다. <리스트 6> expect를 이용한 rsync 자동화 #!/usr/bin/expect spawn /rsync -avuzr -e "ssh -p8060" /home 192.168.100.210:/data expect " expect 'root@192.168.100.210's password:" send "패스워드\r" interact [출처] 웹 관리자를 위한 응급처치법|작성자 아트

Posted by iWithJoy
Linux/CentOS2012. 4. 10. 18:42

최신 php 5.4.0을 설치하였다가 보안관계로 safe_mode 옵션항목 등이 삭제된 관계로

kcp에서 제공한 실행파일을 php에서 사용이 불가하여, 결국, php 5.3.10으로 다운그레이드 수행이 필요하였다.

 

@ 패키지 제거 및 설치
# rpm -qa httpd php mysql
# yum remove -y httpd php mysql
# rm -fR php

# rm /usr/local/lib/php.ini

 

 

@ PHP 설치
# cd /usr/local/src
# wget http://kr2.php.net/get/php-5.3.10.tar.gz/from/kr.php.net/mirror
# tar zxvf php-5.3.10.tar.gz
# cd php-5.3.10

# make clean ---> 처리 미존재(무처리)
# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/lib --with-gd --with-freetype-dir=/usr/local/freetype --with-zlib --enable-sockets --enable-gd-native-ttf --with-png-dir=/usr/local/lib --with-jpeg-dir=/usr/local/lib --enable-sigchild --enable-magic-quotes --with-gettext --enable-mbstring --enable-inline-optimization --enable-bcmath --enable-shmop --enable-calendar --enable-ftp --with-gdbm --with-iconv=/usr/local --enable-mbregex --with-imap --with-imap-ssl --with-openssl --with-curl --enable-soap --disable-debug --with-mcrypt=/usr/local/libmcrypt --with-kerberos --with-mysqli=/usr/local/mysql/bin/mysql_config
# make -j4; make install
# cp php.ini-production /usr/local/lib/php.ini ---> 5.3.0 이후 버전

 

특정 디렉토리의 파일을 실행하려면,

# vi /usr/local/lib/php.ini

...

short_open_tag = On

으로 설정해야 <?인 경우에도 php로 인식한다.

...

또한,

safe_mode = off

로 처리하거나
safe_mode_exec_dir = 특정 디렉토리명

에 지정된 해당 디렉토리에 존재하는 실행 파일만 실행가능토록 수정 필요.

(미설정 시에는 root에 있는 파일만 참조)

 

설정 인자

권장값

요약 설명

register_globals

Off

On으로 하면 php가 입력으로 받아들이는 값을 전역변수로 다루게 되므로 Off로 설정

safe_mode

On

on으로 설정하면 시스템 중요 파일(/etc/passwd) 접근을 제한할 수 있으나, 웹 프로그램이 정상 작동하지 않을 수 있다.

safe_mode_gid

Off

위 설정과 연관되어 시스템 중요 파일(/etc/passwd) 접근을 제한할 수 있으나, 웹 프로그램이 정상 작동하지 않을 수 있다.

expose_php

Off

웹 브라우저의 요청에 대해 PHP 정보 노출을 방지한다.

file_uploads

Off

파일 업로드를 사용하지 않을 경우 Off로 설정 한다.

allow_url_fopen

Off

On으로 설정하면 파일 액세스 시 외부 사이트의 파일을 호출할 수 있다. 특히 include(), require() 계열의 함수 사용 시 심각한 보안상의 문제를 유발한다.

magic_quotes_gpc

On

On으로 설정하면 PHP가 입력으로 받아들이는 값에 단일 인용부호, 이중 인용부호, 백슬래시, 널문자가 포함된 경우 자동으로 해당 문자앞에 백슬래시를 추가하여 특수문자 처리한다.

magic_quotes_sybase

Off

Sybase 사용자의 정상적인 DB 접속을 위해 만들어진 기능. magic_quotes_gpc 설정을 무의미하게 만들 수 있으므로 Sybase 사용자가 아니면 Off로 설정한다.

open_basedir

디렉토리

해당 옵션에 특정 디렉토리를 설정하면, 지정된 디렉토리 내에서만 파일접근 가능

safe_mode_exec_dir

디렉토리

해당 옵션을 사용하면 system(), exec(), passthru() 등 외부 명령어 실행 시 지정된 디렉토리에 존재하지 않는 프로그램은 실행할 수 없게 된다.

임의로 업로드한 공격도구나 wget, xterm 등 공격에 사용될 수 있는 명령어를 제한할 수 있다.

display_errors

Off

PHP 실행 중 에러 정보 노출을 방지하는 역할, 필수적이므로 Off 설정

log_errors

On

On으로 설정하면 PHP 실행 중 발생하는 경고나 에러 정보를 error_log에서 지정한 파일에 기록, 의도적인 에러 발생 시도를 확인해 볼 수 있다.

error_log

파일명

PHP 실행 중 발생하는 경고나 에러 정보를 작성할 파일을 지정

 

 

gd library 설치

#yum install gd gd-devel php-gd

#vi /usr/local/lib/php.ini

...

display_errors=On

...

extension=php_gd2.dll
...

extension=php_mbstring.dll
extension=php_exif.dll      ; Must be after mbstring as it depends on it
...

#service httpd restart

 

gd 설치여부 확인

<?
 $Arr_Gd= @gd_info();
 if(!$Arr_Gd["GD Version"])
  echo "gd설치안됨";
 else
  echo $Arr_Gd["GD Version"];
?>

 

웹상에서 PHP.INI의 설정내용 보기

 

문법:ini_get("php.ini항목명");

설명:환경설정의 값(phpinfo())에서 정보를 공백(off) 또는 1(on)로 얻어옵니다.

주의점:phpinfo()에서 configuration php core 부분의 정보만 가져올수있습니다.

 

<?php

echo 'register_globals = ' . ini_get('register_globals') . "\n";
echo 'post_max_size = ' . ini_get('post_max_size') . "\n";
echo 'post_max_size+1 = ' . (ini_get('post_max_size')+1) . "\n";

?>

 

웹상에서 PHP.INI의 설정내용 바꾸기

 

문법:ini_set("php.ini항목명","0 또는1");

설명:환경설정의 값을 공백(off) 또는 1(on)로 사용한 페이지에서만 임시로 수정합니다.

 

ex)

현재 버전에서는 제대로 되지 않습니다.

 

기타 PHP관련 정보 얻어오기

 

ex)

<?
echo "php버전은 : ".phpversion()."<br>";
echo "zend버전은 : ".zend_version()."<br>";
echo "apache버전은 : ".apache_get_version()."<br> ";

echo "php전체 설정내용은 : ".phpinfo()."<br>";
?>

 

 

Posted by iWithJoy
Linux/CentOS2012. 4. 10. 17:05

# vi /usr/local/lib/php.ini

 

1. engine - PHP가 아파치 모듈로 설치 되었을 경우 특정 디렉토리에서만 스크립트가 동작하게 합니다.
이것은 아파치 httpd.conf 파일에 아래 항목을 추가합니다.


php_admin_flag engine on(PHP3의 경우 php3_engine on)


2. short_open_tag - php tag 사용여부를 정합니다. XML과 같이 사용할 경우 이 부분은 on으로
해야 합니다.

3. asp_tags - ASP 태그의 사용 여부를 설정합니다.

4. y2k_compliance - y2k 문제에 해당하는 브라우저를 위한 설정입니다.

5. safe_mode - php를 안전 모드로 동작 하게끔 하는 설정입니다.

safe_mode_exec_dir 지시자의 해당 디렉토리에 존재하는 실행 파일이 아닌 경우 실행 되지 않습니다.
(root에 있는 파일만 참조하게 합니다.)

6. safe_mode_exec_dir - 실행 프로그램이 있는 디렉토리 명을 적어 줍니다.

"5번"참고

7. max_execution_time - 스크립트 실행 시간을 초단위로 설정합니다.

8. memory_limit - 스크립트 실행 때 메모리 사용을 설정합니다.

9. error_reporting - 에러 출력을 설정합니다.

에러의 종류

1 - 일반적인 에러 출력(Normal function errors)
2 - 일반적인 에러 출력(Normal warnings)
4 - 문법적인 에러 출력(Parser errors)
8 - 버그의 가능성이 있으며 무시할 수 있는 에러 출력(Notices)

10. display_errors - 에러 상황을 html 양식으로 보여줍니다.

11. log_errors - 여러 가지 에러를 로고 파일에 저장합니다.

12. track_errors - $php_errormsg에 마지막의 에러나 경고 메시지를 저장합니다.

13. warn_plus_overloading - 스크립트에서 문자열 결합사용 때 " . " 연산자를 사용하지만 만약
" + "를 사용했을 경우 경고 메시지 출력 여부를 설정합니다.

14. track_vars - GET, POST, COOKIE 등으로 전달된 변수 값을 각각의 $HTTP_GET_VARS , $HTTP_POST_VARS ,
$HTTP_COOKIE_VARS의 배열 변수로 자동 저장 여부를 설정합니다.

15. magic_quotes_gpc - GET , POST , COOKIE 등으로 전달된 데이터에 ‘ " / 등의 문자가 존재할 경우
자동으로 ()역슬래쉬를 붙일지 여부를 설정합니다. 이것은 각 문자를 스크립트와 구별
해서 인식시키기 위해 필요한 부분입니다.

16. magic_quotes_runtime - 외부 스크립트나 여타 소스로부터 돌아오는 데이터에 대해 ()역슬래쉬를 붙일지
여부를 설정합니다.

17. auto_prepend_file - INCLUDE와 비슷한 부분이고, 스크립트의 처음 부분에 포함될 파일명을 적어 줍니다.

18. auto_append_file - "17번"과 같으며 마지막 부분에 포함될 파일명을 적어 줍니다.

19. include_path - INCLUDE, REQUIRE 문의 파일 경로를 설정합니다.

20. doc_root - 서버의 루트 디렉토리를 설정합니다. 안전 모드로 동작할 경우 해당 디렉토리를 벗어나 다른
쪽으로 접근을 할 수 없습니다.

21. user_dir - 서버의 계정을 가진 일반 유저에 PHP 스크립트의 사용을 허가할 수 있습니다.

22. upload_tmp_dir - 파일이 업로드 될 디렉토리를 설정합니다. 기본적으로 /tmp 디렉토리로 업로드 됩니다.

23. upload_max_filesize - 업로드 할 수 있는 최대 파일 크기를 설정합니다.

24. SMTP - mail( ) 함수의 사용을 위해 현 서버의 DNS , IP를 적어줍니다.

25. sendmail_from - 보내는 메일 주소를 설정할 수 있습니다.

26. sendmail_path - sendmail 서버가 있는 위치를 적어 줍니다.

27. debugger.host - 디버거로 사용하는 호스트 명을 적어 줍니다.

28. debugger.port - 디버거로 사용하는 포트 번호를 적어 줍니다.

29. debugger.enabled - 디버거의 사용 여부를 설정 합니다.

30. session.save_handler - 세션과 해당 데이터를 저장하는 방식을 설정하는 부분입니다. 기본적으로 파일 방식
입니다. 세션 항목은 이 책에 사용되는 회원제 부분에서 사용됩니다.

31. session.save_path - 세션 전달 인수를 정의 하는 부분이며 디폴트인 파일 방식일 경우 해당 파일의 경로를
적어 줍니다.

32. session.name - 쿠키 이름으로 사용되어질 세션 이름을 설정합니다. 디폴트는 PHPSESSID입니다.

33. session.auto_start - 세션 요청 시에 자동 모듈 생성 여부를 설정합니다.

0 - off , 1 - on

34. session.lifetime - 해당 세션이 유지 되는 시간을 설정 합니다.
디폴트의 경우 0이며 사용자의 브라우저가 종료 될 때까지 유지됩니다.

35. session.gc_probability - 해당 세션 값이 제거 될 경우 낭비 되는 시스템 메모리 자원을 반납하는 시점을
설정합니다.

36. session.gc_maxlifetime - 해당 세션의 시스템 메모리 자원 반납을 가질 수 있는 시간을 설정합니다.

http://www.ihelpers.co.kr

출처
http://www.phpschool.com/bbs2/inc_view.html?id=1322&code=tnt2&start=0&mode=search&field=title&search_name=&operator=and&period=all&category_id=&s_que=php.ini

추가 참고: http://blog.naver.com/autovan74?Redirect=Log&logNo=100021168844

 

수정 후에는 php.ini의 속성을 확인하여 755인지 확인하고, 아니면,

# chmod 755 php.ini

를 수행하여 속성변경하고,

# service httpd restart

를 수행하여 Apache를 재시작한다.

 

PHP 5.4.0 부터 일부 밀접한 옵션 및 함수들이 삭제되었습니다. 

PHP 5.3 버전때부터 예고되었다고는 하는데.. 막상 갑자기 에러메세지를 내뿜으니 좀 당황스럽더군요.

 

일단 변경 사항 가운데 저한테 와 닿는 항목 위주로 적어 보았습니다.

아래 내용은 압축파일의 news.txt 에도 들어 있습니다.

 

<PHP 5.4.0 변경 사항 중 일부>

 

 * php.ini

  - Safe mode와 관련 항목 삭제 

  - register_globals, register_long_arrays 항목 삭제

  - short_open_tags 와 관계없이 무조건 <? 태그 지원

  - default_charset 의 기본값이 utf-8 로 변경됨

 

 * php 함수

  - 세션 함수 session_is_registered(), session_register(), session_unregister() 삭제

 

 * 구문

  - 2진수 0b001010 형식 지원 

자세한 사항은 다음을 참고: http://www.php.net/manual/en/ini.sect.safe-mode.php

 

 

Posted by iWithJoy
Linux/CentOS2012. 4. 9. 19:17

yum -y install gcc cpp gcc-c++ compat-gcc-34-g77 flex openssl*
yum -y install libjpeg-devel libpng-devel freetype-devel gd-devel libtermcap-devel ncurses-devel libxml2-devel libc-client-devel bzip2-devel
#yum -y install libtermcap-devel [MYSQL컴파일에_적용]
#yum -y install ncurses-devel
#yum -y install libxml2-devel [PHP컴파일에_적용]
#yum -y install openssl*
#yum -y install libc-client-devel
#yum -y install bzip2-devel
rpm -qa gcc* cpp* compat-gcc* flex* openssl*
rpm -qa libjpeg* libpng* freetype* gd-*

reboot [패키지_변경시_리부팅_필요]

cd /usr/local/src
wget ftp://ftp.neowiz.com/pub/mysql/Downloads/MySQL-5.0/mysql-5.0.67.tar.gz
tar xvzf mysql-5.0.67.tar.gz
wget ftp://ftp.neowiz.com/pub/apache/httpd/httpd-2.2.10.tar.gz
tar xvzf httpd-2.2.10.tar.gz
wget ftp://ftp.neowiz.com/pub/languages/php/php-5.2.6.tar.gz
tar xvzf php-5.2.6.tar.gz
useradd -M -s /bin/false mysql
cd /usr/local/src/mysql-5.0.67
./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-extra-charsets=all
make && make install
ll /usr/local/mysql
/usr/local/mysql/bin/mysql_install_db --user=mysql
chown -R root.mysql /usr/local/mysql
chown -R mysql /usr/local/mysql/var
vi /etc/skel/.bash_profile
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin
vi ~/.bash_profile
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin
source ~/.bash_profile
cp /usr/local/mysql/share/mysql/my-huge.cnf /etc/my.cnf
cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --list mysqld
service mysqld start

cd /usr/local/src/httpd-2.2.10
vi /usr/local/src/httpd-2.2.10/server/mpm/prefork/prefork.c
# define DEFAULT_SERVER_LIMIT 2048
vi /usr/local/src/httpd-2.2.10/server/mpm/worker/worker.c
# define DEFAULT_SERVER_LIMIT 512
# define DEFAULT_THREAD_LIMIT 2048
./configure --prefix=/usr/local/apache --enable-mods-shared=all --enable-so --enable-ssl --enable-modules=ssl --enable-rewrite --with-mpm=prefork

make && make install
cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
vi /etc/init.d/httpd
# chkconfig: 2345 90 90
# description: init file for Apache server daemon
# processname: /usr/local/apache/bin/apachectl
# config: /usr/local/apache/conf/httpd.conf
# pidfile: /usr/local/apache/logs/httpd.pid
chkconfig --add httpd
chkconfig --list httpd
service httpd start

cd /usr/local/src/php-5.2.6

./configure --with-config-file-path=/etc --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --disable-debug --enable-safe-mode --enable-sockets --enable-sysvsem=yes --enable-sysvshm=yes --enable-ftp --enable-gd-native-ttf --enable-inline-optimization --enable-bcmath --with-zlib --with-jpeg-dir --with-png-dir --with-freetype-dir --with-libxml-dir --enable-exif --with-gd --with-ttf --with-gettext --enable-sigchild --enable-mbstring --with-openssl --with-imap --with-imap-ssl --with-kerberos

./configure \
--with-config-file-path=/etc \
--prefix=/usr/local/php \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--disable-debug \
--enable-safe-mode \
--enable-sockets \
--enable-sysvsem=yes \
--enable-sysvshm=yes \
--enable-ftp \
--enable-gd-native-ttf \
--enable-inline-optimization \
--enable-bcmath \
--with-zlib \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-libxml-dir \
--enable-exif \
--with-gd \
--with-ttf \
--with-gettext \
--enable-sigchild \
--enable-mbstring \
--with-openssl \
--with-imap \
--with-imap-ssl \
--with-kerberos

make && make install
cp /usr/local/src/php-5.2.6/php.ini-dist /etc/php.ini
vi /usr/local/apache/conf/httpd.conf
User apache
Group apache

ServerName www.hompy.info:80
DocumentRoot "/usr/local/apache/htdocs"

LoadModule ssl_module modules/mod_ssl.so

<IfModule dir_module>
     DirectoryIndex index.html index.htm index.php
</IfModule>

<IfModule mime_module>
     AddType application/x-httpd-php .php .html
     AddType application/x-httpd-php-source .phps
</IfModule>

Include conf/extra/httpd-mpm.conf
Include conf/extra/httpd-vhosts.conf
Include conf/extra/httpd-default.conf
Include conf/extra/httpd-ssl.conf

service httpd restart
rm /usr/local/apache/htdocs/index.html
echo '<?php phpinfo() ?>' > /usr/local/apache/htdocs/index.php

cd /usr/local/src
tar xvzf ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
cd ZendOptimizer-3.3.3-linux-glibc23-i386
./install.sh
# rm /etc/php.ini
# ln -s /usr/local/Zend/etc/php.ini /etc/php.ini

/usr/local/php/bin/pear upgrade-all
/usr/local/php/bin/pear install DB File Mail Mail_Mime
/usr/local/php/bin/pear install MDB2 MDB2_Driver_mysql MDB2_Driver_mysqli
/usr/local/php/bin/pear install HTTP_Request XML_RPC

vi /etc/skel/.bash_profile
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/php/bin
vi ~/.bash_profile
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/php/bin
source ~/.bash_profile

/usr/local/apache/conf/httpd.conf
#Include conf/extra/httpd-ssl.conf

mkdir /usr/local/apache/conf/ssl
cat > /usr/local/apache/conf/ssl/auto.sh
#!/bin/sh
echo "password"
^D
chmod 700 /usr/local/apache/conf/ssl/auto.sh

vi /usr/local/apache/conf/extra/httpd-ssl.conf

#SSLPassPhraseDialog  builtin
SSLPassPhraseDialog  exec:/usr/local/apache/conf/ssl/auto.sh

DocumentRoot "/usr/local/apache/htdocs"
ServerName www.hompy.info:443
ServerAdmin you@hompy.info

SSLCertificateFile /usr/local/apache/conf/ssl/server.crt

SSLCertificateKeyFile /usr/local/apache/conf/ssl/server.key

SSLCertificateChainFile /usr/local/apache/conf/ssl/server-ca.crt

service httpd restart

 

 

그래서 우리의 전문분야는 아니지만 비교적 무난하게 소스 컴파일로 웹 서버와 데이타베이스 서버를 설치하는 데 참고가 될만한 동영상을 준비했습니다. 나름대로의 설치 시나리오를 가지고 진행 과정을 동영상으로 담은 것입니다. 리눅스 배포판 CentOS 5.2 가 설치된 컴퓨터에 Apache, PHP, MySQL 시리즈 APM과 Zend 설치 그리고 요즘 개인정보 보호를 위해 한국정보보호진흥원에서 설치하도록 명시하고 있는 보안서버 적용을 위한 OpenSSL 모듈을 설치하고 셋팅하는 장면입니다.

여러가지 가능성이 고려되지 않은 동영상이므로 관련 기술 문서도 함께 참고하세요.
Apache,PHP,MySQL,Zend,OpenSSL 설치 동영상  - http://hompy.info/527

'Linux > CentOS' 카테고리의 다른 글

php 5.4.0에서 5.3.10으로 다운그레이드  (0) 2012.04.10
php.ini 설정법  (0) 2012.04.10
Gmail for CentOS  (0) 2012.04.03
DNS 설정  (0) 2012.03.30
CentOS에서 rpm 데이터베이스 문제로 yum을 사용할 수 없을때  (0) 2012.03.09
Posted by iWithJoy
Linux/CentOS2012. 4. 3. 00:21

Gmail for CentOS (http://www.jopenbusiness.com/mediawiki/index.php/CentOS)

CentOS 5.5 버전에서 sendmail을 사용하여 Gmail을 연동하여 보자.

  • sendmail 설치
yum install openssl sendmail sendmail-cf
yum install cyrus-sasl cyrus-sasl-plain
  • sendmail이 TLS 또는 SSL을 지원하는지 확인 한다.
#--- STARTTLS와 SASLv2가 있는지 확인
sendmail -d0.1 -bv root
  • SASL 2.1.21 이상을 지원하는지 확인 한다.
yum list | grep sasl
  • OpenSSL을 사용하여 sendmail에서 사용할 개인키와 공개키를 생성를 생성 한다.
  • sendmail 인증 정보를 생성 한다.
cd /etc/mail
mkdir auth
cd auth
vi /etc/mail/auth/authinfo
    AuthInfo:smtp.gmail.com "U:root" "I:[Gmail아이디]@gmail.com" "P:[Gmail비밀번호]"
    ### AuthInfo:smtp.gmail.com "U:root" "I:[Gmail아이디]@gmail.com" "P:[Gmail비밀번호]" "M:PLAIN"
    ### AuthInfo:smtp.gmail.com:587 "U:root" "I:[Gmail아이디]@gmail.com" "P:[Gmail비밀번호]" "M:PLAIN"

#---인증 파일의 hashdb(authinfo.db)를 생성 한다.
makemap hash authinfo < authinfo

#--- 인증파일경로의 퍼미션을 설정 한다.
chmod 700 /etc/mail/auth
chmod 600 /etc/mail/auth/*
  • vi /etc/mail/sendmail.mc
include('/etc/mail/sasl/sasl.m4')dnl            #--- Ubuntu Server에서만 추가
FEATURE(authinfo,hash /etc/mail/auth/authinfo)dnl
define('SMART_HOST','smtp.gmail.com')dnl
define('RELAY_MAILER_ARGS', 'TCP $h 587')dnl
define('ESMTP_MAILER_ARGS', 'TCP $h 587')dnl
define('confCACERT_PATH', '/etc/mail/certs')dnl
define('confCACERT', '/etc/mail/certs/CAcert.pem')dnl
define('confSERVER_CERT', '/etc/mail/certs/mycert.pem')dnl
define('confSERVER_KEY', '/etc/mail/certs/mykey.pem')dnl
define('confCLIENT_CERT', '/etc/mail/certs/mycert.pem')dnl
define('confCLIENT_KEY', '/etc/mail/certs/mykey.pem')dnl
define('confAUTH_MECHANISMS', 'EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
TRUST_AUTH_MECH('EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')
define('confAUTH_OPTIONS', 'A')dnl
#--- 아래 라인 위에 추가 한다.
MAILER(smtp)dnl
  • sendmail.cf 생성
  • CentOS
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
service sendmail restart
  • Ubuntu Server
cd /etc/mail
make

#--- 필요한 경우 sendmail의 설정을 재 생성 한다. 
sendmailconfig

/etc/init.d/sendmail start
  • 최종 확인
echo '/map authinfo AuthInfo:smtp.gmail.com' | /usr/sbin/sendmail -bt
echo "this is a test" | sendmail -s ghkim@daou.co.kr
#--- ghkim@daou.co.kr 메일함에서 메일을 확인 한다.
  • 방화벽에서 587, 465 port를 개방 한다.
system-config-securitylevel
  • 기타 sendmail 설정
  • Access 설정
makemap hash /etc/mail/access.db < /etc/mail/access
  • Mail host 설정
vi /etc/mail/local-host-names
  • showinfo_sendmail.bash
#!/bin/bash
echo 'sendmail 버전  : sendmail 8.13.8'
echo '환경 파일      : vi /etc/mail/sendmail.mc'
echo '기동 종료      : service sendmail restart'
echo '서비스 확인    : ps -ef | grep sendmail | grep -v grep'
  • php.ini 설정
sendmail_path = /usr/sbin/sendmail -t

서비스 업체별 POP3, SMTP 주소

  • gmail.com (환경설정 - 전달 및 POP/IMAP - POP 다운로드 항목에서 사용설정을 해야 이용 가능)
  • IMAP: imap.gmail.com (SSL 사용, 포트: 993)
  • POP3: pop.gmail.com (SSL 사용, 포트: 995)
  • SMTP: smtp.gmail.com (SSL 사용, 포트: 465)
  • hanmail.net
  • POP3: pop.hanmail.net (SSL 사용, 포트: 995)
  • SMTP: smtp.hanmail.net (SSL 사용, 포트: 465)
  • nate.com
  • POP3: nate.com (포트: 110)
  • SMTP: 지원 안함 (다른 업체의 SMTP를 이용하는 수 밖에 없음)
  • naver.com (으뜸사용자만 이용 가능)
  • POP3: pop.naver.com (포트: 110)
  • SMTP: smtp.naver.com (포트: 25)
  • yahoo.co.kr
  • POP3: pop.mail.yahoo.co.kr (SSL 사용, 포트: 995)
  • SMTP: smtp.mail.yahoo.co.kr (SSL 사용, 포트: 465, 인증 사용)
  • yahoo.com
  • POP3: pop.mail.yahoo.com (SSL 사용, 포트: 995)
  • SMTP: smtp.mail.yahoo.com (SSL 사용, 포트: 465, 인증 사용)

참고 문헌

  • Ubuntu Server
  • CentOS

Outlook 설정

  • Microsoft Outlook를 실행하여 "도구 -> 계정 설정 -> 새로 만들기" 메뉴를 선택 합니다.
  • "Microsoft Exchange, POP3, IMAP 또는 HTTP"을 선택 합니다.

그림:GoogleOutlook001.png

  • "수동으로 서버 설정 또는 추가 서버 유형 구성"을 선택 합니다.

그림:GoogleOutlook002.png

  • "인터넷 전자 메일"을 선택 합니다.

그림:GoogleOutlook003.png

  • 필요한 정보를 입력하고 "기타 설정" 버튼을 선택 합니다.
  • 사용자 이름 : 사용자 이름
  • 전자 메일 주소 : 이메일 주소
  • 계정 유형 : IMAP
  • 받는 메일 서버 : imap.gmail.com
  • 보내는 메일 서버 : smtp.gmail.com
  • 사용자 이름 : 이메일 주소
  • 암호 : 비밀번호
  • 암호 저장 체크

그림:GoogleOutlook004.png

  • "고급" 탭을 선택하여 아래와 같이 설정 합니다.
  • 받는 메일 서버 : 993
  • 암호화된 다음 연결 방식 사용 : SSL
  • 보내는 메일 서버 : 25
  • 암호화된 다음 연결 방식 사용 : TLS

그림:GoogleOutlook005.png

  • "보내는 메일 서버" 탭을 선택하여 아래와 같이 설정 합니다.
  • "보내는 메일 서버 인증 필요" 체크
  • "받는 메일 서버와 동일한 설정 사용" 선택

그림:GoogleOutlook006.png

 

 

CentOS sendmail 메일 서버 설치, 설정 (http://blog.leadus.co.kr/119)

1) 메일 서버 설치 여부를 확인한다.

[root@localhost ~]# yum list |grep sendmail
sendmail.x86_64                       8.13.8-8.el5              installed
sendmail-cf.x86_64                    8.13.8-8.el5              installed
sendmail-devel.x86_64                 8.13.8-8.el5              installed

2) dovecot 설치한다.

[root@localhost ~]# yum list |grep dovecot
dovecot.x86_64                        1.0.7-7.el5               base
[root@localhost ~]# yum install dovecot.x86_64

dovecot의 개요
RHEL 4부터 사용되는 imap, pop3 서비스 제공 프로그램으로 기존의 imap
패키지에 비해 TLS/SSL을 지원하여 보안이 강화되었다. 또한 기존에는 imap, pop3
서비스가 inetd(xinetd)에 의해 작동하였지만, dovecot는 단독 데몬으로 작동한다.
참고로 관련정보는 http://www.dovecot.org(새 창으로 열기)에서 확인할 수 있다.

3) sendmail.mc 파일을 수정한다.
vi /etc/mail/sendmail.mc

아래의 부분을 확인한다. 주석처리되어 있으면 제거한다.
TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl

아래의 부분은 주석처리한다.
DAEMON_OPTIONS(`Port=smtp,Addr=112.169.173.161, Name=MTA')dnl
==> dnl DAEMON_OPTIONS(`Port=smtp,Addr=112.169.173.161, Name=MTA')dnl

4) sendmail.mc 적용
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

변경후 결과
-rw-r--r-- 1 root root 58368  6월 13 22:33 sendmail.cf
==> -rw-r--r-- 1 root root 58338  8월 31 16:33 sendmail.cf

5) 최종수신지 도메인 설정  
vi /etc/mail/local-host-names
leadus.co.kr  RELAY

test :
linkus.kr  RELAY

*** 스팸방지
Spam 방지 ( /etc/mail/access )
  linkus.kr  RELAY
 
  makemap hash /etc/mail/virtualusertable.db < /etc/mail/access  <- access 적용 access.db 파일 생성
  또는 /etc/mail 디렉토리에서 간단히 make

가상 메일 ( /etc/mail/virtualusertable )
  webmaster@linkus.kr root
   webmaster@linkus.kr 으로 오는 메일은 root 라는 실제계정이 받게 함

  makemap hash /etc/mail/virtualusertable.db < /etc/mail/virtualusertable
  또는 /etc/mail 디렉토리에서 간단히 make


6) Dovecot 설정
vi /etc/dovecot.conf
  protocols = pop3 <- imap 제외 pop3 만 사용
  listen = *  <- ipv6 사용 안 하고 ipv4 만 사용 ==> php3_listen = * 버전업되면서 바뀌었다.

7) 서비스 시작
 /etc/init.d/sendmail start
 /etc/init.d/saslauthd start <- smtp 인증을 위해 필요
 /etc/init.d/dovecot start

 

Posted by iWithJoy