
서버로서 가장 기본적인 것이 웹서버로서의 동작이다.
이를 위해서는 HTTP 데몬인 Apache2 가 가장 기본적으로 필요하며,
여기에 추가로 데이터베이스 서버인 MySQL이나 Oracle이, 그리고 Server Side 언어인 PHP도 필요하다.
오늘은 데비안에(Base System과 WebServer 항목만 선택하고 설치한 경우)
마피아(MySQL+PHP+Apache 의 앞글자를 줄여서 일컫는 말)를 설치하고 동작시키는 과정을 기록할랜다.
1. Installing Package
필요한 패키지들은 다음과 같다.
apache2
apache2.2-common
libapache-mod-php5
php5
php5-common
php5-gd
php5-mysql
mysql-server
libdbd-mysql-perl
mysql-client-5.0
mysql-common
libdbi-perl
apache2.2-common
libapache-mod-php5
php5
php5-common
php5-gd
php5-mysql
mysql-server
libdbd-mysql-perl
mysql-client-5.0
mysql-common
libdbi-perl
일단 관리자 계정으로 로그인 한 뒤에 위의 파일들중에 설치된 것이 있나 찾아보자
아파치는?
debian:/home/me# dpkg -l | grep apache
ii apache2-doc 2.2.3-4+etch4 documentation for apache2
ii apache2-mpm-prefork 2.2.3-4+etch4 Traditional model for Apache HTTPD 2.1
ii apache2-utils 2.2.3-4+etch4 utility programs for webservers
ii apache2.2-common 2.2.3-4+etch4 Next generation, scalable, extendable web se
ii libapache2-mod-perl2 2.0.2-2.4 Integration of perl with the Apache2 web ser
ii libapache2-mod-php5 5.2.0-8+etch10 server-side, HTML-embedded scripting languag
ii libapache2-mod-python 3.2.10-4 Apache 2 module that embeds Python within th
ii apache2-doc 2.2.3-4+etch4 documentation for apache2
ii apache2-mpm-prefork 2.2.3-4+etch4 Traditional model for Apache HTTPD 2.1
ii apache2-utils 2.2.3-4+etch4 utility programs for webservers
ii apache2.2-common 2.2.3-4+etch4 Next generation, scalable, extendable web se
ii libapache2-mod-perl2 2.0.2-2.4 Integration of perl with the Apache2 web ser
ii libapache2-mod-php5 5.2.0-8+etch10 server-side, HTML-embedded scripting languag
ii libapache2-mod-python 3.2.10-4 Apache 2 module that embeds Python within th
위의 패키지만 있어도 동작은 하지만 apache2 패키지를 추가로 설치해주자
debian:/home/me# aptitude install apache2
Reading package lists... Done
Building dependency tree... Done
Reading extended state information
Initializing package states... Done
Reading task descriptions... Done
Building tag database... Done
The following NEW packages will be installed:
apache2
0 packages upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 41.4kB of archives. After unpacking 65.5kB will be used.
Writing extended state information... Done
Get:1 http://ftp.kr.debian.org etch/main apache2 2.2.3-4+etch4 [41.4kB]
Fetched 41.4kB in 2s (15.0kB/s)
Selecting previously deselected package apache2.
(Reading database ... 21223 files and directories currently installed.)
Unpacking apache2 (from .../apache2_2.2.3-4+etch4_all.deb) ...
Setting up apache2 (2.2.3-4+etch4) ...
Reading package lists... Done
Building dependency tree... Done
Reading extended state information
Initializing package states... Done
Reading task descriptions... Done
Building tag database... Done
The following NEW packages will be installed:
apache2
0 packages upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 41.4kB of archives. After unpacking 65.5kB will be used.
Writing extended state information... Done
Get:1 http://ftp.kr.debian.org etch/main apache2 2.2.3-4+etch4 [41.4kB]
Fetched 41.4kB in 2s (15.0kB/s)
Selecting previously deselected package apache2.
(Reading database ... 21223 files and directories currently installed.)
Unpacking apache2 (from .../apache2_2.2.3-4+etch4_all.deb) ...
Setting up apache2 (2.2.3-4+etch4) ...
aptitude install 명령뒤에는 정확한 패키지명을 명시해줘야 하는데
패키지명을 찾으려면 aptitude search 검색어 로 찾으면 된다.
같은 방식으로 다른 패키지들도 전부 설치해준다.
apache2 같은경우 별다른 configuration 없이도 설치한뒤에 http://IP Address 로 접속을 하면
동작여부를 확인할 수 있다. It Works! 라고 뜨면 성공이다.
설치중에 데비안 에치 설치 시디를 요구하는 경우도 있는데
직접 시디를 넣든지 데비안 iso 이미지를 업로드해서 다음과 같은 명령으로 마운트 시키자
#mount debian-40r3-i386-netinst.iso /cdrom -t iso9660 -o loop
2. Configuration
모든 파일이 설치되었으면 이제 각 패키지간에 연동할 수 있도록 설정해줄 차례이다.
Apache2 부터 시작한다.
데비안에서 각종 설정파일은 대부분 /etc 안에 존재를 하며 Apache2 도 예외는 아니다.
debian:/home/me# vim /etc/apache2/apache2.conf
위의 명령으로 파일을 열어서#AddHandler cgi-script .cgi
부분의 주석 '#'을 제거하자.그뒤에 /etc/apache2/sites-available/default 파일을 열어서 ExecCGI를 추가해주고, 리다이렉션 부분은 주석처리 한다.
Options Indexes FollowSymLinks MultiViews ExecCGI
#RedirectMatch ^/$ /apache2-default/
#RedirectMatch ^/$ /apache2-default/
사용가능한 확장자를 추가하기 위해 /etc/apache2/mods-enabled/php5.conf 를 열어서
확장자를 추가해준다. inc, html, htm 정도면 일반적으로는 문제없다.
AddType application/x-httpd-php .php .phtml .php3 .html .htm .inc
다음으로 아파치 데몬을 재시작 해준다.debian:/etc/apache2# /etc/init.d/apache2 restart
Forcing reload of web server (apache2)...apache2: Could not reliably determine the server's fully qualified domain name, using x for ServerName
httpd (no pid file) not running
apache2: Could not reliably determine the server's fully qualified domain name, using x for ServerName
.
Forcing reload of web server (apache2)...apache2: Could not reliably determine the server's fully qualified domain name, using x for ServerName
httpd (no pid file) not running
apache2: Could not reliably determine the server's fully qualified domain name, using x for ServerName
.
여기까지 했으면 잘 돌아가는지 테스트를 해보자.
debian:/etc/apache2# vim /var/www/phpinfo.php
위의 명령을 통해서 웹문서 루트에 다음 내용을 가진 phpinfo.php 파일을 만들어주고,<?
phpinfo();
?>
웹으로 접속을 해보자 http://서버아이피/phpinfo.phpphpinfo();
?>
접속했을때 php의 정보를 보여주는 웹문서가 보이면 성공이다.
more..
MySQL에 사용자와 데이터베이스를 추가하는 방법은 다음에...

















