0

那是我第一次在我的计算机中为本地工作和测试配置虚拟主机。我正在尝试访问我在可用站点/默认站点上配置的 blog.dev,但它不起作用。这是我的网站可用/默认:

<VirtualHost *:80>
    ServerAdmin eduguimara@gmail.com

    ServerName blog.dev
    ServerAlias www.blog.dev
    DocumentRoot /var/www/crud/public
    <Directory />
            Options FollowSymLinks
            AllowOverride All
    </Directory>
    <Directory /var/www/crud/public>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>
    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride All
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>
    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined
    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride All
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>
</VirtualHost>

我做了 sudo a2ensite blog.dev.conf 和 sudo service apache2 restart 。根据我找到的指南、帮助和教程,它应该正在运行。但是我的浏览器找不到http://blog.dev
当我键入 localhost 时,它仍然可以工作,但 ServerName 不工作。Ports.conf 上的 NameVirtualHost *:80 可以。
我尝试在 sites-available/ 目录中配置一个名为 blog.dev.conf 的新文件,但它仍然无法正常工作。

4

2 回答 2

1

您需要在 /etc/hosts 文件中添加以下条目:

127.0.0.1    blog.dev
于 2014-06-04T03:25:00.813 回答
0

如果 blog.dev 不是真正的域,并且您没有指向服务器的 DNS 条目,那么您需要在系统的 hosts 文件中添加一个虚假条目,以便解析域名。

在 windows 下,您可以将条目添加到位于此处的主机文件:c:\windows\system32\drivers\etc\hosts

然后正如 THEcreationist 所说,将 127.0.0.1 blog.dev 单独添加一行。

对于 linux 环境,请参阅 THEcreationist 的回复。

听起来应该可以解决您的问题。

于 2014-06-04T03:27:52.613 回答