Laravel is one of the most popular web frameworks for PHP and for good reason. It comes bundled with most common web app needs, including authentication, authorization, localization, and support for multiple database backends including PostgreSQL.
In this guide, were going to deploy a simple Laravel 10x web app using Renders native PostgreSQL and Docker support.
Lets get started!
Create a new PostgreSQL database on Render and copy the internal DB URL to use below.
Fork hoangsvit/laravel-10x-docker and create a new Web Service on Render, giving Render permission to access your forked repo.
Select Docker
for the runtime, and add the following environment variables under the Advanced section:
KEY | VALUE |
---|---|
DATABASE_URL |
The internal database URL for the database you created above. |
DB_CONNECTION |
pgsql |
APP_KEY |
Copy the output of php artisan key:generate --show
|
Thats it! Your Laravel web app will be live on your Render URL as soon as the build finishes. You can test it out by registering and logging in.
Modifying an Existing Laravel App for Render
The commit history of our sample repo is useful in understanding the modifications needed for an existing Laravel app.
If you havent already, make sure to run php artisan make:auth
to generate authentication scaffolding for your app.
Force HTTPS on all assets served by Laravel to avoid mixed content warnings in the browser. Render already manages and terminates TLS certificates for you, but Laravels asset helper needs to be configured to serve everything over TLS. You can do this by following the changes in Force HTTPS for Laravel.
Configure your repo to deploy Laravel using Docker and NGINX. Were building on the nginx-php-fpm Docker image as shown here, and adding php-fpm configuration for NGINX to tie everything together.
Finally, add a deploy script that will be run when your PHP app starts up.
You should now be able to deploy your existing Laravel app on Render.
Top comments (0)