리눅스마스터1급 : APM 시작 및 테스트
작성자 정보
- 관리자 작성
- 작성일
컨텐츠 정보
- 3,107 조회
- 0 추천
- 목록
본문
리눅스마스터1급 : APM 시작 및 테스트
지금까지 아파치 웹서버에 PHP, MySQL을 연동설치하였고, 설정파일에 대해 알아 보았다.
이제 아파치 웹서버를 시작해 보도록 하겠다.
앞에서 언급한 방법대로 아파치 웹서버를 설치하였다면, 다음과 같은 명령어로 아파치를 시작, 종료, 재시작등을 할 수 있다.
① 아파치 웹서버 시작
|
|
|
| [root@SULinux-64Bit bin]# /usr/local/apache/bin/apachectl start |
|
|
|
|
위와 같이 입력하면, 아파치 웹서버가 시작된다.
apachectl 프로그램은 다음과 같은 옵션을 가지며, 시작, 정지, 설정파일 점검등의 기능을 수행한다.
|
|
|
| apachectl (start|stop|restart|fullstatus|status|graceful|configtest|help) |
|
|
|
|
▸start : 아파치를 시작한다.
[root@RockyLinux01 ~]# systemctl start httpd [root@RockyLinux01 ~]# [root@RockyLinux01 ~]# ps -ef | grep httpd root 1845 1 0 09:50 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND apache 1847 1845 0 09:50 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND apache 1848 1845 0 09:50 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND apache 1849 1845 0 09:50 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND apache 1850 1845 0 09:50 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND apache 1851 1845 0 09:50 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND root 1899 1778 0 09:50 pts/0 00:00:00 grep --color=auto httpd [root@RockyLinux01 ~]# |
▸stop : 아파치실행을 종료한다.
[root@RockyLinux01 ~]# systemctl stop httpd [root@RockyLinux01 ~]# [root@RockyLinux01 ~]# [root@RockyLinux01 ~]# ps -ef | grep httpd root 1905 1778 0 09:50 pts/0 00:00:00 grep --color=auto httpd [root@RockyLinux01 ~]# |
▸restart : 아파치를 재시작한다.
[root@RockyLinux01 ~]# systemctl restart httpd [root@RockyLinux01 ~]# [root@RockyLinux01 ~]# ps -ef | grep httpd root 1908 1 0 09:51 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND apache 1909 1908 0 09:51 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND apache 1910 1908 0 09:51 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND apache 1911 1908 0 09:51 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND apache 1912 1908 0 09:51 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND apache 1913 1908 0 09:51 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND root 1956 1778 0 09:51 pts/0 00:00:00 grep --color=auto httpd [root@RockyLinux01 ~]# |
▸fullstatus : 아파치 실행상태를 자세하게보여준다.
(lynx 와 mod_status가 설치되어야 한다.)
▸status : 아파치 실행상태를 간단하게 보여 준다.
[root@RockyLinux01 ~]# systemctl status httpd ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Drop-In: /usr/lib/systemd/system/httpd.service.d └─php-fpm.conf Active: active (running) since Fri 2023-06-16 09:51:14 KST; 41s ago Docs: man:httpd.service(8) Main PID: 1908 (httpd) Status: "Total requests: 0; Idle/Busy workers 100/0;Requests/sec: 0; Bytes served/sec: 0 B/sec" Tasks: 47 (limit: 12195) Memory: 30.7M CPU: 192ms CGroup: /system.slice/httpd.service ├─1908 /usr/sbin/httpd -DFOREGROUND ├─1909 /usr/sbin/httpd -DFOREGROUND ├─1910 /usr/sbin/httpd -DFOREGROUND ├─1911 /usr/sbin/httpd -DFOREGROUND ├─1912 /usr/sbin/httpd -DFOREGROUND └─1913 /usr/sbin/httpd -DFOREGROUND
6월 16 09:51:14 RockyLinux01 systemd[1]: Starting The Apache HTTP Server... 6월 16 09:51:14 RockyLinux01 httpd[1908]: AH00558: httpd: Could not reliably determine the server's fully qualified do> 6월 16 09:51:14 RockyLinux01 systemd[1]: Started The Apache HTTP Server. 6월 16 09:51:14 RockyLinux01 httpd[1908]: Server configured, listening on: port 80 [root@RockyLinux01 ~]# |
(lynx 와 mod_status가 설치되어야 한다.)
▸graceful : 아파치를 graceful모드로 재시작한다.
▸configtest : 아파치 설정파일(httpd.conf)의 문법(syntax)을 검사한다. )
▸help : 도움말을 보여준다.
② 아파치 웹 서버 작동확인
ⓐ apachectl 명령어를 통한 정상 작동여부 확인
아파치 웹 서버의 정상 작동여부를 확인하기 위해서 “apachectl”의 “status"옵션을 사용할 수 있으나, 이 옵션을 사용하기 위해서는 "httpd-info.conf"의 설정이 필요하다.
다음과 같이 설정하고 확인 해 보도록 하자.
먼저 httpd.conf 파일에서 httpd-info.conf 파일을 Include 할 수 있게 주석을 제거한다.
|
|
|
| #Include conf/extra/httpd-info.conf ====> Include conf/extra/httpd-info.conf |
|
|
|
|
다음으로 httpd-info.conf 파일에서 “http://localhost/server-status"에 대한 로컬 접속을 다음과 같이 허용한다.
|
|
|
| <Location /server-status> SetHandler server-status Order deny,allow Deny from all Allow from .example.com </Location>
## 위 내용을 다음과 같이 수정한다.
==>
<Location /server-status> SetHandler server-status Order deny,allow Deny from all Allow from 127.0.0.1 </Location> |
|
|
|
|
위와 같이 설정하고, 아파치를 재 시작한다.
(apachectl restart)
다음과 같이 상태를 확인한다.
|
|
|
| [root@SULinux-64Bit bin]# /usr/local/apache/bin/apachectl status
Apache Server Status for localhost
Server Version: Apache/2.2.24 (Unix) mod_ssl/2.2.24 OpenSSL/0.9.8e-fips-sul2 PHP/5.4.14
Server Built: May 4 2013 06:34:13 _________________________________________________________________
Current Time: Wednesday, 08-May-2013 11:38:21 KST Restart Time: Wednesday, 08-May-2013 11:33:34 KST Parent Server Generation: 2 Server uptime: 4 minutes 47 seconds 1 requests currently being processed, 4 idle workers
_W___........................................................... ................................................................ ................................................................ ................................................................
Scoreboard Key: "_" Waiting for Connection, "S" Starting up, "R" Reading Request, "W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup, "C" Closing connection, "L" Logging, "G" Gracefully finishing, "I" Idle cleanup of worker, "." Open slot with no current process |
|
|
|
|
위의 결과와 같이 Apache버전, PHP버전등을 확인할 수 있고, 아파치 서버의 상태를 확인할 수 있다.
ⓑ apache 프로세스 점검
아파치 정상 작동 여부 확인을 위해 아파치 프로세스를 확인한다.
|
|
|
| [root@SULinux-64Bit bin]# ps -ef |grep httpd root 9928 1 0 11:20 ? 00:00:00 /usr/local/apache/bin/httpd -k start daemon 9986 9928 0 11:33 ? 00:00:00 /usr/local/apache/bin/httpd -k start daemon 9987 9928 0 11:33 ? 00:00:00 /usr/local/apache/bin/httpd -k start daemon 9988 9928 0 11:33 ? 00:00:00 /usr/local/apache/bin/httpd -k start daemon 9989 9928 0 11:33 ? 00:00:00 /usr/local/apache/bin/httpd -k start daemon 9990 9928 0 11:33 ? 00:00:00 /usr/local/apache/bin/httpd -k start root 10009 9848 0 11:43 pts/0 00:00:00 grep httpd |
|
|
|
|
ps 명령어와 grep 명령어를 이용하여 아파치 프로세스를 확인하였다.
ⓒ 아파치 포트 리스닝 확인
|
|
|
| [root@SULinux-64Bit bin]# netstat -anp |grep httpd tcp 0 0 :::80 :::* LISTEN 9928/httpd |
|
|
|
|
netstat 명령어와 grep 명령어를 통해 아파치 기본 포트 (TCP/80)포트 오픈 여부를 확인하였다.
ⓓ 웹브라우저를 통한 확인
웹 브라우저를 통해 위와 같이 아파치 웹서버의 정상접속을 확인하였다.
ⓔ PHP 정상 연동 확인
아파치 웹서버에 PHP연동 상태를 확인하기 위해는 다음과 같이 php프로그램을 작성하여 확인 하는 방법이 있다.
php는 php정보를 보여주는 phpinfo() 함수가 있다.
/usr/local/apache/htdocs/sulinux.php 파일에 다음 내용을 작성한다.
|
|
|
| <?php phpinfo(); ?> |
|
|
|
|
위와같이 phpinfo() 함수를 수행하는 sulinux.php 파일을 생성하였다면, 웹브라우저의 주소창에 “http://192.168.19.201/sulinux.php" 입력하여 다음과 같이 확인 할 수 있다.
(주의) 정상 작동 여부를 확인하였다면, 위에서 작성한 "sulinux.php"파일을 삭제해야 한다.
만약 이 내용이 해커에게 노출된다면, 관련 취약점을 이용해 쉽게 해킹을 할 수 있기 때문이다.
관련자료
-
이전
-
다음