Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

gmehtaster's avatar

Issues with deploying a Laravel Site

Hi,

I have been working on a development site on my local machine. I am now trying to deploy it on an EC2 instance. I am facing issues with that. Here is what I have done till now.

Step 1: Cloned project on same level as www so my project is in /var/my_project

Step 2: Next I copied content of my public folder to /var/www/html folder

Step 3: Next I modified the index.php file in my /var/www/html folder for the following require DIR.’/../my_project/bootstrap/autoload.php’; $app = require_once DIR.’/../my_project/bootstrap/app.php’;

Step 4: Changed access to storage folder chmod -R o+w project/storage

Step 5: Modified .env folder

Step 6: Ran the following dependencies $ php composer install $ php composer dumpautoload -o $ php artisan config:cache $ php artisan route:cache

Ran all the migrations and everything. Everything is all set but when I hit the IP Address of the EC2 instance I get 500 Error. I have modified .env file and set APP_ENV = local APP_DEBUG = true but I am not seeing any errors.

Can someone please help me with what I can do to resolve this. Do I need to modify .htaccess folder or is it something totally wrong that I am doing.

0 likes
4 replies
Snapey's avatar

Don't you need to go up another level in your index.php?

/var/my_project

public is in `/var/www/html' so you need to go up to www, then up to var and then specify my_project

require __DIR__.'/../../my_project/bootstrap/autoload.php';
$app = require_once __DIR__.'/../../my_project/bootstrap/app.php';

try this from the command line. If you are in the html folder, you should be able to type cd ../../my_project and be in the 'root' of your project

1 like
willvincent's avatar
Level 54

Instead of changing the index file, you should really just adjust your server config to point at the public directory.

But, based on where you stated you've placed the project vs. where the docroot is, these:

require __DIR__ . ’/../my_project/bootstrap/autoload.php’; 
$app = require_once __DIR__ . ’/../my_project/bootstrap/app.php’;

are pointing at the www directory, not /var/my_project.. you'd need to go up another level, like this:

require __DIR__ . ’/../../my_project/bootstrap/autoload.php’;
$app = require_once __DIR__ . ’/../../my_project/bootstrap/app.php’;
1 like
gmehtaster's avatar

Was able to resolve the issue. The problem was in step 3 Had to change it to

require DIR.’/../my_project/bootstrap/autoload.php’; to require DIR.’/../../my_project/bootstrap/autoload.php’;

$app = require_once DIR.’/../my_project/bootstrap/app.php’; to $app = require_once DIR.’/../../my_project/bootstrap/app.php’;

Please or to participate in this conversation.