ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 웹 서버
    linux/centOS 2018. 7. 18. 11:47

    ☆ http

     

    HTTP (Hypertext Transfer Protocol) ; 하이퍼텍스트 전송 규약

    -> http://www.daum.net:80 (port 80)

     

    HTTP는 웹 상에서 파일(텍스트, 그래픽 이미지, 사운드, 비디오 그리고 기타 멀티미디어 파일)을 주고받는데 필요한 프로토콜로서 TCP/IP와 관련된 하나의 응용 프로토콜이다.

     

    HTTP의 한 부분을 이루는 중요한 개념들은 - 그 이름에도 내포되어 있듯이 - 모든 파일들이 다른 파일들에 대한 참조 링크를 가질 수 있다는 것이며, 그 링크를 선택하면, 또다른 내용이 추가적으로 전달되는 식의 아이디어로 되어 있다. 웹 서버는 모두 HTTP 데몬을 가지고 있는데, 이 프로그램은 HTTP 요청을 기다리고 있다가 요청이 들어오면 그것을 처리하도록 설계되어 있다. HTTP의 입장에서의 웹 브라우저는 서버에 요구를 전달하는 하나의 클라이언트이다. 사용자가 URL을 입력하거나, 하이퍼텍스트 링크를 클릭 함으로써 파일을 요구하면, 브라우저는 HTTP 요구를 URL에 적혀있는 IP 주소에 전달한다. 지정된 서버상의 HTTP 데몬은 그 요구를 받아서, 필요한 작업이 혹 있다면 처리를 한 뒤에 요구된 파일을 찾아서 보내준다.

     

    HTTP 프로토콜은 WWW(World Wide Web)에서 사용되는 프로토콜이다.

    HTTP 프로토콜은 간단(Simple)한 비상태기반 프로토콜(Stateless Protocol)이다.

    클라이언트 측면 요청(Client-Side Request)와 서버측면 응답(Server-Side Response)으로 구성된다.

    요청과 응답은 3가지 부분으로 구성이 된다.
    요청 코드(Request Method)/응답 코드(Response Code)
    헤더(Header)
    바디(Body)

     

     

    HTTPS (Secure Hypertext Transfer Protocol)

    -> https://www.daum.net:443 (port 443)

     

    HTTPS는 넷스케이프에 의해 개발되고 그들의 브라우저에 구현된 웹 프로토콜로서, 사용자의 페이지 요청들과 웹서버에 의해 반환되는 페이지들을 암호화하고 해석한다. HTTPS는 실제로 넷스케이프의 SSL을 정규 HTTP 응용계층 하에서 서브 계층으로서 사용한다 (HTTP가 하부계층인 TCP/IP와의 상호작용을 위해 80번 포트를 사용하는데 비해, HTTPS443번 포트를 사용한다). SSLRC4 스트림 암호화 알고리즘을 위해 40 비트 크기의 키를 사용하는데, 이는 상업적 데이터의 교환을 위한 암호화 정도에 적합하다고 간주된다.

     

    NetPlaza (http://www.netplaza.com)와 같은 웹사이트에 방문해서 그들의 카탈로그를 보기 위해 넷스케이프 브라우저를 사용한다고 가정하라. 주문할 준비가 되었을 때, 사용자는 URLhttps://로 시작되는 웹페이지 주문서를 받게 될 것이다. 사용자가 그 페이지를 판매자에게 보내기 위하여 "보내기" 단추를 클릭하면, 브라우저의 HTTPS 계층이 그 페이지를 암호화한다. 서버가 받았음을 알리는 회신내용 역시 암호화된 형식으로 도착되지만, 그 내용은 브라우저의 HTTPS 서브 계층에 의해 해석된다.

     

    HTTPSSSL은 서버로부터의 X.509 디지털 인증서 사용을 지원하므로, 필요한 경우 사용자는 발신자를 믿을 수 있음을 증명할 수 있다. SSL은 넷스케이프가 W3C에 표준으로 제안한 개방형이며, 비독점적 프로토콜이다. HTTPSEIT가 개발하고 표준으로 제안한 HTTP의 보안 강화판인 SHTTP와 혼동하면 안된다.

     

    S-HTTP (Secure HTTP)

     

    S-HTTP는 월드와이드웹 상의 파일들이 안전하게 교환될 수 있게 해주는 HTTP의 확장판이다. S-HTTP 파일은 암호화되며, 전자서명을 포함한다. S-HTTP는 잘 알려진 또다른 보안 프로토콜인 SSL의 대안이다. 두 가지의 주요 차이점은, S-HTTP는 틀림없는 사용자라는 것을 입증하기 위한 인증서를 클라이언트에서 보낼 수 있는 반면에, SSL에서는 오직 서버만이 인증할 수 있다는 점이다. S-HTTP는 은행을 대리해 서버가 있는 곳, 또는 사용자ID와 패스워드를 사용하는 것보다 좀더 안전한 사용자로부터 인증이 필요한 상황에서 보다 많이 사용될 것 같다.

     

    S-HTTP는 어떠한 단일 암호화 시스템을 사용하지 않지만, RSA 공개키/개인키 암호화 시스템은 지원한다. SSLTCP 계층보다 더 상위의 프로그램 계층에서 동작한다. S-HTTPHTTP 응용의 상위 계층에서 동작한다. 두 개의 보안 프로토콜들 모두가 한 사용자에 의해 사용될 수 있지만, 주어진 문서에 대해서는 오직 그중 하나만이 사용될 수 있다. Terisa Systems은 인터넷 보안도구 내에 SSLS-HTTP 모두를 포함한다.

     

    AOL, 컴퓨서브, IBM, 넷스케이프, Prodigy, 그리고 Spyglass 등이 S-HTTP를 지원한다. 새로 나오는 브라우저들은 SSLS-HTTP를 모두 지원한다. S-HTTPIETF에 표준안으로 상정되었다. RFC 2660S-HTTP에 대해 자세한 설명이 나와있다.

    S-HTTP에 관해 설명하고 있는 IETFRFC 2660 초안입니다. (http://www.ietf.org/rfc/rfc2660.txt)

     

     

    ☆ 웹 서버 개요

     

    (1) 웹서버(Web Server)?

     

    웹 브라우저를 이용하여 World Wide Web을 사용하는 클라이언트에게 미리 저장된 하이퍼 텍스트를 제공하는 서버를 지칭한다.

     

    (웹브라우저) <--------------> (웹서버)

    Internet explore Apache(httpd)

    Firefox IIS

    Mozilla TmaxSoft WebToB

    Crome

     

    [참고] WAS(Web Application Server)

    - (무료) Tomcat

    - (유료) BEA Weblogic(-> Oracle), IBM Webspere, TmaxSoft Zeus

     

    [참고] Web Server 대표적인 제품

    - (무료) Apache Server, IIS

    - (유료) TmaxSoft WebTob

     

    [참고] WAS (Web Application Server) 대표적인 제품

    - (무료) Apache, Tomcat

    - (유료) BEA WebLogic(-> Oracle), IBM Webspere, TmaxSoft Zeus

     

     

    (2) 웹서버(Web Server)의 종류

     

    종류

    설명

    NCSA Server

    아파치 서버의 모태.(NCSA httpd 1.3.X)

    CERN Server

    스위스에 있는 유럽 핵물리 연구기관으로 World Wide Web 프로젝트가 시작된곳.

    Apache Server

    NCSA서버의 개량형, 성능과 기능면에서 우수. 하나의 port(default:80)에서 일반 WebProxy 동시 지원 각 기능의 MoDule화 가장 많이 사용되는 Web Server이다.

    Apache-SSL Server

    아파치 서버의 보안성을 높혔다. 무료로사용, 128bit 엔크립션사용(암호화)

    Netscape Enterprise Server

    상업용 서버 인데, 현재 거의 사용 하지 않는다.

    IIS

    Internet Information Server, window NT Server. HTTP(Hypertext Transfer Protocol) 바이트 범위 지원.SQL데이터를 HTML 형식으로 변환. CGI 응용프로그램이 모든 환수 변수를 받음. HTML 페이지와 기타 문서의 내용에 색인 붙이기. SSL 키를 만들기 위한 그래픽 도구

    AOL Server

    다양한 플랫폼을 지원.

     

     

     

    (3) 고성능의 웹서버가 개발되기 위한 요건

     

    요건

    설명

    동시처리(Concurrency)

    서버는 동시에 여러개의 클라이언트 요청을 수행해야만 한다.

    효율성(Efficiency)

    서버는 지연(latency)을 최소화해야하고, 대역폭을 최대로 활용해야 하며, 불필요하게 CPU()을 동작시키는 것을 피해야 한다.

    프로그래밍 단순화

    (Programming simplicity)

    서버의 디자인은 효율적인 동시처리에 대한 운영 전략의 적용을 단순화할 수 있어야 한다.

    적응성(Adaptability)

    신규 혹은 개선된 트랜스포트 프로토콜(HTTP 1.1과 같은)을 지원하는데 있어서 최소한의 관리 비용이 들도록 해야한다.

     

     

    (4) 웹서버의 구조

     

    Client는 웹브라우저를 통해 HTTP 요청

    웹서버는 요청에 대한 내용을 분석

    파일 시스템의 파일정보를 읽어 들인다.

    Client에게 파일을 보낸다.

     

     

    ☆ 간단한 웹 서버 구성

     

    아파치는 "open source" 라이선스에 따라 배포되어 마음대로 쓸 수 있는 웹서버이다. 버전 1.3은 리눅스, Solaris, Digital UNIX, AIX와 같은 대부분의 유닉스 기반 운영체계, Rhapsody, BeOS, BS2000/OSD 등과 같이 유닉스/포직스에서 파생된 시스템들, 그리고 AmigaOS 및 윈도우NT/95/98 등에서 실행된다. Netcraft에서 19989월에 실시한 웹서버 실태조사에 따르면, 전세계 인터넷 서버의 50% 이상이 아파치에서 운영되고 있다고 한다. 마이크로소프트에서 나온 윈도우기반의 웹서버, 넷스케이프, 그리고 다른 회사들이 수 적인 면에서 보면 늘어가고 있지만, 아파치는 아마도 유닉스 기반의 시스템이 널리 퍼져 있는 기업이나 대학에서 대중적 인기를 계속 유지할 것으로 보인다.

     

    아파치의 Market share에 대한 부분은 http://www.netcraft.com/survey 사이트를 참고한다.

     

    ※ 아파치 웹서버에 관련한 파일/디렉토리

    종 류

    설 명

    /etc/httpd/conf/httpd.conf

    아파치 웹서버 주 설정 파일

    /etc/httpd/conf.d/*.conf

    아파치 웹서버 주 설정 파일에 포함된 하위 설정 파일

    /etc/httpd/logs

    /var/log/httpd/, 아파치 웹서버 로그 디렉토리

    /etc/httpd/modules

    /usr/lib/httpd/modules/, 아파치 웹서버 모듈 디렉토리

    /etc/httpd/run/httpd.pid

    /var/run/, 실행 중인 아파치 데몬의 PID 번호를 저장하는 파일

    /etc/mime.types

    CUPS을 위한 MIME 타입 설명 파일

    /etc/rc.d/init.d/httpd

    아파치 데몬을 제어할 수 있는 스크립트

    /usr/sbin/httpd

    아파치 웹데몬

    /usr/sbin/htpasswd

    특정 디렉토리를 제어할 때 사용하는 사용자 패스워드 입력 프로그램

    /usr/sbin/apxs

    DSO(Dynamic Shared Object) 기반 아파치 모듈을 컴파일할 때 사용되는 유틸리티

     

     

     

    (1) 간단한 웹서버 구성

     

    INDEX

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

    1. 실습준비

    2. 관리자를 위한 웹기본 설정

    3. 사용자를 위한 웹기본 설정

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

     

    (1-1) 실습준비

     

    ----- DNS Server -----   ----- WEB Server -----

       (172.16.9.2XX)               (172.16.9.1XX)

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

     

    [그림] 실습 구조(Master/Slave DNS Server)

     

    (DNS 서버쪽) 172.16.9.240 (EX: 172.16.9.2XX)

    - /etc/resolv.conf 파일 설정

    - Master DNS 서버만 구축

    -> 웹서버 등록

     

    (WEB 서버쪽) 172.16.9.140 (EX: 172.16.9.1XX)

    - /etc/resolv.conf 파일 설정

    - (Optional) /etc/hosts 파일설정

     

    (DNS 서버쪽) 172.16.9.2XX

    /etc/resolv.conf 파일 설정

     

    (가정) 실습에서는 Master DNS 서버만 사용하는 것으로 한다.

    Slave DNS 서버의 설정은 삭제하는것으로 한다.

     

    # vi /etc/resolv.conf

    search linux2XX.example.com

    nameserver 172.16.9.2XX

     

    Master DNS 서버만 구축

    # vi /etc/named.rfc1912.zones

    ..... (중략) .....

    zone "linuxXXX.example.com" IN {

    type master;

    file "exampleXXX.zone";

    also-notify { 172.16.10.149; 172.16.10.249; };

    };

     

    zone "9.16.172.in-addr.arpa" IN {

    type master;

    file "exampleXXX.rev";

    also-notify { 172.16.10.149; 172.16.10.249; };

    };

    -> zone 안에 also-notiry 설정이 되어 있어도 상관이 없다. 하지만 실습에서는 삭제한다.

    -> also-notify 라인을 삭제하지 않고 주석처리할 수도 있다. 이른 경우 "//"(c++ 사용하는 주석)을 사용한다.

     

    # vi /var/named/chroot/var/named/example2XX.zone

    ..... (중략) .....

    IN NS ns1

    IN NS ns2

    ns1 IN A 172.16.9.2XX

    ns2 IN A 172.16.9.1XX

    -> DNS Slave 서버에 대한 정의가 되어 있어도 상관이 없다. 하지만 실습에서는 삭제한다.

     

    # vi /var/named/chroot/var/named/example2XX.rev

    ..... (중략) .....

    IN NS ns1.linux2XX.example.com.

    IN NS ns2.linux2XX.example.com.

    2XX IN PTR ns1.linux2XX.example.com.

    1XX IN PTR ns2.linux2XX.example.com.

    -> DNS Slave 서버에 대한 정의가 되어 있어도 상관이 없다. 하지만 실습에서는 삭제한다.

     

    웹등록

    # vi /var/named/chroot/var/named/example2XX.zone

    ..... (중략) .....

    ;; (2) Web Server

    www IN A 172.16.9.1XX

    (주의) 웹서버(172.16.9.1XX) 아이피에 주의

     

    변경 내용 적용

    # service named restart (# rndc reload)

    Stopping named: [ OK ]

    Starting named: [ OK ]

    -> 반드시 확인 작업 필요

     

    # nslookup www.linux2XX.example.com (# nslookup www)

    Server: 172.16.9.XXX

    Address: 172.16.9.XXX#53

     

    Name: www.linuxXXX.example.com

    Address: 172.16.9.1XX

    -> 정보가 출력되야 한다. (IP: 172.16.9.1XX)

     

     

     

    (웹 서버쪽) 172.16.9.1XX

    /etc/resolv.conf

    # vi /etc/resolv.conf

    search linux2XX.example.com

    nameserver 172.16.9.2XX

    -> DNS 서버쪽을 지정했기 때문에 DNS 서버쪽에서 도메인을 등록한 경우 정상적으로 동작할 것이다.

    -> 만약 DNS 서버가 없는 환경이라면 /etc/hosts 파일을 사용하면 된다.

     

    DNS 서비스 stop

    # chkconfig named off

    # service named stop

     

     

    (1-2) 관리자를 위한 웹 기본 설정

     

    패키지: httpd-2.2.3-31

           ------ Web Server ------                                       ------ Web Client ------

     

    httpd(80)

    - /etc/httpd/conf/httpd.conf

    - /var/www/html/index.html                       <---- http://www.linux2XX.example.com/

    - /home/<사용자>/public_html/index.html         <---- http://www.linux2XX.example.com/~user01/

     

    프로그램 : httpd-2.2.3-31 httpd-manual system-config-httpd

    데몬 & 포트 & 프로토콜 : /usr/sbin/httpd, 80, TCP

    설정 파일 : /etc/httpd/conf/httpd.conf

    하위 설정 파일 : /etc/httpd/conf.d/*.conf

    스크립트 : /etc/init.d/httpd

     

     

     

    패키지 확인

    # rpm -qa | grep httpd

    httpd-2.2.3-31.el5.centos.2

    httpd-manual-2.2.3-31.el5.centos.2

    system-config-httpd-1.3.3.3-1.el5

    [참고] httpd-* 관련 패키지에 대해서

    # system-config-httpd & ----> system-config-httpd-1.3.3.3-1.el5

    # cd /var/www/manual ; ls ----> httpd-manual-2.2.3-31.el5.centos.2

     

    # rpm -ql httpd

    /etc/httpd

    /etc/httpd/conf

    /etc/httpd/conf.d

    /etc/httpd/conf.d/README

    /etc/httpd/conf.d/proxy_ajp.conf

    /etc/httpd/conf.d/welcome.conf

    /etc/httpd/conf/httpd.conf

    /etc/httpd/conf/magic

    /etc/httpd/logs

    /etc/httpd/modules

    /etc/httpd/run

    /etc/logrotate.d/httpd

    /etc/rc.d/init.d/httpd

    /etc/sysconfig/httpd

    /usr/bin/ab

    /usr/bin/htdbm

    /usr/bin/htdigest

    /usr/bin/htpasswd

    /usr/bin/logresolve

    /usr/lib/httpd

    /usr/lib/httpd/modules

    /usr/lib/httpd/modules/mod_actions.so

    ..... (중략) .....

    /usr/lib/httpd/modules/mod_unique_id.so

    /usr/lib/httpd/modules/mod_userdir.so

    /usr/lib/httpd/modules/mod_usertrack.so

    /usr/lib/httpd/modules/mod_version.so

    /usr/lib/httpd/modules/mod_vhost_alias.so

    /usr/sbin/apachectl

    /usr/sbin/htcacheclean

    /usr/sbin/httpd

    /usr/sbin/httpd.event

    /usr/sbin/httpd.worker

    /usr/sbin/httxt2dbm

    /usr/sbin/rotatelogs

    /usr/sbin/suexec

    /usr/share/doc/httpd-2.2.3

    /usr/share/doc/httpd-2.2.3/README

    /usr/share/doc/httpd-2.2.3/VERSIONING

    ..... (중략) .....

     

    데몬 확인 및 포트 확인

    # httpd -v (-v : version)

    Server version: Apache/2.2.3

    Server built: Nov 12 2009 18:43:47

     

    # grep http /etc/services | more

    # http://www.iana.org/assignments/port-numbers

    http 80/tcp www www-http # WorldWideWeb HTTP

    http 80/udp www www-http # HyperText Transfer Protocol

    https 443/tcp # MCom

    https 443/udp # MCom

    gss-http 488/tcp

    gss-http 488/udp

    http-alt 8008/tcp

    http-alt 8008/udp

    http-mgmt 280/tcp # http-mgmt

    http-mgmt 280/udp # http-mgmt

    http-rpc-epmap 593/tcp # HTTP RPC Ep Map

    http-rpc-epmap 593/udp # HTTP RPC Ep Map

    multiling-http 777/tcp # Multiling HTTP

    multiling-http 777/udp # Multiling HTTP

    llsurfup-http 1183/tcp # LL Surfup HTTP

    llsurfup-http 1183/udp # LL Surfup HTTP

    ..... (중략) .....

     

    주 설정 파일 확인

    # cd /etc/httpd/conf

    # ls -l

    -rw-r--r-- 1 root root 33K Nov 13 08:47 httpd.conf

    -rw-r--r-- 1 root root 13K Nov 13 08:47 magic

     

    index.html 파일 생성 및 확인

    # cd /var/www/html

    # ls

    #

    -> index.html 파일이 없다.

     

    # cp /etc/passwd /var/www/html/index.html

    #

     

    httpd 서비스 restart

    # service httpd restart

    Stopping httpd: [FAILED]

    Starting httpd: [ OK ]

     

    웹서비스 확인

     

    웹서비스를 확인하는 여러가지 방법

    () GUI 웹브라우저를 사용하는 방법(EX: firefox)

    () TUI 웹브라우저를 사용하는 방법(EX: lynx/curl)

    () telnet 명령어를 사용하는 방법(EX: telnet <서버 IP> 80)

    () netstat 명령어를 사용하는 방법(EX: netstat -an | :80)

     

    GUI 웹브라우저를 사용하는 방법(EX: firefox, mozilla)

    # firefox http://www.linux2XX.example.com &

     

    TUI 웹브라우저를 사용하는 방법(EX: lynx)

     

    (lynx 프로그램이 없다면 설치) 인터넷이 되는 상태, /etc/resolv.conf 파일의 내용에 주의 해야 한다.

    # vi /etc/resolv.conf -> 임시적으로 정보 변경

    # yum -y install lynx

    # vi /etc/resolv.conf -> 원상태로 복원

     

    # lynx http://www.linux2XX.example.com

    (p1 of 2)

     

    root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin

    daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin

    lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync

    shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt

    mail:x:8:12:mail:/var/spool/mail:/sbin/nologin news:x:9:13:news:/etc/news:

    uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologinoperator:x:11:0:operator:/root:/sbin/nologin

    .... (중략) .....

    ntp:x:38:38::/etc/ntp:/sbin/nologin dbus:x:81:81:System message bus:/:/sbin/nologin

    avahi:x:70:70:Avahi daemon:/:/sbin/nologin rpcuser:x:29:29:RPC Service

    User:/var/lib/nfs:/sbin/nologin nfsnobody:x:65534:65534:Anonymous NFS

    User:/var/lib/nfs:/sbin/nologin named:x:25:25:Named:/var/named:/sbin/nologin

    hsqldb:x:96:96::/var/lib/hsqldb:/sbin/nologin sshd:x:74:74:Privilege-separated

    SSH:/var/empty/sshd:/sbin/nologin haldaemon:x:68:68:HAL daemon:/:/sbin/nologin

    avahi-autoipd:x:100:102:avahi-autoipd:/var/lib/avahi-autoipd:/sbin/nologinxfs:x:43:43:XFont

    Server:/etc/X11/fs:/sbin/nologingdm:x:42:42::/var/gdm:/sbin/nologinsabayon:x:86:86:Sabayon

    -- press space for next page --

    q <----- 'q' 입력

    Are you sure you want to quit? (y) y <----- 'y' 입력

    Arrow keys: Up and Down to move. Right to follow a link; Left to go back.

    H)elp O)ptions P)rint G)o M)ain screen Q)uit /=search [delete]=history list

     

     

    # lynx -head http://www.linux2XX.example.com (# lynx -head http://www.daum.net)

    HTTP/1.1 200 OK

    Date: Sun, 14 Mar 2010 08:30:42 GMT

    Server: Apache/2.2.3 (CentOS)

    Last-Modified: Sun, 14 Mar 2010 06:14:11 GMT

    ETag: "37b31-7eb-ac46d2c0"

    Accept-Ranges: bytes

    Content-Length: 2027

    Connection: close

    Content-Type: text/html; charset=UTF-8

     

     

     

    q <----- 'q' 입력

    Are you sure you want to quit? (y) y <----- 'y' 입력

    Commands: Use arrow keys to move, '?' for help, 'q' to quit, '<-' to go back.

    Arrow keys: Up and Down to move. Right to follow a link; Left to go back.

    H)elp O)ptions P)rint G)o M)ain screen Q)uit /=search [delete]=history list

     

     

    telnet 명령어를 사용하는 방법

    # telnet www.linux2XX.example.com 80

    Trying 172.16.9.240...

    Connected to www.linux240.example.com (172.16.9.240).

    Escape character is '^]'.

    GET <----- 'GET' 입력

    root:x:0:0:root:/root:/bin/bash

    bin:x:1:1:bin:/bin:/sbin/nologin

    daemon:x:2:2:daemon:/sbin:/sbin/nologin

    adm:x:3:4:adm:/var/adm:/sbin/nologin

    lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin

    sync:x:5:0:sync:/sbin:/bin/sync

    .... (중략) .....

    sabayon:x:86:86:Sabayon user:/home/sabayon:/sbin/nologin

    fedora:x:500:500:fedora:/home/fedora:/bin/bash

    user01:x:501:501::/home/user01:/bin/bash

    user02:x:502:502::/home/user02:/bin/bash

    user03:x:503:503::/home/user03:/bin/bash

    Connection closed by foreign host.

     

     

    netstat 명령어를 사용하는 방법

    # netstat -antp (-a: all, -n: numeric, -t: tcp, -u: udp, -p: program)

    Active Internet connections (servers and established)

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

    tcp 0 0 127.0.0.1:2208 0.0.0.0:* LISTEN 4203/hpiod

    tcp 0 0 0.0.0.0:707 0.0.0.0:* LISTEN 3917/rpc.statd

    tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 4235/xinetd

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

    tcp 0 0 172.16.9.250:53 0.0.0.0:* LISTEN 12789/named

    tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 12789/named

    tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 10365/vsftpd

    tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 5077/cupsd

    tcp 0 0 0.0.0.0:23 0.0.0.0:* LISTEN 4235/xinetd

    tcp 0 0 127.0.0.1:953 0.0.0.0:* LISTEN 12789/named

    tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 4253/sendmail: acce

    tcp 0 0 127.0.0.1:2207 0.0.0.0:* LISTEN 4208/python

    tcp 0 0 :::80 :::* LISTEN 14890/httpd

    tcp 0 0 :::22 :::* LISTEN 4221/sshd

    tcp 0 0 :::443 :::* LISTEN 14890/httpd

     

    [참고] netstat -an 명령어의 사용법에 대해서

    # netstat -an /* 모든 서비스: TCP + UDP + 소켓 */

    # netstat -ant /* TCP 서비스만 */

    # netstat -anu /* UDP 서비스만 */

     

    # netstat -anp /* 모든 서비스: TCP + UDP + 소켓, 프로그램이름/PID 표시 */

    # netstat -antp /* TCP 서비스만, 프로그램 이름/PID 표시 */

    # netstat -anup /* UDP 서비스만, 프로그램 이름/PID 표시 */

     

     

     

    (1-3) 사용자를 위한 웹 기본 설정

     

    (전제조건) user01,user02,fedora 사용자가 존재해야 한다.

    # tail /etc/passwd

    # useradd <사용자이름> (EX: # useradd user01)

    # passwd <사용자이름> (EX: # passwd user01)

     

    user01 사용자로 전환

    # su - user01
    $ id

    uid=501(user01) gid=501(user01) groups=501(user01)

     

    $ pwd

    /home/user01

     

    public_html 디렉토리와 index.html 파일 생성

    $ mkdir public_html

    $ cd public_html

    $ vi index.html

    <H1><CENTER>Web Server(linux1XX : user01)</CENTER></H1>

     

    사용자 홈디렉토리 퍼미션 변경

    $ cd

    $ ls -ld

    drwxr----- 4 user01 user01 1024 Mar 14 19:06 /home/user01

     

    $ chmod 755 /home/user01 ($ chmod 755 .)

    $ ls -ld /home/user01

    drwxr-xr-x 4 user01 user01 1024 Mar 14 19:06 /home/user01

     

    $ exit

    #

     

    /etc/httpd/conf/httpd.conf 파일 수정 및 적용

    # vi /etc/httpd/conf/httpd.conf

    /UserDir <------ Last Line Mode에서 '/UserDir' 입력

    [수정전]

    ..... (중략) .....

    <IfModule mod_userdir.c>

    #

    # UserDir is disabled by default since it can confirm the presence

    # of a username on the system (depending on home directory

    # permissions).

    #

    UserDir disable

     

    #

    # To enable requests to /~user/ to serve the user's public_html

    # directory, remove the "UserDir disable" line above, and uncomment

    # the following line instead:

    #

    #UserDir public_html

     

    </IfModule>

    ..... (중략) .....

    [수정후]

    ..... (중략) .....

    <IfModule mod_userdir.c>

    #

    # UserDir is disabled by default since it can confirm the presence

    # of a username on the system (depending on home directory

    # permissions).

    #

    #---> UserDir disable <----- '기존 라인 주석처리'

     

    #

    # To enable requests to /~user/ to serve the user's public_html

    # directory, remove the "UserDir disable" line above, and uncomment

    # the following line instead:

    #

    UserDir public_html <----- '기존 라인 주석처리 제거'

     

     

    </IfModule>

    ..... (중략) .....

    # service httpd restart

    Stopping httpd: [ OK ]

    Starting httpd: [ OK ]

    -> 만약 에러메세지가 발생한다면 무시하고 넘어가나. 또는 아래 내용을 참고하여 /etc/hosts 파일에 긴 이름의 호

    스트 이름을 등록하고 httpd 서비스를 재시작하면 된다.

     

    [참고] httpd 서비스 start 시 에러메세지 제어

    # service httpd restart

    httpd ()를 시작 중: httpd: apr_sockaddr_info_get() failed for linux1XX.example.com

    httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

    # vi /etc/hosts

    .....

    172.16.9.1XX linux1XX.example.com linux1XX

    # service httpd restart

     

    확인

    # firefox http://www.linux2XX.example.com/~user01  

     

     

     

     

     

    (정리) 사용자 웹페이지

     

      ----- Web Client -----                            ----- Web Server -----

    http://DAUM/~user01 ---------------------> httpd(80)

                                               /home/<사용자>/public_html/index.html

                                               # cat /etc/httpd/conf/httpd.conf

                                               UserDir public_html

     

     

     

    (1-4) 사용자를 위한 웹 기본 설정2

    (웹 요청 비교)

    http://www.linux2XX.example.com/~user01/

    http://www.linux2XX.example.com/user01/ (http://cafe.daum.net/bscsolaris)

     

    /etc/httpd/conf/httpd.conf 파일 설정

    # vi /etc/httpd/conf/httpd.conf

    /Alias <------ Last Line Mode에서 '/Alias' 입력

     

    ..... (중략) .....

    #

    # Aliases: Add here as many aliases as you need (with no limit). The format is

    # Alias fakename realname

    #

    # Note that if you include a trailing / on fakename then the server will

    # require it to be present in the URL. So "/icons" isn't aliased in this

    # example, only "/icons/". If the fakename is slash-terminated, then the

    # realname must also be slash terminated, and if the fakename omits the

    # trailing slash, the realname must also omit it.

    #

    # We include the /icons/ alias for FancyIndexed directory listings. If you

    # do not use FancyIndexing, you may comment this out.

    #

    Alias /icons/ "/var/www/icons/"

    Alias /user01/ "/home/user01/public_html/" <----- 새로운 라인 추가

     

    <Directory "/var/www/icons">

    Options Indexes MultiViews

    AllowOverride None

    Order allow,deny

    Allow from all

    </Directory>

    ..... (중략) .....

     

    httpd 서비스 재시작

    # service httpd restart

     

    서비스 확인

    # firefox http://www.linux2XX.example.com/user01/ (# firefox http://www.linux2XX.example.com/~user01)

     

     

    ※ pache Web Server 실행

     

    (현재) # service httpd (restart/start/stop)

    (부팅) # chkconfig httpd (on|off)

     

    (httpd 명령어 사용법)

    # httpd -t /* httpd.conf 파일의 문법 점검(Syntax Check) */

    # service httpd configtest /* httpd.conf 파일의 문법 점검(Syntax Check) */

    # httpd -v /* httpd 버전 확인 */

    # httpd -f httpd_test.conf /* httpd_test.conf 파일의 설정대로 데몬을 띄운다. */

    'linux > centOS' 카테고리의 다른 글

    FTP  (0) 2018.07.20
    DNS 서버 2  (0) 2018.07.17
    DNS 서버 1  (0) 2018.07.12
    네트워크 설정  (0) 2018.07.11
    centos  (0) 2018.07.10

    댓글

Designed by Tistory.