【问题标题】:Page on VPS in Laravel doesn't workLaravel 中 VPS 上的页面不起作用
【发布时间】:2015-11-28 10:59:39
【问题描述】:

我购买了 VPS 并在其上安装了 Laravel,主页运行正常,我得到副标题“Laravel 5”,但是当我在路由文件中创建测试页面时:

Route::get('/test', function() {
   return 'test' ;
});

我明白了:

 Not Found
 The requested URL /test was not found on this server.
 Apache/2.4.7 (Ubuntu) Server at plerp.net.pl Port 80`

我在 777 上 chmod 存储文件夹。

`

    ServerName www.plerp.net.pl
    DocumentRoot /var/www/laravel/public

    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/laravel>
            AllowOverride All
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    LogLevel warn
    CustomLog ${APACHE_LOG_DIR}/access.log combined

`

【问题讨论】:

  • 您是否启用了mod_rewrite 模块?

标签: php webpage laravel-5.1 vps


【解决方案1】:

我认为您的网络服务器没有激活重写模块。试试这个(注意,下面只有 Apache 的说明):

  • sudo a2enmod rewrite(适用于 Debian/Ubuntu 系列)
  • sudo ln -s /etc/httpd/mods-available/rewrite.load /etc/httpd/mods-enabled/(适用于 Red Hat / CentOS 系列)

它可能没有安装,在这种情况下,您需要在发行版的存储库中搜索它:

  • sudo apt search apache rewrite 用于基于 deb 的发行版
  • sudo yum search httpd rewrite 用于基于 rpm 或 sudo dnf search httpd rewrite 用于 Fedora 21+

然后用

安装它
  • sudo apt install &lt;name-of-package&gt; 基于 deb 的
  • sudo yum install &lt;name-of-package&gt; 用于基于 rpm (将 yum 替换为 dnf 用于 Fedora 21+)

您可能需要仔细检查文件和文件夹权限,很可能您需要做的就是chown Web 服务器用户下的相应文件夹。

【讨论】:

  • 我确实重写了,也是同样的问题,当我重新启动时,我得到:* Restarting web server apache2 AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 155.xxx. Xx. Xx. Set the 'ServerName' directive globally to suppress this message ...done.我将文件夹更改为存储。
  • 您可以将sites-enabled 目录的内容粘贴到某处吗?在其中的每个文件中都应该有一行定义 ServerName,它只不过是您想要使用该定义访问的域名(即 example.org,它应该指向 Laravel 的主页 - 照顾DirectoryRoot 指令)
  • 好的,我做到了,我从数字海洋的教程中复制了 apache 文件,一切正常digitalocean.com/community/tutorials/…
猜你喜欢
  • 2017-07-08
  • 2019-06-14
  • 1970-01-01
  • 2016-11-26
  • 2020-08-08
  • 2020-07-15
  • 2017-08-12
  • 1970-01-01
  • 2022-10-16
相关资源
最近更新 更多