Apache SSL 인증서 설치 / 적용 가이드

원문 : https://www.securesign.kr/guides/Apache-SSL-Certificate-Install

사전 구성 환경

  • OpenSSL 라이브러리 http://www.openssl.org/ : openssl 1.0.1 이상 권장
  • Apache w/mod_ssl http://www.modssl.org/ : http.conf 에서 mod_ssl 모듈 활성화 (LoadModule ssl_module modules/mod_ssl.so)
  • TLS / SHA-2(sha256) 암호화 지원 모듈 구성/활성 확인 필수
  • MD5, RC4 등 국제 보안 기구에서 해제를 권장하는 취약한 암호화 모듈 비활성화
  • SSL 2.0, 3.0 및 TLS 1.0 1.1 프로토콜 접속 허용 해제. 최신 TLS 1.2 1.3 설정 권장

진행 과정

  1. 개인키(Private Key) 생성
  2. CSR(Certificate Signing Request) 생성
  3. 인증서 발급 신청 제출
  4. 인증서 발급 완료 (발급내역서/파일설명서 PDF 참조)
  5. 인증서 설치 적용 – 신규,갱신,재발급,도메인추가
  6. 서버 정상 적용 완료 테스트
  7. 웹페이지에 https:// 링크 적용

개인키(Private Key) 생성


– SSL 인증서 발급 신청서 작성시, CSR 입력 단계에서 온라인 “CSR 자동생성” 이용을 권장합니다. (현재 과정 필요 없음)
– CSR 자동생성 발급 완료시, “개인키, 서버인증서, 체인인증서, 루트인증서” PEM 파일이 모두 포함되어 있습니다.
– 추가 포함된 “pfx / jks” 패키지에는, “개인키+서버인증서+체인인증서+루트인증서” 가 모두 통합되어 있습니다.
openssl genrsa -des3 -out private.key 2048
  • -des3 : 개인키 암호화 수준 DES3 (Windows Apache 환경은 해당 옵션 제외)
  • -out private.key : 개인키를 저장할 파일명 지정. 개인키 파일은 분실하지 않도록 잘 보관해야 합니다.
  • 2048 : bit

Result


Loading ‘screen’ into random state – done
Generating RSA private key, 2048 bit long modulus
……………………..+++
……………………………………………..
…………………+++
e is 65537 (0x10001)
Enter pass phrase for pri.kery: (개인키 파일 암호 입력)
Verifying – Enter pass phrase for pri.kery: (개인키 파일 암호 입력)

CSR(Certificate Signing Request) 생성 예


– SSL 인증서 발급 신청서 작성시, CSR 입력 단계에서 온라인 “CSR 자동생성” 이용을 권장합니다. (현재 과정 필요 없음)
– CSR 자동생성 발급 완료시, “개인키, 서버인증서, 체인인증서, 루트인증서” PEM 파일이 모두 포함되어 있습니다.
– 추가 포함된 “pfx / jks” 패키지에는, “개인키+서버인증서+체인인증서+루트인증서” 가 모두 통합되어 있습니다.
openssl req -new -key private.key -out out.csr -config “../share/openssl.cnf”


또는
openssl req -new -key private.key -out out.csr -subj “/C=KR/ST=Seoul/L=Gang-nam/O=SecureSign.KR/OU=Dev Team/CN=example.com”
  • -key private.key : 앞서 생성한 개인키 파일 지정
  • -outout.csr : 생성될 CSR 파일명 지정
  • -config “../share/openssl.cnf” : cnf 위치를 확인하지 못하는 경우 cnf 파일 경로 지정
  • -subj : CSR 생성시 입력이 필요한 정보 지정
    • C : ISO 국가 코드 KR, US, CN, JP (대문자)
    • ST : 시,도
    • L : 구,군
    • O : 기관명, 회사명
    • OU : 조직명
    • CN : 도메인명, 일반이름. IP 주소는 CN 으로 사용할수 없습니다.
    • 위 항목은 모두 영문입력을 해야 합니다. 특수문자를 사용하면 안됩니다.

  • (예제에 사용된 옵션 값 등은 예제용이므로, 실제 해당 도메인 정보로 지정하시기 바랍니다)

Single

CN : sub.example.com 처럼 FQDN 도메인 형식 이어야 합니다.

Wildcard

CN : *.example.com 과 같은 패턴 이어야 합니다.

MultiDomain

CN : example.com 대표성을 가진 FQDN 도메인 1개만 입력 합니다.
SAN : 인증서에 포함될 나머지 FQDN 도메인은, 신청서 작성중 DCV 설정 단계에서 추가 입력합니다.

