在Ubuntu虚拟主机无法正常工作(virtual host in ubuntu not work)

2019-10-18 10:09发布

我创建了一个虚拟主机/etc/apache2/site-available/mysite.local与此配置:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName mysite.local
    DocumentRoot /var/www/mysite
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/mysite>
            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 None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>
</VirtualHost>

/etc/hosts

127.0.0.1    localhost
127.0.1.3    mysite.local

但是当我去mysite.local它显示了localhost ! 有什么问题?

Answer 1:

问题是根据重装的Apache2服务,我必须重新加载Apache作为sudoer。

我必须使用sudo service apache2 reload ,而不是service apache2 reload



文章来源: virtual host in ubuntu not work