/etc/apache2에 sites-available/000-default.conf가 없습니다.

/etc/apache2에 sites-available/000-default.conf가 없습니다.

Apache2용 가상 호스트를 설정하려고 합니다. 수많은 튜토리얼이 있지만 모두 파일이 /etc/apache2/sites-available/000-default.conf거기에 있다고 가정합니다. 하지만 내가 실행하면 :

$ cd /etc/apache2/
$ ls
conf-available
$ cd conf-available
$ ls
javascript-common.conf

같은 문제를 겪은 사람을 찾을 수 없습니다. 이와 같은 튜토리얼을 시작하기 전에 해야 할 일이 있나요?

https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-16-04

모든 것이 최신 상태입니다. 우분투는 16.04 LTS입니다.

답변1

에 있는 파일은 /etc/apache2/conf-available관리자가 자유롭게 생성, 이름 바꾸기, 제거, 적절한 콘텐츠 채우기 등을 할 수 있는 파일입니다. 000-default.com이 없으면 새로 만드세요.

그런 다음 전화해야합니다

sudo a2ensite 000-default.conf

주의사항:

  • 가상 호스트가 공존합니다. 제가 이해한 바에 따르면 이미 비표준 구성이 있습니다. 가상호스트가 서로 충돌하는 것을 주의하세요. 구성을 포함하여 apache2를 새로 설치해야 할 수도 있습니다.

  • /etc/apache2/apache2.conf구성으로 최종적으로 로드(포함)되는 파일은 명령 include(지정된 파일 포함) 과 같은 다른 구성 파일에 따라 달라집니다 . 포함된 파일에서 포함을 호출할 수도 있습니다.

참고로 apache2(버전 2.4.7)의 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

    # 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

그리고 심볼릭 링크를 생성하여 사이트를 생성하는 것보다 다음 명령을 사용하여 사이트를 활성화/비활성화하는 것이 가장 좋습니다(여전히 할 수 있지만 음... 일반적으로 오타를 피하기 위해 도우미 스크립트에 의존합니다).

a2ensite 000-default
a2dissite 000-default

일부 구성이 시작되지 않으면 다음을 시도해 볼 수 있습니다.

sudo service apache2 reload

또는 더 깊은 구성 재로드가 다음에서 발생합니다.

sudo service apache2 restart

다시 로드는 일부 연결 관련 데이터를 메모리에 유지하며 일반적인 새로 설치 시 두 가지 모두 1초도 채 걸리지 않습니다.

편집: a2ensite, a2dissite, service apache2 restart/reload라는 네 가지 유용한 명령에 대한 메모를 추가했으며 후속 편집에서는 질문에 더 잘 맞도록 답변을 재구성했습니다.

관련 정보