ubuntu 18.04中的Lumen虚拟主机

问题描述

我已经为laravel项目实现了虚拟主机,并且可以正常工作,并且在实现所有功能上都没有问题。

现在,我正在为我的流明项目做同样的事情,但是它不起作用: 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 [email protected]
    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

像魅力一样工作!