![PHP LARAVEL 错误:在 Ubuntu 16 OS 上的 LAMP Stack 上部署的 Laravel 中,除索引页外未找到任何页面](https://linux22.com/image/1006321/PHP%20LARAVEL%20%E9%94%99%E8%AF%AF%EF%BC%9A%E5%9C%A8%20Ubuntu%2016%20OS%20%E4%B8%8A%E7%9A%84%20LAMP%20Stack%20%E4%B8%8A%E9%83%A8%E7%BD%B2%E7%9A%84%20Laravel%20%E4%B8%AD%EF%BC%8C%E9%99%A4%E7%B4%A2%E5%BC%95%E9%A1%B5%E5%A4%96%E6%9C%AA%E6%89%BE%E5%88%B0%E4%BB%BB%E4%BD%95%E9%A1%B5%E9%9D%A2.png)
在 Google Compute Engine 上运行 Ubuntu 16 服务器映像。我第一次接触 Ubuntu。我已经通过安装了 Laravelcomposer
并正确完成了所有操作,但您的网站只打开了主页,其他一切都显示此错误:
404 not found
您可以在此处查看网站:http://35.227.60.17
每个按钮都在路线中重定向,它们只是路线。
- 我已经设置了虚拟主机并禁用了该
000-default.conf
文件,但情况仍然一样。 - 我已经在 XAMPP 服务器(Windows)上对其进行了本地测试。一切正常。
- 甚至数据库迁移也正在运行。
- 我已经通过安装了所有依赖项
composer
。 - 我
php
的服务器上安装了 5.6、7.0、7.1、7.2 以及每个版本的所有扩展。
这是我的routes/web.php
:
App\Post
Route::get('/','PagesControllers@index');
Route::get('/about','PagesControllers@about');
Route::get('/services','PagesControllers@services');
Route::resource('posts','PostsController');
// writing a route for PostController other than resources
//and using App\Post for Post model...
Route:: get('/mytestroute', function()
{
$posts= Post::paginate(1);
return view('mytestroute')->with('posts', $posts);
});
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
如何解决这个问题?
答案1
尝试在终端中运行这个
$ sudo a2enmod rewrite
然后添加到你的/etc/apache2/sites-available/000-defaults.conf
里面虚拟主机标记另一个标签:
<Directory /var/www/html>
AllowOverride All
</Directory>
替换/var/www/html
为你的文档根目录。最后重启 apache
$ sudo service apache2 restart
你就可以出发了!