Apache2 서버를 시작할 수 없습니다

Apache2 서버를 시작할 수 없습니다

Ubuntu 22.04 LTS Desktop에 설치된 apache2 서버를 시작하려고 합니다. 그러나 다시 시작이 실패했으며 오류 로그에서 볼 수 있듯이 이는 내 구성과 관련이 있습니다. 그러나 정확한 문제에 대해서는 더 이상 디버깅할 수 없습니다. 내 apache2 서버 구성은 다음과 같습니다.

cat /etc/apache2/sites-enabled/000-default.conf 
<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName www.example.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    WSGIDaemonProcess flaskapp threads=5 python-home=/home/hd2900/Documents/Python/hd2900TakeawayPrint/env
    WSGIScriptAlias / /home/hd2900/Documents/Python/hd2900TakeawayPrint/flaskapp.wsgi
    WSGIApplicationGroup %{GLOBAL}

    <Directory /home/hd2900/Documents/Python/hd2900TakeawayPrint>
              WSGIProcessGroup flaskapp
              Require all granted
    </Directory>

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

서버를 시작하려고 할 때

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

systemctl status apache2.service를 더 자세히 살펴보면 apache2 구성 파일의 18번째 줄에 문제가 있는 것 같습니다. 해당 줄을 확인했지만 문제가 무엇인지 정확히 알 수 없습니다.

systemctl status apache2.service
× apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Sun 2022-08-28 00:11:46 CEST; 1min 14s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 4561 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)
        CPU: 66ms

Aug 28 00:11:45 hd2900 systemd[1]: Starting The Apache HTTP Server...
Aug 28 00:11:46 hd2900 apachectl[4564]: AH00526: Syntax error on line 18 of /etc/apache2/sites-enabled/000-default.conf:
Aug 28 00:11:46 hd2900 apachectl[4564]: Invalid command '\xe2\x80\x86', perhaps misspelled or defined by a module not included in the server configuration
Aug 28 00:11:46 hd2900 apachectl[4561]: Action 'start' failed.
Aug 28 00:11:46 hd2900 apachectl[4561]: The Apache error log may have more information.
Aug 28 00:11:46 hd2900 systemd[1]: apache2.service: Control process exited, code=exited, status=1/FAILURE
Aug 28 00:11:46 hd2900 systemd[1]: apache2.service: Failed with result 'exit-code'.
Aug 28 00:11:46 hd2900 systemd[1]: Failed to start The Apache HTTP Server.

또한 error.log를 확인하고 아래 내용을 인쇄했습니다. 아직 정확한 문제가 무엇인지 잘 모르겠습니다.

cat /var/log/apache2/error.log 
[Sat Aug 27 23:42:48.764507 2022] [mpm_event:notice] [pid 2886:tid 281473433382944] AH00489: Apache/2.4.52 (Ubuntu) configured -- resuming normal operations
[Sat Aug 27 23:42:48.765058 2022] [core:notice] [pid 2886:tid 281473433382944] AH00094: Command line: '/usr/sbin/apache2'
[Sat Aug 27 23:46:40.942688 2022] [mpm_event:notice] [pid 2886:tid 281473433382944] AH00492: caught SIGWINCH, shutting down gracefully
[Sat Aug 27 23:46:41.074596 2022] [mpm_event:notice] [pid 4010:tid 281473172430880] AH00489: Apache/2.4.52 (Ubuntu) mod_wsgi/4.9.0 Python/3.10 configured -- resuming normal operations
[Sat Aug 27 23:46:41.075061 2022] [core:notice] [pid 4010:tid 281473172430880] AH00094: Command line: '/usr/sbin/apache2'
[Sat Aug 27 23:52:16.956956 2022] [mpm_event:notice] [pid 4010:tid 281473172430880] AH00491: caught SIGTERM, shutting down

답변1

file 의 내용을 나열하는 cat -tev대신 명령을 사용하면 18행과 19행에 다음과 같은 이상한 제어 문자가 포함되어 있는 것을 볼 수 있습니다.cat/etc/apache2/sites-enabled/000-default.conf

[...]
    <Directory /home/hd2900/Documents/Python/hd2900TakeawayPrint>$
    M-bM-^@M-^F M-bM-^@M-^F M-bM-^@M-^F M-bM-^@M-^F M-bM-^@M-^F WSGIProcessGroup flaskapp$
    M-bM-^@M-^F M-bM-^@M-^F M-bM-^@M-^F M-bM-^@M-^F M-bM-^@M-^F Require all granted$
    </Directory>$
[...]

아마도 웹이나 PDF 페이지에서 이러한 지시문을 복사하여 붙여넣었을 것입니다.

이 파일의 18행과 19행을 삭제하고 동일한 위치에 구성 지시어를 수동으로 다시 입력해야 합니다.

WSGIProcessGroup flaskapp
Require all granted

관련 정보