Apache http 서버 구축 – #1. 설치

HTTP 데몬(HTTP Daemon), 즉 httpd는 웹 서버의 백그라운드에서 실행되어, 들어오는 서버 요청을 대기하는 소프트웨어 프로그램이다. 이 데몬은 자동으로 요청에 응답하며 HTTP를 사용하여 인터넷을 경유, 하이퍼텍스트, 멀티미디어 문서들을 서비스한다. HTTPd는 HTTP daemon의 준말이다. (예: 웹 서버)

yum 명령으로 패키지를 설치한다.

[root@class14 ~]# yum install -y httpd
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
epel/x86_64/metalink                                                                                                                                                                | 2.8 kB  00:00:00
 * base: mirror.kakao.com
 base                                                                                                                                                                                | 3.6 kB  00:00:00
(1/7): base/7/x86_64/group_gz                                                                                                                                                       | 153 kB  00:00:00
중략
(7/7): epel/x86_64/primary_db                                                                                                                                                       | 6.9 MB  00:00:03
Resolving Dependencies
--> Running transaction check
중략
---> Package httpd.x86_64 0:2.4.6-93.el7.centos will be an update
--> Processing Dependency: httpd-tools = 2.4.6-93.el7.centos for package: httpd-2.4.6-93.el7.centos.x86_64
--> Running transaction check
---> Package httpd-devel.x86_64 0:2.4.6-80.el7.centos will be updated
중략--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================================================================================
 Package                                           Arch                                        Version                                                     Repository                                 Size
===========================================================================================================================================================================================================
Updating:
 httpd                                             x86_64                                      2.4.6-93.el7.centos                                         base                                      2.7 M
Updating for dependencies:
 httpd-devel                                       x86_64                                      2.4.6-93.el7.centos                                         중략
Transaction Summary
===========================================================================================================================================================================================================
Upgrade  1 Package (+4 Dependent packages)

Total download size: 4.4 M
Downloading packages:
No Presto metadata available for base
(1/5): httpd-devel-2.4.6-93.el7.centos.x86_64.rpm                                                                                                                                   | 198 kB  00:00:00
중략
(5/5): httpd-2.4.6-93.el7.centos.x86_64.rpm                                                                                                                                         | 2.7 MB  00:00:00
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                       19 MB/s | 4.4 MB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : httpd-tools-2.4.6-93.el7.centos.x86_64                                                                                                                                                 1/10
중략
  Verifying  : httpd-manual-2.4.6-80.el7.centos.noarch                                                                                                                                               10/10
Updated:
  httpd.x86_64 0:2.4.6-93.el7.centos
Dependency Updated:
  httpd-devel.x86_64 0:2.4.6-93.el7.centos           httpd-manual.noarch 0:2.4.6-93.el7.centos           httpd-tools.x86_64 0:2.4.6-93.el7.centos           mod_ssl.x86_64 1:2.4.6-93.el7.centos
Complete!
[root@class14 ~]# rpm -qa | grep httpd
httpd-manual-2.4.6-93.el7.centos.noarch
httpd-2.4.6-93.el7.centos.x86_64
httpd-tools-2.4.6-93.el7.centos.x86_64
httpd-devel-2.4.6-93.el7.centos.x86_64

서비스 구동

 # 별도의 설정 없이 구동을 하면 기본 값으로 실행된다.
[root@class14 ~]# service start httpd
Redirecting to /bin/systemctl start httpd.service
 # 또는
[root@class14 ~]# systemctl start httpd.service

서비스 구동 확인

[root@class14 ~]# netstat -nltp | grep 80
tcp6       0      0 :::80                   :::*                    LISTEN      2411/httpd
 # 또는
[root@class14 ~]# netstat -nltp | grep httpd
tcp6       0      0 :::80                   :::*                    LISTEN      2411/httpd
tcp6       0      0 :::443                  :::*                    LISTEN      2411/httpd
[root@class14 ~]#
웹브라우저로 접속 성공한 모습.

접속이 안될 경우
※ 다양한 원인이 있을 수 있으나 linux 방화벽 (iptables, firewalld)에 의해 막히는 경우가 많다.

[root@class14 ~]# service firewalld stop
Redirecting to /bin/systemctl stop firewalld.service
 # 또는
[root@class14 ~]# service iptables stop
 # CentOS6 이하, CentOS7 이상에서 firewalld 를 삭제하고 iptables를 구동 했을 때