관리 메뉴

리눅스 CentOS7 httpd 설치 방법 본문

리눅스/Linux 공부내용

리눅스 CentOS7 httpd 설치 방법

ª_ª 2023. 3. 11. 10:04
728x90
반응형

 

 

 

1. httpd 설치

- 명령어 : yum install httpd -y

[root@localhost ~]# yum install httpd -y
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: mirror.navercorp.com
 * extras: mirror.navercorp.com
 * updates: mirror.kakao.com
base                                                                                                                                   | 3.6 kB  00:00:00
extras                                                                                                                                 | 2.9 kB  00:00:00
updates                                                                                                                                | 2.9 kB  00:00:00
updates/7/x86_64/primary_db                                                                                                            |  20 MB  00:00:00
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-98.el7.centos.6 will be installed
--> Processing Dependency: httpd-tools = 2.4.6-98.el7.centos.6 for package: httpd-2.4.6-98.el7.centos.6.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-98.el7.centos.6.x86_64
--> Running transaction check
---> Package httpd-tools.x86_64 0:2.4.6-98.el7.centos.6 will be installed
---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================================
 Package                              Arch                            Version                                          Repository                        Size
==============================================================================================================================================================
Installing:
 httpd                                x86_64                          2.4.6-98.el7.centos.6                            updates                          2.7 M
Installing for dependencies:
 httpd-tools                          x86_64                          2.4.6-98.el7.centos.6                            updates                           94 k
 mailcap                              noarch                          2.1.41-2.el7                                     base                              31 k

Transaction Summary
==============================================================================================================================================================
Install  1 Package (+2 Dependent packages)

Total download size: 2.8 M
Installed size: 9.6 M
Downloading packages:
(1/3): httpd-tools-2.4.6-98.el7.centos.6.x86_64.rpm                                                                                    |  94 kB  00:00:00
(2/3): mailcap-2.1.41-2.el7.noarch.rpm                                                                                                 |  31 kB  00:00:00
(3/3): httpd-2.4.6-98.el7.centos.6.x86_64.rpm                                                                                          | 2.7 MB  00:00:00
--------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                         6.1 MB/s | 2.8 MB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mailcap-2.1.41-2.el7.noarch                                                                                                                1/3
  Installing : httpd-tools-2.4.6-98.el7.centos.6.x86_64                                                                                                   2/3
  Installing : httpd-2.4.6-98.el7.centos.6.x86_64                                                                                                         3/3
  Verifying  : httpd-tools-2.4.6-98.el7.centos.6.x86_64                                                                                                   1/3
  Verifying  : mailcap-2.1.41-2.el7.noarch                                                                                                                2/3
  Verifying  : httpd-2.4.6-98.el7.centos.6.x86_64                                                                                                         3/3

Installed:
  httpd.x86_64 0:2.4.6-98.el7.centos.6

Dependency Installed:
  httpd-tools.x86_64 0:2.4.6-98.el7.centos.6                                           mailcap.noarch 0:2.1.41-2.el7

Complete!

 

2. httpd 서비스 시작

- 명령어 : systemctl start httpd

[root@localhost ~]# systemctl start httpd
[root@localhost ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since 목 2023-03-09 23:59:36 KST; 1s ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 1925 (httpd)
   Status: "Processing requests..."
   CGroup: /system.slice/httpd.service
           ├─1925 /usr/sbin/httpd -DFOREGROUND
           ├─1926 /usr/sbin/httpd -DFOREGROUND
           ├─1927 /usr/sbin/httpd -DFOREGROUND
           ├─1928 /usr/sbin/httpd -DFOREGROUND
           ├─1929 /usr/sbin/httpd -DFOREGROUND
           └─1930 /usr/sbin/httpd -DFOREGROUND

 3월 09 23:59:36 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...
 3월 09 23:59:36 localhost.localdomain httpd[1925]: AH00558: httpd: Could not reliably determine the serv
 3월 09 23:59:36 localhost.localdomain systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost ~]#

 

3. httpd 서비스 자동 시작 설정하기

- 서버를 재시작하거나 다시 시작할 때마다 

   httpd 서비스를 수동으로 시작할 필요 없이 자동으로 시작하도록 설정할 수 있습니다.
- 명령어 : systemctl enable httpd

[root@localhost conf]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

 

4. httpd 구성파일 수정하기

- httpd 구성 파일을 수정하여 웹 서버를 자신의 요구에 맞게 설정할 수 있습니다. 
- 예를 들어, 기본 웹 페이지의 경로를 변경하려면 

   아래 경로의 파일의 DocumentRoot 경로를 원하는 경로로 변경합니다.
- DocumentRoot "/var/www/html"
- 명령어 : vi /etc/httpd/conf/httpd.conf

vi /etc/httpd/conf/httpd.conf

115 # DocumentRoot: The directory out of which you will serve your
116 # documents. By default, all requests are taken from this directory, but
117 # symbolic links and aliases may be used to point to other locations.
118 #
119 DocumentRoot "/var/www/html"
120
121 #
122 # Relax access to content within /var/www.

 

5. 방화벽에서 httpd  포트 열기

- CentOS 7에서는 방화벽이 기본적으로 활성화되어 있으므로,

   httpd를 사용하려면 방화벽에서 httpd 포트를 열어야 합니다.
- 명령어 : firewall-cmd --permanent --add-service=http
- 명령어 : firewall-cmd --reload

[root@localhost conf]# firewall-cmd --permanent --add-service=http
success
[root@localhost conf]# firewall-cmd --reload
success

 

6. 웹브라우저에서 접속

- 명령어 : http://192.168.1.2(서버의 IP주소) or http://localhost

 

 

 

728x90
반응형
Comments