【问题标题】:ubuntu apache2 local virtual siteubuntu apache2 本地虚拟站点
【发布时间】:2014-08-28 12:19:01
【问题描述】:

1)我创建了默认配置文件的副本并将其重命名为“livrets.com”(在 /etc/apache2/sites-available 目录中)

2) 我编辑如下:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName livrets.com
        ServerAlias www.livrets.com

        DocumentRoot /var/www/livrets.com/htdocs
        <Directory /var/www/livrets.com/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                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
</VirtualHost>

3) 我启用它运行sudo a2ensite livrets.com

4) 我创建了目录 /var/livrets.com/htdocs 给它 777 个属性(可以肯定)和我的用户作为所有者:sudo chown -R fred:fred /var/www

5) 我在 /var/www/livrets.com/htdocs 中创建了一个 index.html 文件

6)我重启了apache

不过,当我在浏览器中键入 livrets.com URL 时,它不会显示我的 /var/www/livrets.com/htdocs/index.html 文件。

有什么想法吗?

【问题讨论】:

    标签: ubuntu apache2 localhost virtualhost


    【解决方案1】:

    您忘记在 hosts 文件中添加一个条目,当您在浏览器的地址栏中键入“livrets.com”时,该条目会告诉您的计算机“查找”的位置。

    默认情况下,您的机器将使用域的 DNS 条目。通过将以下行添加到您的主机文件...

    127.0.0.1    livrets.com
    

    ...您是在告诉您的机器,每当您在浏览器的地址栏中键入“livrets.com”时,查看您自己的机器(127.0.0.1)。

    如果您使用的是 Linux,“hosts”文件位于 /etc/ 目录,如果您使用的是 Windows PC,则它位于 C:\Windows\System32\Drivers \etc\hosts,如果您使用的是 Mac,则位于 /private/etc/

    【讨论】:

      猜你喜欢
      • 2017-05-23
      • 2015-08-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-30
      • 1970-01-01
      • 1970-01-01
      • 2013-01-24
      相关资源
      最近更新 更多