Skip to content
zefıly

How to host Laravel on your own server

Zefily serves a Laravel app from its public folder as a PHP site, and each deploy from Git becomes a new release. This guide sets up your repository, the production environment, the database, the scheduler and the queue workers.

Before you start

  • A server connected to Zefily with a PHP web stack; choose a PHP version your app supports.
  • Your Laravel app in a Git repository. GitHub repositories connect through the Zefily GitHub App.
  • A database: MariaDB or PostgreSQL on the server, or one you connect from the Databases pane.

Steps

  1. 1. Add the site

    Open the server, choose Sites, then Add site. Select Runs on: PHP, choose the PHP version your app needs and enter the domain with HTTPS on.

  2. 2. Connect the repository

    On the site's Deploy pane choose the Laravel preset and your repository. The preset sets the public folder to public, fills in the build commands and keeps .env and storage as shared paths.

  3. 3. Write the production .env

    Open Edit .env and set APP_ENV=production and APP_DEBUG=false. Click Add APP_KEY to generate the application key, or paste the key you generated locally.

  4. 4. Connect the database

    Create or choose a database on the Databases pane and connect it to the site. This fills in the DB_ values in the .env, so you do not type the password into the repository.

  5. 5. Check the release commands and deploy

    Before the first deploy, read the build and release commands on the Deploy pane and change them if your app needs more. Then click Deploy now. Zefily switches the site to the new release only after the build succeeds.

  6. 6. Turn on the scheduler and queue workers

    On the Deploy pane turn on Scheduler (every minute), which runs php artisan schedule:run. Set the number of Queue workers and click Apply. Workers restart after every deploy.

  7. 7. Optional: enable Octane

    For faster responses add laravel/octane to the repository, commit and deploy. Then set the Workers and Requests per worker, and click Enable Octane. Test the app under Octane first, because workers keep state between requests.

Verify it works

Open the domain: the page loads over HTTPS. Open the Deploy pane and run migrate:status with Run to confirm the migrations are applied, and check the Logs pane with the Laravel source for new errors.

Troubleshooting

Error 500 after a deploy
Open the Logs pane and choose the Laravel source. The usual causes are a missing APP_KEY, or a wrong path or database value in the .env.
Migrations fail
Check that the DB_ values in the .env match the connected database. Migrations run as the site user, so the database user must be able to change its tables.
The scheduler or the queue does not run
Check that the scheduler is on and that the number of queue workers is above zero, then click Apply. Every deploy restarts the workers.

Questions

Can I use SQLite?

The one-click Laravel uses SQLite only when the server has no database. For your own app connect MariaDB or PostgreSQL from the Databases pane.

Do I need Redis?

No. Turn on the Object cache to use Valkey for the cache and sessions, which Laravel reads as CACHE_STORE=redis.

Can I run Laravel Reverb for WebSockets?

Yes. Add a location for Reverb on the nginx pane, then run Reverb as a daemon of the site user.

Read next

Start on a server you own

Create your account, connect a server and follow the guide. The server stays yours: you pay your provider.

Start free

Black Friday & Cyber Monday

Before you go: lifetime plans are on sale

Pay once for a lifetime plan, or get 30% off the first year of any yearly plan.

Only 100 lifetime plans per plan. When they are gone, they are gone.

See the campaign

Amazing November

See the campaign →