Ubuntu apache虚拟主机站点在浏览器

时间:2018-02-26 10:48:00

标签: laravel apache vhosts

我有一个我在/var/www/html/设置的Laravel网站。我还为此网站设置了一个虚拟主机,因为我想要一个自定义网址( example.dev )而不是localhost

这就是我设置vhost的方式:

<VirtualHost *:80>

    ServerName example.dev
    ServerAlias http://example.dev
    DocumentRoot /var/www/html/example/public/

        <Directory /var/www/html/example/>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>

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

</VirtualHost>

执行此操作后,我通过运行sudo a2dissite 000-default.conf禁用默认的.conf,然后启用我创建的.conf(sudo a2ensite example.dev.conf)。毕竟,我重新启动了apache并重新加载配置。

从那时起,我将我的服务器名称添加到我的主机文件中,如下所示:

127.0.0.1       localhost       example.dev
127.0.1.1       tangaye

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

现在,当我尝试在浏览器中访问我的网站时,我输入了example.dev

  

无法访问此网站。 example.dev拒绝连接。

但当我localhost我的网站启动时。为什么会这样?有趣的是,我意识到当我curl -L example.dev时,我在终端中获得了我网站的完整预期结果。 为什么我的网站在终端而不是浏览器中访问?将不胜感激任何帮助。谢谢!

0 个答案:

没有答案
相关问题