Linux/보안장비 운용

아파치 웹서버 데몬이 안뜨는 이유

GGkeeper 2022. 3. 8. 16:09

실습> 아파치 웹서버 데몬이 안뜨는 이유

!!! 에러가 발생되면 항상 로그파일을 확인하는 습관을 가지는게 좋다. !!!
!!! 다양한 환경에서 다양한 오류를 많이 접해야 실력이 향상된다. !!!

# systemctl stop httpd
# cd /var/log/httpd
# mv access_log access_log.bak
# mkdir access_log
# cd
# httpd -t
Syntax OK
# systemctl start httpd
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.

# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since 월 2022-03-07 16:46:51 KST; 19s ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 1567 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=0/SUCCESS)
  Process: 1580 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 1580 (code=exited, status=1/FAILURE)

 3월 07 16:46:51 web1.linuxmaster.net systemd[1]: Starting The Apache HTTP Server...
 3월 07 16:46:51 web1.linuxmaster.net systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
 3월 07 16:46:51 web1.linuxmaster.net systemd[1]: Failed to start The Apache HTTP Server.
 3월 07 16:46:51 web1.linuxmaster.net systemd[1]: Unit httpd.service entered failed state.
 3월 07 16:46:51 web1.linuxmaster.net systemd[1]: httpd.service failed.

# cd /var/log/httpd
# unalias ls
# ls
access_log  access_log-20220304  access_log.bak  error_log  error_log-20220304


error_log 를 확인했더니 Is a directory 메세지나 나온 것을 확인할 수 있다.
# tail error_log
[Mon Mar 07 16:41:13.076713 2022] [log_config:error] [pid 1537] (21)Is a directory: AH00649: could not open transfer log file /etc/httpd/logs/access_log.
AH00015: Unable to open logs
[Mon Mar 07 16:44:28.246309 2022] [core:notice] [pid 1554] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
[Mon Mar 07 16:44:28.247157 2022] [suexec:notice] [pid 1554] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Mon Mar 07 16:44:28.263183 2022] [lbmethod_heartbeat:notice] [pid 1554] AH02282: No slotmem from mod_heartmonitor
[Mon Mar 07 16:44:28.282684 2022] [mpm_prefork:notice] [pid 1554] AH00163: Apache/2.4.6 (CentOS) PHP/5.4.16 configured -- resuming normal operations
[Mon Mar 07 16:44:28.282708 2022] [core:notice] [pid 1554] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Mon Mar 07 16:45:20.753540 2022] [mpm_prefork:notice] [pid 1554] AH00170: caught SIGWINCH, shutting down gracefully
[Mon Mar 07 16:46:51.870788 2022] [log_config:error] [pid 1580] (21)Is a directory: AH00649: could not open transfer log file /etc/httpd/logs/access_log.
AH00015: Unable to open logs

# ls -l
합계 16
drwxr-xr-x. 2 root root    6  3월  7 16:46 access_log
-rw-r--r--. 1 root root  257  3월  4 11:12 access_log-20220304
-rw-r--r--. 1 root root 1886  3월  7 16:09 access_log.bak
-rw-r--r--. 1 root root 3661  3월  7 16:46 error_log
-rw-r--r--. 1 root root 1104  3월  4 21:35 error_log-20220304

# rm -rf access_log
# mv access_log.bak access_log
# systemctl start httpd
# netstat -nltp | grep 80
tcp6       0      0 :::80                   :::*                    LISTEN      1601/httpd