【问题标题】:Laravel - the requested url cannot be found on this serverLaravel - 在此服务器上找不到请求的 url
【发布时间】:2016-11-23 12:52:49
【问题描述】:

我已经在linode 上部署了我的项目并正确配置了所有内容,但我发现主页是唯一可以工作的东西。其他任何事情都在给我The requested url can not be found on this server。我检查了我所有的配置,一切似乎都是正确的。 a2enmod rewrite 已启用,此 000-default.conf:

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # 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 webmaster@localhost
        DocumentRoot /var/www
        <Directory /var/www>
                Options Indexes FollowSymLinks
                AllowOverride All
                RewriteEngine On
                RewriteBase /var/www/application
                Require all granted
        </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}/error.log
        CustomLog ${APACHE_LOG_DIR}/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

还缺少什么?

编辑:

VirtualHost configuration:
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex default: dir="/var/lock/apache2" mechanism=fcntl 
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
Define: ENABLE_USR_LIB_CGI_BIN
User: name="www-data" id=33
Group: name="www-data" id=33

【问题讨论】:

  • 你能告诉我你的文件虚拟主机吗?
  • 我已经添加了配置

标签: apache laravel linode


【解决方案1】:

您需要将文档根目录设置为应用程序的公共文件夹,如下所示:

“var/www/your-site.com/public”

【讨论】:

  • 项目结构中没有公用文件夹。
【解决方案2】:

尝试按照我的配置:

<VirtualHost *:80>
  ServerName yourproject.com
  ServerAlias www.yourproject.com

  ServerAdmin webmaster@localhost
  DocumentRoot /var/www/yourproject/public
  <Directory "/var/www/yourproject/public">
    Require all granted
    Allowoverride All
  </Directory>

  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

【讨论】:

  • 项目结构中没有公用文件夹。
  • 我不明白。这是一个 laravel 项目。为什么没有公用文件夹?
  • 它基于 hellovideoapp.com,我有一个应用程序文件夹和一个内容文件夹。应用程序文件夹包含除公共文件夹之外的所有内容,这有点奇怪
【解决方案3】:

原来.htaccess 不见了,这就是原因。我已经添加了它,它工作正常。

【讨论】:

    猜你喜欢
    • 2017-12-26
    • 2015-03-30
    • 2015-12-17
    • 2016-12-21
    • 2016-07-23
    • 1970-01-01
    • 2017-03-21
    • 2010-10-16
    • 1970-01-01
    相关资源
    最近更新 更多