• Isaac's Newsletter
  • Posts
  • How to deploy a Laravel project with Laravel Vapor (& AWS) in 6 easy steps

How to deploy a Laravel project with Laravel Vapor (& AWS) in 6 easy steps

Deploy your very first Laravel project to Laravel Vapor in ~15 minutes

Step 1: Head over to: https://vapor.laravel.com/ and create an account.

You can get away with a Free account for a little bit, but if this is a project that you want to make into a SaaS and make $ on, I’d just bite the bullet and go ahead and subscribe. After your first 5-6 subscribers, it pays for itself, and you can launch all your future projects on here for no extra cost.

Step 2: Whether you go with the free or paid version, you’ll need to link Vapor to an AWS account. I know AWS can be scary but don’t worry, I’ll walk you through it and after the initial AWS setup, you’ll rarely login there again.

Step 3: Go to: https://signin.aws.amazon.com/signup?request_type=register and create an account.

After you’re signed up, you should land on this screen called “Console Home.” Click your username in the top right of the screen and look for the “security credentials” tab. Click that.

Scroll down on the page until you see the “Access Keys” section and click “Create Access Key”.

You will see this screen. Click “I understand” and “Create Access Key.” We will cover IAMs and alternative approaches in a future newsletter, but this is required for Vapor to work.

Finally, you’ll have what you need. Copy your “Access Key” (what’s hidden behind the grey box) and click “show” on the secret access key. Make sure you store this secret access key in a safe place. If you lose it, you’ll need to create another one.

 

Step 4: Enter your AWS credentials.

Take the access key and the secret access key from Step 3 and enter them in on this screen (this popup will appear after you click “Link AWS”)

Don’t forget to enter in your monthly budget. I’d set this around $25 unless you’re expecting millions and millions of users. In my experience, each project costs around ~$18-20/month on AWS.

Keep in mind, this is on top of the $39/month Laravel Vapor subscription.

I have 5 projects deployed on AWS and these are my monthly costs. All things considered, it’s cheap.

After you’re done, your screen should look like this.

Step 5: Create/Connect your Laravel project

I have never done a “Fresh Laravel Project” from Vapor. You could if you wanted to, but it doesn’t make sense to me to start paying AWS costs before the project is ready. The rest of this tutorial will assume that you already have a Laravel project running locally on your machine.

If you don’t know how to setup a Laravel project on your machine, check out this article I wrote: https://isaac-saas.beehiiv.com/p/saas-project-14-step-guide

Click “Existing Laravel Project”

Give your project a name, ideally whatever your repo is called locally on your machine, then click “create”

You’ll land on a screen that looks like this. Now we’re ready to rock and roll.

Copy that first command, and head over to your terminal

composer require laravel/vapor-core

Click enter. Once it’s done running, your terminal should look something like this.

Go back to Vapor and copy the second command you see there. Pay close attention. Vapor says to run: composer global laravel/vapor-cli, but I personally don’t like to install this globally. I like to install it on a project by project basis, plus I’ve run into trouble time and time again installing it globally. Run this, it’s better (same command, just no “global”)

composer require laravel/vapor-cli

Click enter. Once that’s done running, your terminal will look something like the image above.

Head back to Vapor. Again, pay attention closely to this step. You will need to create a new file in the root of your project called vapor.yml.

You have two options:

1) You can open the project in VS code, or whatever text editor/IDE you use and do it manually. If you want to do it this way, I’ll leave that up to you.

2) Or, run this in your terminal:

touch vapor.yml

All touch does is create a new file. If you’ve never run this command before, remember it. You’ll use it a lot.

Copy all that stuff you see in the Vapor UI into your vapor.yml file. It should look something like this:

Head back to Vapor.

Copy and paste this into your terminal:

vapor login

Press enter.

If you see “command not found: vapor”, don’t worry.

Add this before the vapor login command:

php vendor/bin/vapor login

Press enter.

You’ll be prompted to enter the email address and password you used to create your Laravel Vapor account in Step 1.

Once you’re done with the email and the password, you’ll see this.

We’re almost done!

Run this command in your terminal:

php vendor/bin/vapor deploy production

This will take 2-3 minutes and will look like this once it’s finished deploying.

Take that URL and plop it into the browser and voilá, you now have a Laravel project that’s live on the world wide interwebz.

Head back over to Laravel Vapor and your UI should now look like this. Make sure the URL you see there below “production” matches what you see in your terminal.

Step 6: Create & connect a database

This is important, obviously. If you try to register a user for your project, you’re going to run into a 500 server error.

Click into your project in Vapor.

You should now see a screen like this. Click “create database”

Give it a name. I’d use the same name as your project in Vapor and the same name as your repo locally, just to keep things consistent. The “~$15/month” you see here is what I mentioned earlier about the AWS costs. In my experience, this has been right around $18/month. Click “create”

Next, you’ll see a screen like this.

Save these credentials. Probably in the same place you stored your AWS Access ID and AWS Secret Key? I’ll leave that up to you. We’ll use these later to login to a database GUI, like Table Plus, so we can more easily see what’s in our database.

Now we wait. The database is going to take around ~10 minutes to provision. Go run a lap around the neighborhood. Get a drink. Follow me on X if you don’t already: https://x.com/isaac_saas - Do whatever you gotta do.

Once the database is done provisioning, it will look like this:

In the bottom left is your database host and in the top right is your database password. You can take these values over to any database GUI and connect directly to your database. I prefer TablePlus: https://tableplus.com/

Ok. We’re almost done setting up the database.

We’re going to open up VS Code, or whatever IDE you use, and navigate back to our vapor.yml file and add this to line 5:

database: [your-database-name]

Remember, this must match whatever you named your database in the Laravel Vapor UI.

After you have that saved, we’re going to head back to our terminal and run this command again:

php vendor/bin/vapor deploy production

Once that’s done deploying (~2-3 minutes), our database is officially connected.

All that’s left to do is run our first migration on the production database so that we have some tables.

Head back to Vapor. Click into your project in the left navigation bar. Click “production” like we did earlier, then find the “commands” tab on the top.

Click “run command” and then enter this command:

php artisan migrate —force

Click “run.” Once that’s done, you’ll see a screen like this:

(Quick note: you should always be careful when running any type of —force command. This is what we’d call a quick and dirty hack. It’s fine because this is our first migration, but as your project matures you can really shoot yourself in the foot by doing this. Always make sure your database is backed up, etc.)

Let’s go! We’re done! Head back to your URL where your project is deployed and register with your first user.

If you setup Table Plus ealier, you’ll see your first user here after you register.

In my next article, hopefully next week, I’ll show you how to connect this project to a custom domain name and setup your MX records so you can send/receive email from your Laravel app.

Cheers,

Isaac 💪