简体   繁体   English

带有Apache2的Ubuntu上的Laravel无法正常工作

[英]Laravel on Ubuntu with Apache2 not working

i tried to configure laravel for apache2. 我试图为apache2配置laravel。

But if I open http://localhost/ it redirect me to http://localhost/login and there is nothing to display. 但是,如果我打开http:// localhost /,它将重定向到http:// localhost / login ,则无任何显示。

If I try http://localhost/index.php/login I get the view blade to login. 如果我尝试使用http://localhost/index.php/login ,则可以使用视图刀片进行登录。 But how can I remove the /index.php/ 但是,如何删除/index.php/

The Apache vHost config Apache vHost配置

我的虚拟主机配置

And the "main" route 和“主要”路线

Route::get('/home', function() {
    return Redirect::to('login'); 
});

Route::group([], function() {
    Route::get('/', function() {
        return Redirect::to('dashboard');

    Route::get('galleries', 'GalleryController@getGalleries');
    Route::get('galleries/{GID}', 'GalleryController@getPicuteGallery');    

    Route::get('news', 'NewsController@index');
    Route::get('dashboard', 'DashboardController@index');

    Route::get('search', 'Search\SearchController@index');

    Route::get('calendar', 'CalendarController@index'); 

    Route::get('symposium', 'SymposiumController@index');

    Route::get('conference', 'ConferenceController@index');

    Route::get('publication', function() {
        return view('publication'); 
    });
});

The Auth routes are predefined by AdminLTE installer. Auth路由由AdminLTE安装程序预定义。

/**
 * Define the AdminLTETemplate routes.
 */
protected function defineRoutes()
{
    if (!$this->app->routesAreCached()) {
        $router = app('router');

        $router->group(['namespace' => $this->getAppNamespace().'Http\Controllers'], function () {
            require __DIR__.'/../Http/routes.php';
        });
    }
}

And the AdminLTE Router 和AdminLTE路由器

<?php
/*
 * Same configuration as Laravel 5.2:
 * See https://github.com/laravel/framework/blob/5.2/src/Illuminate    /Auth/Console/stubs/make/routes.stub
 */
Route::group(['middleware' => 'web'], function () {
    Route::auth();

    Route::get('/home', 'HomeController@index');

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

---UPDATE--- -更新-

I found out that the mod_rewrite wasnt enabled. 我发现未启用mod_rewrite。 Now the web site works fine. 现在,该网站可以正常运行。

But I need to add the 'middleware' => 'web' class 但是我需要添加'middleware'=>'web'类

Remove ['middleware' => 'web'] from you routes.php , because since Laravel 5.2.27 this middleware applies automatically to all your routes and if you're adding it manually, it may give you broken app. 删除['middleware' => 'web']从您routes.php ,因为自Laravel 5.2.27这个中间件自动适用于所有的路线,如果你手动添加它,它可能会给你坏了应用程序。

UPDATE: 更新:

You have a function which redirects you to 'dashboard' (why?) and also the function is not closed. 您有一个将您重定向到“仪表板”的功能(为什么?),并且该功能未关闭。 So try to remove these lines: 因此,请尝试删除这些行:

Route::get('/', function() {
    return Redirect::to('dashboard');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM