Deploying laravel project

Published 3 months ago by jwillz21

I'm trying to deploy my project on a server, Its a RESTAPI. the server is running apache and is working properly (I tested it with a hello world script).

My project itself is in /var/API. I've moved my public folder from my project to my document root (/var/www/). I've altered my index.php document from my laravel project and added it to my document root, along with my public/.htaccess. The problem I'm having lies in my altered index.php file posted below.

If I run a get API call i get a 404 error in my browser. If I just run the ip for the server itself I get a 500 error.

<?php

define('LARAVEL_START', microtime(true));

require __DIR__.'/var/API/vendor/autoload.php';

$app = require_once __DIR__.'/var/API/bootstrap/app.php';

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);

$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture()
);

$response->send();

$kernel->terminate($request, $response);
jdc1898

Why did you alter your index.php file? Your routes should be in you api.php file.

jwillz21

because I moved my public directory into /var/www to keep the source code secure.

BishoyWagih

if you are using shared hosting just do the following

1 - move all files from public folder to root folder

2 - don't delete public folder leave it empty

3 - update index.php file as you did.

jwillz21

@BishoyWagih It didnt work. still having the same issue (404)

Please sign in or create an account to participate in this conversation.