Multi-Wildcard

CN : example.com 대표 루트 도메인 1개을 CN으로 입력 합니다.
SAN : *.example.com 형식의 와일드카드 도메인은, 신청서 작성중 DCV 설정 단계에서 추가 입력합니다.

Result


Enter pass phrase for pri.kery: (개인키 패스워드 입력)
Loading ‘screen’ into random state – done
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter ‘.’, the field will be left blank.
—–
Country Name (2 letter code) [AU]:KR (국가코드 C)
State or Province Name (full name) [Some-State]:Seoul (시,도 ST)
Locality Name (eg, city) []:Gang-nam (구,군 L)
Organization Name (eg, company) [Internet Widgits Pty Ltd]:SecureSign.KR (기관명 O)
Organizational Unit Name (eg, section) []:Dev Team (조직명 OU)
Common Name (eg, YOUR name) []:example.com (도메인명 CN)
Email Address []:webmaster@example.com (이메일)

Please enter the following ‘extra’ attributes
to be sent with your certificate request
A challenge password []: enter (설정 X)
An optional company name []: enter (설정 X)

생성된 CSR 예제


– SSL 인증서 발급 신청서 작성시, CSR 입력 단계에서 온라인 “CSR 자동생성” 이용을 권장합니다. (현재 과정 필요 없음)
– CSR 자동생성 발급 완료시, “개인키, 서버인증서, 체인인증서, 루트인증서” PEM 파일이 모두 포함되어 있습니다.
– 추가 포함된 “pfx / jks” 패키지에는, “개인키+서버인증서+체인인증서+루트인증서” 가 모두 통합되어 있습니다.
-----BEGIN CERTIFICATE REQUEST-----
MIIC5TCCAc0CAQAwgZ8xCzAJBgNVBAYTAktSMQ4wDAYDVQQIEwVTZW91bDERMA8G
A1UEBxMIR2FuZy1uYW0xGDAWBgNVBAoTD1NlY3VyZUxheWVyIEluYzERMA8GA1UE
-- 중략 --
wxd+87gwsvAC2dyK8I4N1ttXDRJcDPCDe1BGqWvYYAZN7FbvnbHCM7y/SN++pxbS
jbnkoe8uStQvfCo6DW5MZHUli5+lRU/UpA==
-----END CERTIFICATE REQUEST-----

앞서 생성한 CSR 파일은 Base64 포맷의 PEM Text 이며, 텍스트 편집기를 이용하여 파일을 오픈합니다. -----BEGIN ~ REQUEST----- 까지 포함하여 내용 전체를 복사하여 신청서에 입력합니다. (—– 를 누락하거나, 새로운 빈출이 추가되지 않도록 주의하세요)

인증서 발급 완료 및 참고 사항

– 발급 완료 후에는, 메일첨부 또는 주문상세의 압축파일(zip)에 인증서 파일이 포함되어 있습니다.
– 서버 적용에 필요한 파일들에 대해서, 발급 내역서 PDF 및 루트/체인 설명 PDF를 통해서 미리 숙지해야 합니다.
– 이후 과정 부터는, 서버에 SSL 인증서 설치/적용/확인 절차 입니다. (인터넷에 공개된 설정법과 차이 없음)

– 서버이름표시(SNI) 지원되는 서버의 경우, SSL 인증서 마다 각 포트 구분없이 모두 443 포트 적용가능합니다.
– SNI 설정으로 하는 경우, 클라이언트에서 SNI 미지원 하는 경우 접속 호환성 문제가 있으므로 미리 검토해야 합니다.

VirtualHost 적용 예제 (서버 인증서 발급 받은 후)

<VirtualHost *:443>

ServerName “아래 지정한 서버 인증서에 포함된 DNS Name 중에 있어야 함 ”
SSLEngine on
SSLProtocol all -SSLv2 -SSLv3 또는 TLSv1 TLSv1.1 TLSv1.2 (서버 환경에 따라서 선택적 적용)
SSLCertificateKeyFile /인증서파일경로/개인키 ex. domain_xxxxx.key.pem
SSLCertificateFile /인증서파일경로/서버인증서 ex. domain_xxxxx.crt.pem
SSLCertificateChainFile /인증서파일경로/체인인증서ex. chain-bundle.pem
SSLCACertificateFile /인증서파일경로/루트인증서 ex. AAACertificateServicesRoot.crt.pem

</VirtualHost>

