ubuntu apache2本地虚拟站点

ubuntu apache2本地虚拟站点,ubuntu,apache2,localhost,virtualhost,Ubuntu,Apache2,Localhost,Virtualhost,1我创建了默认配置文件的副本,并将其重命名为/etc/apache2/sites available目录中的livrets.com 2我将其编辑如下: <VirtualHost *:80> ServerAdmin webmaster@localhost ServerName livrets.com ServerAlias www.livrets.com DocumentRoot /var/www/livrets.com

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

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文件


有什么想法吗?

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

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

127.0.0.1    livrets.com
…每当您在浏览器的地址栏中键入livrets.com时,您都在告诉您的机器查看您自己的机器127.0.0.1

如果使用Linux,则主机文件位于/etc/目录;如果使用Windows PC,则主机文件位于C:\Windows\System32\Drivers\etc\hosts;如果使用Mac,则主机文件位于/private/etc/目录