简体   繁体   中英

Difficulty deploying lumen app

I'm trying to deploy a small application to my remote server, however, I seem to be having difficulty with some of the routes. Bare in mind that everything works on my local machine.

Here is what I've done:

  1. Uploaded the entire project to /home/user/app
  2. Moved contents of /home/user/app/public to /home/user/public_html/api
  3. Modified /home/user/public_html/api/index.php from:

$app->run();

to

$request = Illuminate\Http\Request::capture();
$app->run($request);

...this allowed my first route to work, but I cannot load any other routes such as:

http://www.mywebsite.com/api/v1/book

Please note that only http://www.mywebsite.com/api is the only route that loads correctly.

My routes.php looks like this:

$app->get('/', function() use ($app) {
    return "Lumen RESTful API";
});

$app->group(['prefix' => 'api/v1','namespace' => 'App\Http\Controllers'], function($app)
{
    $app->get('book','BookController@index');

    $app->get('book/{id}','BookController@getbook');

    $app->post('book','BookController@createBook');

    $app->put('book/{id}','BookController@updateBook');

    $app->delete('book/{id}','BookController@deleteBook');
});

My .htaccess is as follows:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

The error I am receiving:

我收到的错误

Let me know if you need any more information?

Any help would be greatly appreciated!

将路由组前缀更改为:

$app->group(['prefix' => 'v1'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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