HartleySan
HartleySan

Reputation: 7810

How do I move a local Laravel project to an AWS server?

I have a localhost Laravel project running on Windows 10 with XAMPP, and everything's working fine. I now want to move this project to AWS so that I can share it with other people.

Specifically, I want to put it on an EC2 server with Apache and PHP 7.0+, and then put the MariaDB instance on an RDS instance that I'll connect to.

I know how to set up an EC2 instance and an RDS instance. I also know how to set up the MariaDB instance an edit the .env file to point to the RDS MariaDB instance.

What I don't know how to do though is move / set up the Laravel project on the EC2 instance so that all of my files are there and when I go to the IP address of the EC2 instance, it loads the root controller (i.e., Route::get('/', function () { ... })).

My thought process was to move everything over so that the public folder of my Laravel project matched up with the /var/www/html/ directory on the server, but maybe that's not right.

Also, should I copy all the npm/composer files over from my local project to the server (via FTP, etc.), or should I skip those and then run an npm install and composer install (sorry, don't recall the exact command) once all the other files are on the server?

Do I need to edit the Apache config to get things working? How? What kind of file permissions need to possibly be set?

These are the main questions I have, but I may be missing other stuff as well. Thank you.

Upvotes: 0

Views: 1286

Answers (1)

Harry
Harry

Reputation: 399

You will have to set the document root equal to the public folder of your project. So normally the site will be at /var/www/yoursite/ and the document root in your apache config will be /var/www/yoursite/public. That way the route '/' will be your public folder. The /var/www/html folder will be the default document root of apache which must be left alone. In the folder /var/www/yoursite you can pull your changes from github and then run composer install and npm install.

Upvotes: 1

Related Questions