* 루트/체인 인증서는 상품별로 차이가 있으므로, 발급 완료시 첨부된 파일 내역에서 확인 가능합니다.
* chain-bundle.pem 은 체인인증서가 여러개인 경우 1개 파일로 통합한 PEM Text 파일입니다.
* CSR 자동 생성 이용시, 개인키에는 패스워드가 지정되지 않습니다. (별도 지정 필요시 변환 매뉴얼 참조)
* 예제에 포함되어 있지 않은 나머지 Property 는 공식 매뉴얼 또는 현재 서버 설정값을 사용하시기 바랍니다. (/conf/extra/httpd-ssl.conf 참조)

VirtualHost 적용 예제 – Apache 2.4.8 + (서버 인증서 발급 받은 후)

<VirtualHost *:443>

ServerName “아래 지정한 서버 인증서에 포함된 DNS Name 중에 있어야 함 ”
SSLEngine on
SSLProtocol all -SSLv2 -SSLv3 또는 TLSv1 TLSv1.1 TLSv1.2 (서버 환경에 따라서 선택적 적용)
SSLCertificateKeyFile /인증서파일경로/개인키 ex. domain_xxxxx.key.pem
SSLCertificateFile /인증서파일경로/서버+체인 PEM 통합된 파일 ex. domain_unified.pem
SSLCACertificateFile /인증서파일경로/루트인증서 ex. AAACertificateServicesRoot.crt.pem

</VirtualHost>

* 루트/체인 인증서는 상품별로 차이가 있으므로, 발급 완료시 첨부된 파일 내역에서 확인 가능합니다.
* 통합 pem 파일 생성 : cat domain_xxxxx.crt.pem chain-bundle.pem > unified.domain.pem (cat, type 명령어 사용)
* 통합된 domain_unified.pem 파일을 Text 편집기로 열어서, PEM 내용간 구분되어 있는지 꼭 확인해야 합니다.
* CSR 자동 생성 이용시, 개인키에는 패스워드가 지정되지 않습니다. (별도 지정 필요시 변환 매뉴얼 참조)
* 예제에 포함되어 있지 않은 나머지 Property 는 공식 매뉴얼 또는 현재 서버 설정값을 사용하시기 바랍니다. (/conf/extra/httpd-ssl.conf 참조)

설치 적용 확인 및 변환

* 서버에 SSL 설정 적용 후, 웹서버를 재시작하여 시작시 오류 또는 경고가 있는지 콘솔/데몬 로그를 필히 확인해야 합니다. (필수 확인 사항)
* SSL 발급 도메인 웹페이지에 https:// 링크 적용을 별도 진행해야 최종적으로 SSL 암호화가 적용됩니다. (개발자,웹디자이너)
* PC 및 스마트폰의 “Chrome / Firefox / IE / Edge” 각 웹브라우져에서 “루트,체인,SSL,TLS” 경고가 발생 하는지 확인해야 합니다.

SSL 설치/적용 트러블슈팅
SSL 설치 적용 확인 하기
체인인증서 적용 확인 방법
인증서 포맷 변환 방법
TrustLogo 적용 방법

Plex Media Server – Cache Folder 이동

The Plex Media Server cache resides in %USERPROFILE%\Local Settings\Application Data\Plex Media Server
NOTE: For XP – C:\Documents and Settings\USERNAME\Local Settings\Application Data\Plex Media Server

If your drive is running out of space you can move it to another location by:

  • Close Plex Media Server from the System Tray
  • Use Robocopy to copy the cache folder to a new location e.g. D:\Plex Media Server

    Execute – Robocopy.exe “C:\Documents and Settings\USERNAME\Local Settings\Application Data\Plex Media Server” “D:\Plex Media Server” /E

    NOTE1: Windows Explorer is unable to copy some files (com.plexapp.agents.thetvdb_4ccc065777fa44d06bbc4542ac5544325fc53bbf)
    NOTE2: If using XP – Robocopy is part of the Windows Server 2003 Resource Kit Tools available here – http://www.microsoft.com/en-au/download/confirmation.aspx?id=17657 18

  • Rename the “C:\Documents and Settings\USERNAME\Local Settings\Application Data\Plex Media Server” folder to “Plex Media Server_OLD”
  • Open Regedit.exe, browse to HKEY_CURRENT_USER -> Software -> Plex, Inc. -> Plex Media Server and create a String Value called “LocalAppDataPath”. Set its value to D:<br>
    NOTE3: On Win 7 – You could instead use the mklink comand to create a link from C:\Users\USERNAME\Local Settings\Application Data\Plex Media Server to D:\Plex Media Server
  • Restart Plex and ensure it’s working
  • Delete the renamed Plex Media Server_OLD folder

    Open cmd.exe and Execute – Rmdir /S “C:\Documents and Settings\USERNAME\Local Settings\Application Data\Plex Media Server_OLD”

    NOTE4: Windows Explorer is unable to delete some files (Refer to NOTE1)

