Apache2 Virtualhost가 루트 디렉토리로 이동합니다.


-1

attrave.com.conf/etc/apache2/sites-available 라는 가상 호스트가 있습니다.

해당 가상 호스트 파일의 코드는 다음과 같습니다 (관련 코드 만 첨부).

ServerName attrave.com
ServerAdmin bonyuuuc@gmail.com
ServerAlias www.attrave.com
DocumentRoot /var/www/attrave.com

<Directory />
        Options FollowSymLinks
        AllowOverride None
</Directory>
<Directory /var/www/attrave.com>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
</Directory>

나는 www.attrave.com또한 사이트에 액세스 할 수 있기를 원합니다 attrave.com.

에 내가 탐색 할 때 현재 attrave.com는 저를 필요 /var/www/디렉토리 정말 실제에 저를해야 할 때 attrave.com의 폴더. 내가 www.모든 것을 포함 시키면 효과가 있지만 이것은 좌절입니다.

편집 : 업데이트 된 가상 호스트 파일은 다음과 같습니다. (여전히 작동하지 않습니다)

# Ensure that Apache listens on port 80
Listen 80

# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80

<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.attrave.com
ServerAdmin bouuuuc@gmail.com
ServerAlias www.attrave.com
DocumentRoot /var/www/attrave.com

<Directory />
        Options FollowSymLinks
        AllowOverride None
</Directory>
<Directory /var/www/attrave.com>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
</Directory>

업데이트 2 :

귀하의 모든 제안을 사용해 보았지만 여전히 "attrave.com" 에서 사이트를 작동시킬 수 없습니다 . "www.attrave.com" 에서 작동합니다 .

관련 내용의 텍스트를 첨부하여이 문제에 대해 더 많은 정보를 얻을 수 있기를 바랍니다.

  • Attrave.com.conf (가상 호스트 파일)

    DocumentRoot /var/www/attrave.com
    ServerName attrave.com
    ServerAlias attrave.com www.attrave.com
    ServerAdmin bouuuuic@gmail.com
    
    
    <Directory /var/www/attrave.com>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>
    
  • / etc / hosts 파일

    # Your system has configured 'manage_etc_hosts' as True.
    # As a result, if you wish for changes to this file to persist
    # then you will need to either
    # a.) make changes to the master file in /etc/cloud/templates/hosts.tmpl
    # b.) change or remove the value of 'manage_etc_hosts' in
    #     /etc/cloud/cloud.cfg or cloud-config from user-data
    
    127.0.0.1 localhost
    
  • Apache2.conf 파일

     <Directory />
      Options FollowSymLinks
     AllowOverride None
      Require all denied
     </Directory>
    
    <Directory /usr/share>
     AllowOverride None
     Require all granted
    </Directory>
    
    <Directory /var/www/>
     Options Indexes FollowSymLinks
     AllowOverride None
     Require all granted
     </Directory>
    
     #<Directory /srv/>
     #  Options Indexes FollowSymLinks
     #   AllowOverride None
     #   Require all granted
    #</Directory>
    

답변:


-1

당신이 시도 했습니까?

# Ensure that Apache listens on port 80
Listen 80

# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80
<VirtualHost *:80>
    DocumentRoot /var/www/attrave.com
    Servername attrave.com
    # Other directives here
</VirtualHost>

cname을 확인했습니다. www가 추가되었습니다. 또한 내 문제는 내 문제는 내가하는 탐색 할 때 함께 www.attrave.com하지입니다 attrave.com 이는 / var / www가 루트 디렉토리에 저를합니다. 이 문제를 해결할 수 있기를 바랍니다.
— mat

1
어떤 dig attrave.com모습입니까?
— meatspace

; <<>> DiG 9.9.5-3ubuntu0.2-Ubuntu <<>> attrave.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 12031 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 512 ;; QUESTION SECTION: ;attrave.com. IN A ;; ANSWER SECTION: attrave.com. 1799 IN A 45.55.165.145 ;; Query time: 125 msec ;; SERVER: 8.8.8.8#53(8.8.8.8) ;; WHEN: Thu Apr 23 10:15:38 EDT 2015 ;; MSG SIZE rcvd: 56
— mat

수정 된 답변을 확인하십시오.
— Francisco Tapia

불행히도, 그것은 작동하지 않았지만 여전히 동일한 루트 디렉토리를 제공합니다.
— mat
당사 사이트를 사용함과 동시에 당사의 쿠키 정책과 개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.