[Apache2] apache troubleshooting log : linux

‍한지영·2022년 5월 9일
0

sudo service apache2 restart/start시 에러가 나는 경우

command

sudo service apache2 restart #restart

out

Job for apache2.service failed because the control process exited with error code.
See "systemctl status apache2.service" and "journalctl -xe" for details.

command

/etc/init.d/apache2 status #상태확인, = systemctl status apache2.service

out

● apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Mon 2022-05-09 20:45:46 KST; 3min 2s ago
     Docs: https://httpd.apache.org/docs/2.4/
  Process: 7272 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)

=> apache2.conf에 syntax error가 있을 가능성 염두.

command

cd /etc/apache2
apache2ctl configtest #It will show you where is the error in the apache2.conf file to correct.

out

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using [server ip address]. Set the 'ServerName' directive globally to suppress this message
Syntax OK

=> syntax error는 없었으나 server's domain name을 확실히 할 수 없다는 에러. [server ip address] 부분에 본인 서버 아이피가 뜰 것.
=> "ServerName"을 명시해줄 것.

command

cd /etc/apache2/
sudo vi apache2.conf 

=> apache2.conf 수정

/etc/apache2/apache2.conf 맨 마지막 줄에
Servername [본인 서버 ip 주소] 추가하고 저장.

command

sudo service apache2 restart #재시작

out

Job for apache2.service failed because the control process exited with error code.
See "systemctl status apache2.service" and "journalctl -xe" for details.

재시작하였으나, 다시 에러

command

sudo service apache2 status #상태 확인

out

● apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Mon 2022-05-09 20:58:28 KST; 4s ago
     Docs: https://httpd.apache.org/docs/2.4/
  Process: 7563 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)

 5월 09 20:58:28 linux systemd[1]: Starting The Apache HTTP Server...
 5월 09 20:58:28 linux apachectl[7563]: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
 5월 09 20:58:28 linux apachectl[7563]: (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
 5월 09 20:58:28 linux apachectl[7563]: no listening sockets available, shutting down
 5월 09 20:58:28 linux apachectl[7563]: AH00015: Unable to open logs
 5월 09 20:58:28 linux apachectl[7563]: Action 'start' failed.
 5월 09 20:58:28 linux apachectl[7563]: The Apache error log may have more information.
 5월 09 20:58:28 linux systemd[1]: apache2.service: Control process exited, code=exited status=1
 5월 09 20:58:28 linux systemd[1]: apache2.service: Failed with result 'exit-code'.
 5월 09 20:58:28 linux systemd[1]: Failed to start The Apache HTTP Server.

다른 에러. 이전 서버 시작/종료가 비정상적이어서 발생. 80포트 강제로 꺼버리고 apache 재시작하면 해결 가능.

command

sudo netstat -ltnp | grep :80 #열려있는 80포트 확인

out

tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      7639/nginx: master  
tcp        0      0 0.0.0.0:8000            0.0.0.0:*               LISTEN      6663/python3        
tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN      2033/java           
tcp6       0      0 :::8009                 :::*                    LISTEN      2033/java           
tcp6       0      0 :::8080                 :::*                    LISTEN      2033/java

나의 경우에는 nginx 프로세스가 돌아가고 있었으나, apache2가 돌아가고 있는 경우가 대다수일것. 어쨌든 80포트(7639) kill.

command

sudo kill -9 7639
sudo netstat -ltnp | grep :80 #잘 껐나 확인용

out

tcp        0      0 0.0.0.0:8000            0.0.0.0:*               LISTEN      6663/python3        
tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN      2033/java           
tcp6       0      0 :::8009                 :::*                    LISTEN      2033/java           
tcp6       0      0 :::8080                 :::*                    LISTEN      2033/java   

잘 꺼진 것 확인

command

sudo service apache2 restart #재시작
sudo service apache2 status #상태

out

● apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2022-05-09 21:07:00 KST; 6s ago

Active 확인. 해결

profile
NLP 전공 잡식성 문헌정보 석사생

0개의 댓글