리눅스 파일 검색/찾기, 파일 내부 문자열 찾기/검색

# 리눅스 파일명으로 검색하는법.

사용법

find [찾을위치] -name [파일명]

예) 최상위 폴더부터 하위로 ‘apache’로 시작하는 파일 찾기.

find / -name ‘apache*’

예) usr 폴더부터 하위로 ‘apa’로 시작하는 파일 찾기.

find /usr/ -name ‘apa*’

 

# 리눅스 파일 내부 문자열 검색하는법.

grep 을 이럴때 유용하게 쓸 수 있습니다.

사용법

grep -r [찾을 문자열] [대상파일들]

예) 현재 폴더에 있는 test.log 파일내부에 ‘apache’ 라는 문자열 찾기.

grep -r ‘apache’ ./test.log

예) ‘var’ 폴더부터 하위 모든 파일내부에서 ‘apache’ 라는 문자열 찾기.

grep -r ‘apache’ /var/* [–include ‘*.conf’] (include 옵션으로 특정 확장자에서만 검색도 가능하다)

 

# 파일 내부 문자열 검색 다른 방법 (Feat. 강조색)

find . -type f -print | xargs grep -i “phpMyAdmin” /dev/null

현재위치부터 하위폴더의 모든 파일중에서 ‘phpMyAdmin’ 이라는 문자열을 검색한다.

find . -name ‘*.conf’ | xargs grep -r –color=auto -n 2>dev/null ‘phpMyAdmin’

현재 부터 하위 모두를 검색하되,

conf 라는 확장자를 가진 파일중에서 ‘phpMyAdmin’ 이라는 문자열을 검색한다.

그리고 일치 문자열은 강조색으로 표시!

How do I enable core dumps for everybody (모든 사용자 계정에 core dump 파일 활성화 하기)

Overview

In most Linux Distributions core file creation is disabled by default for a normal user. However, it can be necessary to enable this feature for an application (e.g. Oracle). For example, if you encounter an ORA-7445 error in Oracle, then it must be possible to write a core file for the user«oracle».

To enable writing core files you use the ulimit command, it controls the resources available to a process started by the shell, on systems that allow such control.

If you try to enable writing core files, usually you run in the following problem. Normally SSH is used to logon to the server.

ssh oracle@ora-server
$ ulimit -a

core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
pending signals                 (-i) 1024
max locked memory       (kbytes, -l) 32
max memory size         (kbytes, -m) unlimited
open files                      (-n) 65536
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 16384
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

Nowtry (not as user root) to change the core file size to unlimited

ulimit -c unlimited
-bash: ulimit: core file size: cannot modify limit: Operation not permitted

Solution

  1. Check Environment for ulimit

    The first step is to check, that you don’t set ulimit -c 0 in any shell configuration files for this user, for example in $HOME/.bash_profile or $HOME/.bashrc. Uncomment it if you have such an entry.

    #
    # Do not produce core dumps
    #
    # ulimit -c 0
     

  2. Globally enable Core Dumps

    This must be done as user root, usually in /etc/security/limits.conf

    # /etc/security/limits.conf
    #
    #
     Each line describes a limit for a user in the form:
    #
    #
     <domain> <type> <item> <value>
    #

    *  soft  core  unlimited

     

  3. Logoff and Logon again and set ulimit

    ssh oracle@ora-server
    $ ulimit -c
    0

    Try to set the limit as user root first

    su –
    ulimit -c unlimited

    ulimit -c
    unlimited

    Now you can set ulimit also for user oracle

    su – oracle
    ulimit -c unlimited
    ulimit -c
    unlimited

Perhaps the last step number 3 is not necessary, but we have figured out, that this is the way which always work. The core file size limitation is usually also set in different configuration files. If you want to enable cores, you can uncomment them.

In /etc/profile (Redhat)

# No core files by default
# ulimit -S -c 0 > /dev/null 2>&1

In /etc/init.d/functions (Redhat)

# make sure it doesn’t core dump anywhere unless requested
# ulimit -S -c ${DAEMON_COREFILE_LIMIT:-0} >/dev/null 2>&1

Now, from this current shell you can generate the core, so check ulimit before.

$ ulimit -a

core file size          (blocks, -c) unlimited
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
pending signals                 (-i) 1024
max locked memory       (kbytes, -l) 32
max memory size         (kbytes, -m) unlimited
open files                      (-n) 65536
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 16384
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

GIT – 다중 원격저장소 (remote repository) 사용 방법

svn 은 하나의 repository 만 설정할 수 있지만,
git 은 여러개의 repository 를 설정할 수 있다.

[#M_ more.. | less.. | git remote add secondremote alt-machine:/path/to/repo_M#]

 

remote 가 http/https 일경우 다음과 같이 설정하면 된다.

 

[#M_ more.. | less.. | git remote add secondremote https://remote-git.example.com/project/myproj.git _M#]


인증이 필요할 경우 매번 id 와 암호를 입력해야 하므로 id 정도는 url 에 같이 포함시키는 것이 편리하다. id와 @ 를 도메인 앞에 붙여 주면 된다.

 

[#M_ more.. | less.. | git remote add secondremote https://lesstif@remote-git.example.com/project/myproj.git_M#]

 

새로 추가된 remote에 기존의 내용(commit)을 업데이트 (push)하기 위해서는 다음의 명령어도 가능

 

[#M_ more.. | less.. |git push -u secondremote _M#]


모든 remote 에서 branch 및 update 된 내역을 가져오려면 다음 명령어 실행(HEAD 에 merge 하지는 않는다.)

 

[#M_ more.. | less.. | git remote update _M#]


alt remote 의 master branch 에서 fetch 하고 현재 HEAD 에 pull

 

[#M_ more.. | less.. | git pull alt master_M#]

 

매번 repository 마다 push/pull 을 따로 해줘야 하는게 번거롭다면 stackoverflow의 pull/push from multiple remote locations 글의 http://stackoverflow.com/a/3195446 답변을 참고

 

“Microsoft 직렬 볼펜” 과 “Serial Converter(FTDI)” 와 충돌하여 사용 불가능 할 경우,

FTDI 드라이버 고급속성 (장치관리자에서 COM 포트 속석)에서 “Serial Enumerator (직렬 니유머레이터” 항목을 비활성화

원인 : https://stackoverrun.com/ko/q/2408753
자세한 내용 : http://www.ftdichip.com/Support/Documents/AppNotes/AN_107_AdvancedDriverOptions_AN_000073.pdf

사용하지 않는 Serial Port를 제거하는 방법

사용하지 않는 Serial Port를 제거하는 방법
아래 작업 방법을 실행해 주시기 바랍니다.

 

  1. Windows Key + R을 눌러 명령 프롬프트를 실행합니다.
  2. cmd 명령 프롬프트에서 ‘set devmgr_show_nonpresent_devices=1‘를 입력합니다.
  3. 그리고 ‘start devmgmt.msc‘를 입력합니다.
  4. 장치관리자가 실행이 되면, 보기 -> 숨김 장치 표시 선택하면 숨겨진 장치들이 표시됩니다.
  5. 제거하려고 하는 COM Port를 마우스 우클릭하고 ‘제거’를 클릭합니다.

lsyncd + rsync로 디렉토리 실시간 백업하기

lsyncd + rsync로 디렉토리 거의 실시간 백업하기
실시간 동기화 라고 할 수도 있지만.. 실제로는 원본 디렉토리에 파일이 생성된 직후 rsync가 실행되어 백업 서버로 동기화 하기 때문에 파일이 copy되는 동안의 시간차 발생함.
1. rsync 설치, 설치 확인 (백업서버)
[root@vm2 sdir]# yum install rsync
[root@vm2 sdir]# rpm -qa | grep rsync
rsync-3.0.6-4.el5_7.1
2. rsync 활성화 (백업서버)
[root@vm2 data]# vi /etc/xinetd.d/rsync
# default: off
# description: The rsync server is a good addition to an ftp server, as it \
# allows crc checksumming etc.
service rsync
{
disable = no
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = –daemon
log_on_failure += USERID
}
3. rsyncd.conf 설정 (백업서버)
[root@vm2 data]# vi /etc/rsyncd.conf
[data_sync]
path=/data/sdir <– 접근을 허용할 디렉토리(백업디렉토리)
hosts allow=192.168.122.20 <– 접근을 허용할 서버 IP, 여러대를 동기화 할 경우 , 로 IP 추가
uid=0
gid=0
use chroot=yes
read only=no
[root@vm2 data]# mkdir /data/sdir
[root@vm2 data]#
[root@vm2 data]# /etc/init.d/xinetd restart
xinetd 를 정지 중: [ OK ]
xinetd (을)를 시작 중: [ OK ]
[root@vm1 data]#
4. lsyncd 설치 (원본서버)
[root@vm1 yum.repos.d]# yum install lsyncd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.daum.net
* extras: ftp.daum.net
* rpmforge: ftp.riken.jp
* updates: ftp.daum.net
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package lsyncd.i386 0:2.0.4-1.el5.rf set to be updated
–> Processing Dependency: lua for package: lsyncd
–> Running transaction check
—> Package lua.i386 0:5.1.4-2.el5.rf set to be updated
–> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================
Installing:
lsyncd i386 2.0.4-1.el5.rf rpmforge 149 k
Installing for dependencies:
lua i386 5.1.4-2.el5.rf rpmforge 242 k
Transaction Summary
====================================================================================================================================
Install 2 Package(s)
Upgrade 0 Package(s)
Total download size: 391 k
Is this ok [y/N]: y
Downloading Packages:
(1/2): lsyncd-2.0.4-1.el5.rf.i386.rpm | 149 kB 00:00
(2/2): lua-5.1.4-2.el5.rf.i386.rpm | 242 kB 00:00
————————————————————————————————————————————
Total 243 kB/s | 391 kB 00:01
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : lua 1/2
Installing : lsyncd 2/2
Installed:
lsyncd.i386 0:2.0.4-1.el5.rf
Dependency Installed:
lua.i386 0:5.1.4-2.el5.rf
Complete!
[root@vm1 yum.repos.d]#
– yum 으로 실치가 불가능할 경우 아래와 같이 rpmforge의 레포지터리를 추가하거나, rpm 파일을 다운로드 받아서 설치
[root@vm1 yum.repos.d]# cat /etc/yum.repos.d/rpmforge.repo
[rpmforge]
name = Red Hat Enterprise $releasever – RPMforge.net – dag
#baseurl = http://apt.sw.be/redhat/el5/en/$basearch/dag
mirrorlist = http://apt.sw.be/redhat/el5/en/mirrors-rpmforge
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge
enabled = 1
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 0
5. lsyncd.conf 파일 생성 (원본서버)
settings = {
logfile = “/var/log/lsyncd.log”, <– 로그파일 경로 설정
statusFile = “/var/log/lsyncd-status.log”, <– lsyncd 상태 로그 경로
delay = 1,
}
sync{
default.rsync,
source= “/data/sdir”, <– 동기화 할 원본 디렉토리
rsyncOpts= “-avz”,
target= “192.168.122.184::data_sync” <– backup 경로, rsyncd.conf 파일에 지정된 서비스명
}
sync{
default.rsync,
source= “/data/sdir”, <– 동기화 할 원본 디렉토리
rsyncOpts= “-avz”,
target= “192.168.122.150::data_sync”, <– backup 경로, rsyncd.conf 파일에 지정된 서비스명
}
==============================================
– 백업서버가 2EA 이상일 경우, 아래와 같은 형식으로 작성해도 됨.
[root@vm1 sdir]# cat /etc/lsyncd.conf
settings = {
logfile = “/var/log/lsyncd.log”, <– 로그파일 경로 설정
statusFile = “/var/log/lsyncd-status.log”, <– lsyncd 상태 로그 경로
delay = 1,
}
targetlist = {
“192.168.122.184::data_sync”, <– backup 경로, rsyncd.conf 파일에 지정된 서비스명
“192.168.122.150::data_sync” <– backup 경로, rsyncd.conf 파일에 지정된 서비스명
}
for _, server in ipairs(targetlist) do
sync{ default.rsync,
source=”/data/sdir/”, <– 동기화 할 원본 디렉토리
target=server,
rsyncOpts= “-avz”,
}
end
6. lsyncd 데몬 실행 (원본서버)
[root@vm1 sdir]# /etc/init.d/lsyncd restart
lsyncd (을)를 시작 중: [ OK ]
7. 동기화 테스트
– 원본 서버의 source 디렉토리(/data/sdir) 에서 파일을 생성/삭제하면서, 백업서버의 target 디렉토리가 정상적으로 동기화 되는지 확인
8. 여러대의 서버를 서로 상호간 동기화 설정을 하기 위해서는
– 원본 서버에 백업서버와 동일하게 rsyncd.conf 파일을 생성하여 백업서버에서 접근이 가능하도록 설정
– 백업서버에 원본과 동일하게 lsyncd를 실행하고 백업 디렉토리에 생성/삭제된 파일이 원본서버로 동기화 되도록 설정

How to install asterisk and freepbx on ubuntu 16.04

출처 : https://schooloffreelancing.blogspot.com/2017/11/asterisk-freepbx-install-into-ubuntu.html

apt-get -y autoremove
apt-get -y update
apt-get -y upgrade
# Some Utils
apt-get install -y curl vim-nox
# PJSIP
apt-get install -y make gcc g++ binutils sudo git
cd /usr/src
git clone https://github.com/asterisk/pjproject.git
cd /usr/src/pjproject
CFLAGS=’-DPJ_HAS_IPV6=1′ ./configure –prefix=/usr –enable-shared –disable-sound –disable-resample –disable-video –disable-opencore-amr
make dep 
make
make install
ldconfig
ldconfig -p | grep pj
# Asterisk 13
apt-get install -y libtool pkg-config libnewt-dev subversion
apt-get install -y libncurses5-dev uuid-dev libjansson-dev libxml2-dev libsqlite3-dev
apt-get install -y libmysqlclient-dev 
apt-get install -y unixodbc-dev libmyodbc
apt-get install -y libssl-dev libcurl4-openssl-dev libgnutls28-dev libsrtp0-dev
apt-get install -y bison flex
apt-get install -y sox lame flac mpg123 libmpg123-dev libogg-dev libvorbis-dev libspeex-dev libspeexdsp-dev libasound2-dev
apt-get install -y libiksemel-dev libiksemel-utils 
apt-get install -y libspandsp-dev
apt-get install -y libical-dev libneon27-dev 
cd /usr/src
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz
tar zxvf asterisk-13-current.tar.gz
cd asterisk-*
# contrib/scripts/install_prereq install
contrib/scripts/get_mp3_source.sh
./configure
make menuselect.makeopts
menuselect/menuselect –enable-category MENUSELECT_ADDONS menuselect.makeopts
menuselect/menuselect –enable CORE-SOUNDS-EN-GSM –enable MOH-OPSOUND-WAV –enable EXTRA-SOUNDS-EN-GSM –enable cdr_mysql menuselect.makeopts
menuselect/menuselect –disable app_mysql –disable app_setcallerid –disable func_audiohookinherit menuselect.makeopts
make
make install
make config
make samples
ldconfig
ldconfig -p | grep asterisk
systemctl disable asterisk.service
cd /var/lib/asterisk/sounds
wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-en-wav-current.tar.gz
wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-wav-current.tar.gz
tar xvf asterisk-core-sounds-en-wav-current.tar.gz
rm -f asterisk-core-sounds-en-wav-current.tar.gz
tar xfz asterisk-extra-sounds-en-wav-current.tar.gz
rm -f asterisk-extra-sounds-en-wav-current.tar.gz
# Wideband Audio download 
wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-en-g722-current.tar.gz
wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-g722-current.tar.gz
tar xfz asterisk-extra-sounds-en-g722-current.tar.gz
rm -f asterisk-extra-sounds-en-g722-current.tar.gz
tar xfz asterisk-core-sounds-en-g722-current.tar.gz
rm -f asterisk-core-sounds-en-g722-current.tar.gz
useradd -m asterisk
chown asterisk. /var/run/asterisk
chown -R asterisk. /etc/asterisk
chown -R asterisk. /var/{lib,log,spool}/asterisk
chown -R asterisk. /usr/lib/asterisk
# FreePBX 13
export DEBIAN_FRONTEND=noninteractive
apt-get install -y apache2 mysql-server mysql-client php5 php5-curl php5-cli php5-mysql php5-gd php-pear unixodbc
rm /var/www/html/index.html
sed -i ‘s/\(^upload_max_filesize = \).*/\120M/’ /etc/php5/apache2/php.ini
cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf_orig
sed -i ‘s/^\(User\|Group\).*/\1 asterisk/’ /etc/apache2/apache2.conf
sed -i ‘s/AllowOverride None/AllowOverride All/’ /etc/apache2/apache2.conf
service apache2 restart
cat >> /etc/odbcinst.ini << EOF
[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libodbcmyS.so
FileUsage = 1
 
EOF
cat >> /etc/odbc.ini << EOF
[MySQL-asteriskcdrdb]
Description=MySQL connection to ‘asteriskcdrdb’ database
driver=MySQL
server=localhost
database=asteriskcdrdb
Port=3306
Socket=/var/run/mysqld/mysqld.sock
option=3
 
EOF
cd /usr/src
wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-13.0-latest.tgz
tar vxfz freepbx-13.0-latest.tgz
rm -f freepbx-13.0-latest.tgz
cd /usr/src/freepbx
rm /etc/asterisk/*.conf
./start_asterisk start
./install -n
cat >> /etc/systemd/system/freepbx.service << EOF
[Unit]
Description=FreePBX VoIP Server
After=mysql.service
 
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/fwconsole start
ExecStop=/usr/sbin/fwconsole stop
 
[Install]
WantedBy=multi-user.target
 
EOF
systemctl enable freepbx.service
systemctl start freepbx.service
systemctl status freepbx.service
fwconsole chown
fwconsole reload
fwconsole moduleadmin installall
fwconsole moduleadmin upgradeall
fwconsole chown
fwconsole reload
fwconsole moduleadmin uninstall dahdiconfig
fwconsole moduleadmin delete dahdiconfig
fwconsole moduleadmin uninstall sipstation
fwconsole moduleadmin delete sipstation
fwconsole moduleadmin uninstall digium_phones
fwconsole moduleadmin delete digium_phones
fwconsole moduleadmin uninstall cxpanel
fwconsole moduleadmin delete cxpanel
fwconsole moduleadmin uninstall firewall
fwconsole moduleadmin delete firewall
fwconsole moduleadmin upgradeall
fwconsole chown
fwconsole reload
fwconsole chown

MySQL 외부 접속 (root / user) 가능하도록 설정

원격 접속 가능한 호스트 및 사용자 확인

[root@company bin]# mysql uroot p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 561388
Server version: 5.0.51log Source distribution
 
 
 
mysql> select HOST, USER, Password FROM mysql.user;
+—————–+——-+——————————————-+
| HOST            | USER  | Password                                  |
+—————–+——-+——————————————-+
| localhost       | root  | *(생략)                           | 
| company         | root  |                                           | 
| 127.0.0.1       | root  |                                           | 
| localhost       |       |                                           | 
| company         |       |                                           | 
| localhost       | news  | *(생략)                                | 
| 211.200.200.200 | news  | (생략)                                     | 
| 100.200.100.100 | news  | (생략)                                      | 
| 192.168.100.110 | news  | (생략)                                      | 
+—————–+——-+——————————————-+
 
9 rows in set (0.02 sec)

위 경우 HOST에 명시된 호스트에서만 접속 가능.

따라서 사용자 추가.

mysql> show databases;
+——————–+
| Database           |
+——————–+
| information_schema | 
| mysql              | 
| company            | 
+——————–+
3 rows in set (0.01 sec)
 
mysql> use mysql
Database changed
 
mysql> insert into user (host,user,password) 
values(‘%’,‘news’,password(‘newspasswd’));
Query OK, 0 rows affected (0.02 sec)
 
mysql> GRANT all privileges on *.* to ‘news’@‘%’ 
identified by ‘newspasswd’ ;
Query OK, 0 rows affected (0.02 sec)
 
mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)
 
 
mysql> select HOST, USER, Password FROM mysql.user;
+—————–+——-+——————————————-+
| HOST            | USER  | Password                                  |
+—————–+——-+——————————————-+
| localhost       | root  | *7540F67EE4(생략)                         | 
| company         | root  |                                           | 
| 127.0.0.1       | root  |                                           | 
| localhost       |       |                                           | 
| company         |       |                                           | 
| localhost       | news  | *7540F67EE4                               | 
| 211.200.200.200 | news  | 49d7                                      | 
| 100.200.100.100 | news  | 49d7                                      | 
| 192.168.100.110 | news  | 49d7                                      | 
| %  | news  | *7540F67EE4                               | 
+—————–+——-+——————————————-+
10 rows in set (0.02 sec)
 


단 MySQL 5.7에서는 Insert 명령어를 아래와 같이 변경해야 함.
insert into user(host,user,authentication_string,ssl_cipher,x509_issuer,x509_subject) values (‘%’, ‘news’, password(‘password’),”,”,”);


호스트를 %로 할경우 어떤 호스트에서든 접속 가능.

이렇게 하고도… 외부에서 접속이 안될 경우

1. OS 방화벽 (리눅스 방화벽 확인 ) 해제 – ufw disable
2. MySQL 설정 파일 “my.cnf” (mysqld.cnf) 에, bind-address=127.0.0.1 로 되어 있는 것을 “0.0.0.0” 으로 변경 후, 
3. MySQL 재시작