Dico

Apache yum Install

  • 민갤

환경: CentOS7.5 Minimal

CentOS minimal은 httpd가 설치되어 있지 않다.

확인

설치되어 있지 않을 경우

# rpm -qa httpd
# yum list httpd
(... skip ...)
Available Packages
httpd.x86_64                                2.4.6-80.el7.centos.1                                updates

설치되어 있을 경우

# rpm -qa httpd
httpd-2.4.6-80.el7.centos.1.x86_64
# yum list httpd
(... skip ...)
Installed Packages
httpd.x86_64                                2.4.6-80.el7.centos.1                                @updates

설치

# yum -y install httpd
(... skip ...)
Installed:
  httpd.x86_64 0:2.4.6-80.el7.centos.1

Dependency Installed:
  apr.x86_64 0:1.4.8-3.el7_4.1                 apr-util.x86_64 0:1.5.2-6.el7            
  httpd-tools.x86_64 0:2.4.6-80.el7.centos.1    mailcap.noarch 0:2.1.41-2.el7             

Complete!

서비스

systemctl [start|stop|restart|status...] [SERVICE_NAME].service

  • systemctl = /usr/bin/systemctl


시작

# systemctl start httpd.service

중지

# systemctl stop httpd.service

재시작

# systemctl restart httpd.service

상태 확인

# systemctl status httpd.service

- 정상 실행 시 Artive: active (running) 표시

부팅 시 자동 실행하기

# systemctl enable httpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service



구동

기본 설정

  • ServerName 설정 : 서버의 도메인 또는 IP 지정
# vi /etc/httpd/conf/httpd.conf
(... skip ...)
89 # ServerName gives the name and port that the server uses to identify itself.
90 # This can often be determined automatically, but we recommend you specify
91 # it explicitly to prevent problems during startup.
92 #
93 # If your host doesn't have a registered DNS name, enter its IP address here.
94 #
95 #ServerName www.example.com:80
96 ServerName localhost:80
(... skip ...)

- IP로 설정할 경우 해당 IP로 지정

# hostname -I
10.0.2.15

방화벽 설정

  • 서비스 추가
# firewall-cmd --permanent --zone=public --add-service=http
success
# firewall-cmd --permanent --zone=public --add-service=https
success
  • 포트 추가
# firewall-cmd --permanent --zone=public --add-port=80/tcp
success
# firewall-cmd --permanent --zone=public --add-port=443/tcp
success

SELINUX 해제

# vi /etc/selinux/config
1
2 # This file controls the state of SELinux on the system.
3 # SELINUX= can take one of these three values:
4 #     enforcing - SELinux security policy is enforced.
5 #     permissive - SELinux prints warnings instead of enforcing.
6 #     disabled - No SELinux policy is loaded.
7 SELINUX=disabled
8 # SELINUXTYPE= can take one of three two values:
9 #     targeted - Targeted processes are protected,
10 #     minimum - Modification of targeted policy. Only selected processes are protected.
11 #     mls - Multi Level Security protection.
12 SELINUXTYPE=targeted

네트워크 확인

# cat /etc/sysconfig/network-scripts/ifcfg-enp0s3
(... skip ...)
ONBOOT=yes

재시작

# reboot

가상머신의 웹호스트 접근

  • 가상머신 설정 > 네트워크 > 고급 > 포트 포워딩
이름프로토콜호스트 IP호스트 포트게스트 IP게스트 포트
WEBTCP8080

웹호스트 접속

  • http://localhost:80

아파치

버전 확인

# httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built:   Jun 27 2018 13:48:59