簡體   English   中英

無法使用Apache 2.4創建虛擬主機

[英]Unable to create virtual hosts with Apache 2.4

我正在嘗試在新的Ubuntu 13.10安裝上將多個虛擬主機配置為開發服務器。 它只需要為自己服務。 Apache服務器版本:Apache / 2.4.6(Ubuntu)

我已閱讀http://httpd.apache.org/docs/2.4/vhosts/name-based.html https://help.ubuntu.com/13.04/serverguide/httpd.html和許多其他網站,試圖弄清楚這一點出來。

http://localhost工作正常,但未找到http://ncacaa.local 我在想什么??? ping http://nacaa.local返回ping: unknown host http://ncacaa.local

這是/etc/apache2/sites-available/ncacaa.conf的內容

<VirtualHost *:80>
    DocumentRoot "/var/www/vhosts/htdocs-ncacaa"
    ServerName ncacaa.local
    ErrorLog "/var/log/apache2/ncacaa.localhost-error.log"
    <Directory "/var/www/vhosts/htdocs-ncacaa">
       Order allow,deny
       Allow from all
       Require all granted
    </Directory>
</VirtualHost>

在a2ensite創建的啟用站點的目錄中有指向它的符號鏈接

這是在000-default.conf文件中未注釋掉的內容:

<VirtualHost *:80>
    ServerAdmin john@***.com
    DocumentRoot /var/www
    <Directory "/var/www">
            AllowOverride FileInfo
            Options Indexes FollowSymLinks
            Order allow,deny
            Allow from all
            Require all granted
    </Directory>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

以下是apache.conf文件中未注釋掉的內容:

Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
LogLevel warn
<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>
AccessFileName .htaccess
<FilesMatch "^\.ht">
    Require all denied
</FilesMatch>
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*
ServerName localhost:80

提前致謝!

配置中還需要有一行來打開虛擬主機:

NameVirtualHost *:80

盡管錯誤“ ping http://nacaa.local返回ping:未知主機http://ncacaa.local ”表示您的dns無法解析。 您需要添加到/ etc / hosts或設置dns。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM