ubuntu 18.04 中的 Lumen 虚拟主机

Lumen Virtual host in ubuntu 18.04

我已经为一个 laravel 项目实现了一个虚拟主机并且工作没有任何问题并且在实现所有东西时真的没有问题。

现在我正在为我的 lumen 项目做同样的事情,但它不起作用: Hmm. We’re having trouble finding that site.

这是我的 test.local.conf 的样子:

<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port t>
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName www.example.com

    ServerAdmin admin@test.com
    ServerAlias test.local
    ServerName test.local
    DocumentRoot /var/www/html/test/public

    <Directory /var/www/html/test/public>
            Options -Indexes +FollowSymLinks
            AllowOverride All
            Allow from all
    </Directory>
    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

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

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

我已经重新启动了 apache,但它不起作用。我在这里做错了什么?

我在 stavkoverflow 提出的 3 个问题中,所有 3 个问题都是我自己回答的...

无论如何,没问题,每个为此苦苦挣扎的人都不要忘记在机器主机文件中添加一个条目,如下所示:

sudo nano /etc/hosts

添加这一行:

127.0.0.1       test.local

ctrl+o 保存,ctrl+x 退出

最后一步,重启apache:sudo service apache2 restart

PS:如果 127.0.0.1 已被占用,您可以设置另一个 ip,例如:127.0.0.2

很有魅力!