2

I was brought in to work on and modernize a web application that is hosted on a Windows EC2 instance. There is no real source control or local development right now, all changes are done in master on the production server.

The first thing I want to do is lock down the production instance and get a local development environment up and running.

After initializing a Git repository, snapshotting the code, and pulling it locally, I used php artisan serve to get a local copy working. However, the local copy doesn't work, and in fact gives me the following error

Warning: require_once(/Users/{myUserName}/Projects/{FolderName}/{webapp_name}/public/index.php): failed to open stream: No such file or directory in /Users/{myUserName}/Projects/{FolderName}/{webapp_name}/server.php on line 21

Indeed, there is no index.php in the public folder. I have a fresh copy of laravel/laravel working on my machine, which does have an index.php in the correct place.

I've found the index.php in the source code, and it's in the root of the project folder. On a hunch, I went back to the EC2 instance and ran php artisan serve --port=8123 and sure enough, it gave me the same error on the production EC2 instance.

The error is similar:

require_once(): Failed opening required 'C:\xampp\htdocs\{app_name}/public/index.php

Note how there is a mix of forward and backwards slashes in this path. I am unsure if this is the reason it is failing.

I am brand new to Laravel (though I have experience with PHP). Is there a different command for actually deploying a Laravel app? The app is located in the xampp\htdocs on the production instance.

It's been a while since I used XAMPP. I mostly just use Heroku or built in solutions from AWS/Azure for deploying web apps now so I have to re-learn the nuts and bolts.

My question is: how is this Laravel application running if php artisan serve does not work correctly on the production instance?

Vishaal Kalwani
  • 730
  • 1
  • 7
  • 20
  • 1
    If `index.php` is in the project's root, someone who couldn't be bothered to configure the webserver moved it around. This is a security issue, unfortunately. This will break `php artisan serve`, as it expects it to be in `public/index.php`. – ceejayoz Jan 21 '19 at 23:53
  • Check out the web server's configuration and look for where it's looking for index.php. Then, you should be able to see what they've done with it; and hopefully put everything (including the web config) back how it should be? – Elliot Jan 22 '19 at 00:46
  • In `httpd.con`, I see the `DocumentRoot` is set to the root directory of the Laravel app. Perhaps that's why `index.php` was moved into the root directory. – Vishaal Kalwani Jan 22 '19 at 06:28

0 Answers0