아파치는 PHP를 단독으로 사용할 경우에 주로 사용한다.

JAVA를 이용할 경우 Tomcat에 부하를 줄여주기 위해 아파치와 연동해서 사용하기도 한다.


1. yum 명령어를 이용하여 apache를 설치한다.

[root@localhost soo]# yum install httpd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * remi-safe: mirror.neolabs.kz
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-67.el7.centos.6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================
 Package           Arch               Version                              Repository           Size
=====================================================================================================
Installing:
 httpd             x86_64             2.4.6-67.el7.centos.6                updates             2.7 M

Transaction Summary
=====================================================================================================
Install  1 Package

Total download size: 2.7 M
Installed size: 9.4 M
Is this ok [y/d/N]: y
Downloading packages:
httpd-2.4.6-67.el7.centos.6.x86_64.rpm                                        | 2.7 MB  00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : httpd-2.4.6-67.el7.centos.6.x86_64                                                1/1
  Verifying  : httpd-2.4.6-67.el7.centos.6.x86_64                                                1/1

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

Complete!
[root@localhost soo]#


2. Apache를 실행한다. (service httpd start)
[root@localhost soo]# service httpd start
Redirecting to /bin/systemctl start httpd.service
[root@localhost soo]#

3. 정상적으로 실행되었는지 상태를 확인한다. (service httpd status)


[root@localhost soo]# service httpd status
Redirecting to /bin/systemctl status httpd.service
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2018-01-18 22:47:33 EST; 2min 28s ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 1574 (httpd)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
   CGroup: /system.slice/httpd.service
           ├─1574 /usr/sbin/httpd -DFOREGROUND
           ├─1575 /usr/sbin/httpd -DFOREGROUND
           ├─1576 /usr/sbin/httpd -DFOREGROUND
           ├─1577 /usr/sbin/httpd -DFOREGROUND
           ├─1578 /usr/sbin/httpd -DFOREGROUND
           └─1579 /usr/sbin/httpd -DFOREGROUND

Jan 18 22:47:33 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...
Jan 18 22:47:33 localhost.localdomain httpd[1574]: AH00558: httpd: Could not reliably determine ...ge
Jan 18 22:47:33 localhost.localdomain systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost soo]#


4. 서버 재부팅시 자동으로 실행되도록 서비스 활성화 등록을 해놓는다.


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


5. 웹브라우저 주소창에 localhost를 입력하여 잘 구동되는지를 확인한다.


6. PHP를 사용할 경우 info.php 파일을 만들어 서버의 root에 넣고 확인해본다. (사전에 php설치가 되어있는 경우)

   1) httpd의 root로 이동

[root@localhost html]# cd /var/www/html

   2) info.php 파일을 만든다.
[root@localhost html]# vi  info.php

   3) 시스템 정보를 가져오는 php 함수만 입력한다.


   위 내용만 키보드의 i 를 치고 입력 후 :wq (저장후 나옴) 입력하고 나온다.

7. 웹브라우저에 http://localhost/info.php 를 입력해서 확인한다.



만족하셨나요? ~~~~~~~


+ Recent posts