1. 서버 환경
1.1. 하드웨어
네트워크에 대한 관심으로 지속적으로 네트워크 공부를 해보고 싶어 윈도우 서버와 리눅스 서버를 모두 구축하기로 한다.
CPU : Pentium 4 1.8 Northwood Ram : 768 Ram Lan1 : Realtek RTL8139 Family PCI Fast Ethernet NIC Lan2 : Realtek RTL8139 Family PCI Fast Ethernet NIC #2 |
1.2. 시스템 구현
1) 기본 운영체제로 Windows 서버 Windows 2003 Enterprise Edition 설치.
2) VM Ware 6.0을 이용하여 Linux Fedora 5 설치.
3) Linux의 인터넷 사용시 윈도우 서버에 가는 무리를 줄이기 위하여 VMware에서는 Lan2 사용.
2. 웹서버(APM) 설치
웹서버는 웹 서비스를 제공하는 컴퓨터이다. 클라이언트는 웹브라우저에 ‘http://zzru.net’과 같은 웹 주소를 입력하면 클라이언트는 이 주소에 해당하는 웹 서버에게 웹 서비스를 요청한다. 요청을 받은 웹 서버는 자기가 가지고 있는 웹 문서를 클라이언트에게 전달한다. 이 과정을 웹 서비스라고 한다.
웹 서비스를 제공하기 위한 프로토콜은 HTTP(Hyper Text Transfer Protocol)이다. 웹서버와 클라이언트는 HTTP를 통해 서로 통신한다.
클라이언트의 웹 서비스 요청에 대해 리눅스 서버의 httpd 데몬이 처리를 담당하고 httpd는 well-known포트 80번(변경 가능)에 대한 요청을 웹 서비스에 대한 요청으로 받아들이고 웹 서비스를 수행하게 된다.
2.1 APM 이란?
아파치 웹서버는 클라이언트의 위에서 서술한 대로 클라이언트의 요청에 따라 서버에 저장된 웹 페이지를 클라이언트에게 보여주는 웹서비스를 담당한다.
최근 인터넷 사이트에서는 정적인 페이지가 아닌 게시판이나 방명록이 삽입 되게 되었다. 이에 단순히 HTML 문서나 그림 파일만을 보여주는 기존의 웹사이트는 의미를 잃게 되었다.
기존의 정적 페이지에서 벗어나 동적 페이지를 꾸미기 위하여 웹 프로그래밍 언어와 저장공간이 필요하게 되었다. 웹 프로그래밍 언어는 클라이언트와의 상호작용으로 정보를 제공받아 처리 과정을 거쳐 결과를 되돌려주는 동적 환경을 제공한다. 데이터베이스는 축척된 정보를 처리하여 쉽게 데이터를 관리 할 수 있게 해 준다.
이렇게 동적인 웹 사이트를 구축하는데 필요한 아파치 웹 서버, 동적 환경을 구축하기 위한 웹 프로그래밍 언어 PHP, 데이터베이스인 MySQL 3개를 하나의 뭉쳐 APM이라고 한다.
2.2 설치 과정
2.2.1 기존 설치 확인
yum 명령을 이요하여 Apache 웹 서버, PHP, MySQL을 설치한다. APM을 연동하기 위해서는 세 패키지 외에도 추가해서 설치해야 할 패키지들이 있는데, 이런 패키지들까지 함께 설치하도록 한다.
[root@localhost ~]# rpm -qa | grep httpd [root@localhost ~]# rpm -qa | grep php [root@localhost ~]# rpm -qa | grep mysql [root@localhost ~]# |
표 1에서 APM 패키지는 모두 설치되어 있지 않은것을 알 수 있다.
2.2.2 패키지 검색
yum search 명령으로 각각의 패키지 검색
2.2.3 검색된 패키지 설치
[root@localhost ~]# yum install httpd php mysql mysql-server php-mysql system-config-httpd Setting up Install Process Setting up repositories updates-released 100% |=========================| 951 B 00:00 extras 100% |=========================| 1.1 kB 00:00 ..... ..... ..... --> Running transaction check
Dependencies Resolved
============================================================================= Package Arch Version Repository Size ============================================================================= Installing: httpd i386 2.0.54-10.4 updates-released 947 k mysql i386 4.1.20-1.FC4.1 updates-released 2.9 M mysql-server i386 4.1.20-1.FC4.1 updates-released 9.8 M php i386 5.0.4-10.5 updates-released 2.3 M php-mysql i386 5.0.4-10.5 updates-released 60 k system-config-httpd noarch 5:2.3.2-2 base 504 k Installing for dependencies: 4Suite i386 1.0-8.b1 base 3.5 M apr i386 0.9.6-3.5 updates-released 105 k apr-util i386 0.9.6-2 base 56 k perl-DBD-MySQL i386 2.9007-1 base 140 k perl-DBI i386 1.48-4 base 571 k php-pear i386 5.0.4-10.5 updates-released 371 k
Transaction Summary ============================================================================= Install 12 Package(s) Update 0 Package(s) Remove 0 Package(s) Total download size: 21 M Is this ok [y/N]: y Downloading Packages: ..... ..... ..... Importing GPG key 0x4F2A6FD2 "Fedora Project <fedora@redhat.com>" Is this ok [y/N]: y Key imported successfully Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing: perl-DBI ####################### [ 1/12] Installing: mysql ####################### [ 2/12] Installing: apr ####################### [ 3/12] Installing: apr-util ####################### [ 4/12] Installing: httpd ####################### [ 5/12] Installing: php ####################### [ 6/12] Installing: perl-DBD-MySQL ####################### [ 7/12] Installing: 4Suite ####################### [ 8/12] Installing: php-mysql ####################### [ 9/12] Installing: php-pear ####################### [10/12] Installing: system-config-httpd ####################### [11/12] Installing: mysql-server ####################### [12/12]
Installed: httpd.i386 0:2.0.54-10.4 mysql.i386 0:4.1.20-1.FC4.1 mysql-server.i386 0:4.1.20-1.FC4.1 php.i386 0:5.0.4-10.5 php-mysql.i386 0:5.0.4-10.5 system-config-httpd.noarch 5:2.3.2-2 Dependency Installed: 4Suite.i386 0:1.0-8.b1 apr.i386 0:0.9.6-3.5 apr-util.i386 0:0.9.6-2 perl-DBD-MySQL.i386 0:2.9007-1 perl-DBI.i386 0:1.48-4 php-pear.i386 0:5.0.4-10.5 Complete! [root@localhost ~]# |
* 웹 서버 패키지 설치 후 만들어지는 주요 파일
/usr/sbin/httpd 웹 서버 데몬 본체
/etc/rc.d/init.d/httpd 웹 서버 데몬을 제어하기 위한 스크립트
/etc/httpd/conf/httpd.conf 웹 서버 환경설정 파일
/var/log/httpd 웹서버 로그 파일
/var/www/html Document Root 디렉토리
2.3 설치 후 설정
2.3.1 웹 서버 데몬 실행
[root@localhost ~]# /etc/rc.d/init.d/httpd start httpd (을)를 시작합니다: [ 확인 ] [root@localhost ~]# |
2.3.2 웹서버 데몬 확인
[root@localhost ~]# ps -ef | grep httpd root 2234 1 0 19:30 ? 00:00:00 /usr/sbin/httpd apache 2236 2234 0 19:30 ? 00:00:00 /usr/sbin/httpd apache 2237 2234 0 19:30 ? 00:00:00 /usr/sbin/httpd apache 2238 2234 0 19:30 ? 00:00:00 /usr/sbin/httpd apache 2240 2234 0 19:30 ? 00:00:00 /usr/sbin/httpd apache 2241 2234 0 19:30 ? 00:00:00 /usr/sbin/httpd apache 2242 2234 0 19:30 ? 00:00:00 /usr/sbin/httpd apache 2243 2234 0 19:30 ? 00:00:00 /usr/sbin/httpd apache 2244 2234 0 19:30 ? 00:00:00 /usr/sbin/httpd root 2286 1901 0 19:34 pts/1 00:00:00 grep httpd [root@localhost ~]# |
2.3.3 부팅 후 서버 바로 시작하도록 설정
[root@localhost ~]# chkconfig --list | grep httpd httpd 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제 [root@localhost ~]# chkconfig httpd on [root@localhost ~]# chkconfig --list | grep httpd httpd 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제 [root@localhost ~]# |
2.3.4 방화벽 설정
웹 서비스는 리눅스 서버의 80번 포트, tcp 프로토콜을 통해 서비스한다. 리눅스 서버는 방화벽을 통해 이에 대한 접근을 제한하고 있기 때문에 iptables 명령으로 웹 서비스에 대한 접근을 허가 해야한다.
[root@localhost ~]# iptables -I INPUT -p tcp --dport 80 -j ACCEPT [root@localhost ~]# iptables -L Chain FORWARD (policy ACCEPT) target prot opt source destination
Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT tcp -- anywhere anywhere tcp dpt:http
Chain OUTPUT (policy ACCEPT) target prot opt source destination [root@localhost ~]# |
2.3.5 방화벽 설정 저장
[root@localhost ~]# /etc/rc.d/init.d/iptables save 방화벽 규칙현 규칙들을 /etc/sysconfig/iptables에 저장합니다[ 확인 ] [root@localhost ~]# |
2.3.6 MySQL 데몬 실행
[root@localhost ~]# /etc/rc.d/init.d/mysqld start MySQL 데이타베이스를 초기화 하고 있습니다: Installing all prepared tables
To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /usr/bin/mysqladmin -u root password 'new-password' /usr/bin/mysqladmin -u root -h localhost password 'new-password' See the manual for more instructions.
You can start the MySQL daemon with: cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory: cd sql-bench ; perl run-all-tests
Please report any problems with the /usr/bin/mysqlbug script!
The latest information about MySQL is available on the web at http://www.mysql.com Support MySQL by buying support/licenses at http://shop.mysql.com [ 확인 ] MySQL (을)를 시작합니다: [ 확인 ] [root@localhost ~]# |
2.3.7 MySQL 데몬 확인
[root@localhost ~]# ps -ef | greap mysqld bash: greap: command not found [root@localhost ~]# ps -ef | grep mysqld root 2762 1 0 20:09 pts/1 00:00:00 /bin/sh /usr/bin/mysqld_safe --defaults-file=/etc/my.cnf --pid-file=/var/run/mysqld/mysqld.pid mysql 2795 2762 1 20:09 pts/1 00:00:00 /usr/libexec/mysqld --defaults-file=/etc/my.cnf --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-locking --socket=/var/lib/mysql/mysql.sock root 2825 1901 0 20:11 pts/1 00:00:00 grep mysqld [root@localhost ~]# |
2.3.8 MySQL 루트 비밀번호 설정
[root@localhost ~]# mysqladmin -u root password '******' [root@localhost ~]# |
2.3.9 MySQL 접속 확인
[root@localhost ~]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 to server version: 4.1.20
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> |
2.3.10 서버 시작시 MySQL 자동 실행되도록 설정
[root@localhost ~]# chkconfig --list mysqld mysqld 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제 [root@localhost ~]# chkconfig mysqld on [root@localhost ~]# chkconfig --list mysqld mysqld 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제 [root@localhost ~]# |
2.4 아파치 설정 파일(httpd.conf) 수정
2.4.1 index.php를 디렉토리 인덱스 파일로 사용하도록 설정
//index.php를 디렉토리 인덱스 파일로 사용하기 위해 httpd.conf파일 수정
# # DirectoryIndex: sets the file that Apache will serve if a directory # is requested. # # The index.html.var file (a type-map) is used to deliver content- # negotiated documents. The MultiViews Option can be used for the # same purpose, but it is much slower. # DirectoryIndex index.php index.html index.html.var |
2.4.2 확장자가 php, phtml, php3인 파일은 php로 인식 하도록 설정
# AddType allows you to add to or override the MIME configuration # file mime.types for specific file types. # #AddType application/x-tar .tgz AddType application/x-httpd-php .php .phtml .php3 AddType application/x-httpd-php-source .phps |
2.4.3 설정된 내용 반영하기 위해 웹 서버 재시작
[root@localhost ~]# /etc/rc.d/init.d/httpd restart httpd 를 정지함: [ 확인 ] httpd (을)를 시작합니다: [ 확인 ] [root@localhost ~]# |
2.5 APM 설치 확인
2.5.1 소스파일
<? echo "홍종민이 구축한 서버가 정상 작동하고 있습니다"; phpinfo(); ?> |
2.5.2 테스트 화면
3. FTP 서버 설치
네트워크를 통해 파일을 공유할 때는 FTP 서비스를 이용한다. 사용자는 FTP 클라이언트를 이용하여 인터넷에서 FTP 서버에 접속하고 FTP 서버가 제공하는 파일을 이용 할 수 있다.
FTP 서비스를 살펴보면 FTP 클라이트가 리눅스 서버의 21번 포트(명령포트)로 FTP 서비스를 요청하는데 이 과정에서 실제 데이터를 전송할 클라이언트의 포트번호를 서버에게 알린다. FTP 서버는 접속 여부를 결정하고 FTP 허가 메시지를 보내고 20번 포트(데이터 포트)로 클라이언트에서 제공받은 데이터 전송 포트로 접속한다. 접속이 성공하면 리눅스 서버와 클라이언트 간에 연결된 데이터 통로를 통해 파일을 전송 할 수 있게 된다.
3.1 Proftp 설치
3.1.1 Proftp 설치
[root@localhost /]# yum install proftpd ....... Installed : proftpd-1.3.0-6.fc4 Complete! [root@localhost /]# |
3.1.2 Proftp 설치 확인
[root@localhost /]# rpm -qa | grep ftp ftp-0.17-26 proftpd-1.3.0-6.fc4 tftp-server-0.17-9 lftp-3.1.3-1 [root@localhost /]# |
3.1.3 proftpd.conf 파일 설정 변경
# This is the ProFTPD configuration file # $Id: proftpd.conf,v 1.1 2004/02/26 17:54:30 thias Exp $
ServerName "zzru" ServerIdent on "Zzru의 개인 서버 입니다" ServerAdmin tabbi@naver.com ServerType standalone #ServerType inetd DefaultServer on AccessGrantMsg "%u 님 어서 오세요" #DisplayConnect /etc/ftpissue #DisplayLogin /etc/ftpmotd #DisplayGoAway /etc/ftpgoaway DeferWelcome off |
3.1.4 ProFTPd 서버 데몬 실행
[root@localhost /]# /etc/rc.d/init.d/proftpd start proftpd (을)를 시작합니다: [ 확인 ] [root@localhost /]# |
3.2 Proftp 설치 후 설정 변경
3.2.1 부팅시 Proftp 자동 실행 되도록 활성화
[root@localhost /]# chkconfig --list | grep proftp proftpd 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제 xproftpd: 해제 [root@localhost /]# chkconfig proftpd on [root@localhost /]# chkconfig --list | grep proftp proftpd 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제 xproftpd: 해제 [root@localhost /]# |
3.2.2 방화벽에서 21번 포트 허용
[root@localhost /]# iptables -I INPUT -p tcp --dport 21 -j ACCEPT [root@localhost /]# iptables -L Chain FORWARD (policy ACCEPT) target prot opt source destination
Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT tcp -- anywhere anywhere tcp dpt:ftp ACCEPT tcp -- anywhere anywhere tcp dpt:http
Chain OUTPUT (policy ACCEPT) target prot opt source destination [root@localhost /]# /etc/rc.d/init.d/iptables save 방화벽 규칙현 규칙들을 /etc/sysconfig/iptables에 저장합니다[ 확인 ] [root@localhost /]# |
3.2.3 FTP 테스트 화면
'자료실 > 기타잡다지식' 카테고리의 다른 글
키보드 자판 타입 (0) | 2007.08.08 |
---|---|
인터넷 익스플로러 동시 다운로드 갯수 늘리기 (1) | 2007.07.07 |
정보보안 (0) | 2007.06.12 |
C언어 - 윤년 구하는 공식.. (0) | 2007.04.24 |
간단한 오라클 명령어 (0) | 2007.04.18 |