Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EC2 web application folder structure

I have a web application which is currently working fine on my local machine and I am now trying to get it to work on EC2.

I transferred the index.php file into the folder /var/www and I am able to access it by visiting my elastic IP (for example, http://123.45.678.910/ ).

The trouble is that I also added the folder named restAPI into the folder /var/www which in turn has several files. When I try to access restAPI/index.php by going to the URL - http://123.45.678.910/var/www/restAPI/index.php, it gives me a 404 error.

like image 363
Ashish Agarwal Avatar asked Feb 07 '26 05:02

Ashish Agarwal


1 Answers

There are two things at play here:

  1. The file system path
  2. The URL path

If you're running an Amazon Linux image, your web content should be deployed inside /var/www/html -- as is the case with just about every reasonable Linux installation.

If your index page is stored at /var/www/html/index.php, then your URL will be http://123.45.678.910/index.php.

If you're trying to access http://123.45.678.910/var/www/restAPI/index.php, it means that you uploaded your file to /var/www/html/var/www/restAPI/index.php.

Make sense?

like image 186
Ryan Parman Avatar answered Feb 09 '26 09:02

Ryan Parman