Deploy a Laravel App on Tanzahost: Step-by-Step Guide
Asha puts laravel-blog live on Tanzahost: the plan from your code, MySQL, encrypted variables, migrations, workers and your own domain.
Updated 17 Nov 20269 min read
You have a Laravel app that runs on your computer and no deploy config to write. By the end of this post your app is live on Tanzahost with its database, cache, encrypted variables, migrations on every deploy and your own domain. Asha put the open-source laravel-blog online this way, in her project blog, in location UK-02 · United Kingdom.
What you need before you start
Your Laravel app in a GitHub repository, as a ZIP file, or as a public repository's link.
composer.jsonandcomposer.lockcommitted. We know it's Laravel when the code has anartisanfile andcomposer.jsonrequireslaravel/framework. That is all we need: nothing else has to change.A Tanzahost account with a card saved.
Leave your .env file out of Git. It holds passwords. Its settings become encrypted variables instead.
Create the project and add the app
Choose New project and pick the location closest to your visitors
In the dashboard, choose New project, give it a name, and pick its location: the one closest to your visitors. Asha chose UK-02 · United Kingdom.
Add the service and point it at your code
In the project, choose Add a service, then App or website. Name the app, then choose GitHub and pick your repository and branch, or paste a public repository's link.
Read the plan before anything is built
The page reads your code and shows a plan: the PHP version, the extensions, the database, cache and email we'll make, the variables we'll fill, and the workers your code needs, each with why and with its price a month first. For laravel-blog it says:
Laravel 11 on PHP 8.4, with Node.js 22 and Yarn 4.5.1 for the assets;
extensions added for your code:
pcntl(Horizon),exifandgd(pictures),zip(backups),redis(your queue);a MySQL database, a cache for your queue, and email from your project, each with its price a month first;
Horizon as a worker, with its price;
Needs your key: Pusher (live comments), which stays off until you add it.
We read the files that say what your code needs and run none of them: require.php in composer.json, config.platform.php, the php every package in composer.lock accepts, package.json, config/*.php and .env.example. Build and deploy files your code carries for other hosts are read as hints only, never run.
The PHP version is the newest one all of those allow; our default is PHP 8.4. laravel-blog asks for ^8.3, but its lock holds nette/schema, which stops at 8.4, so its plan says "PHP 8.4 (your packages accept 8.3 and 8.4)". The health address is /up, which Laravel 11 and later declare: it answers without the database, so a new version is not held back by a home page that needs data.
To choose something else, change it on the plan, in the app's Set up and run settings, or in the settings file at /docs/apps/settings-file: your choice wins. If your packages don't accept a version you picked, the plan says so before the build and offers the one they accept.
Decide what the app should get, and set its limits
Make the database, cache and email for me is on. Turn it off if you'd rather add them later. A new account starts on the shared MySQL, which costs least; you can choose A database server of its own instead.
Then set its limits: the most memory and processor time it may use. They cost nothing by themselves.
A new Laravel app's .env.example has DB_CONNECTION=sqlite. A file database would be lost at every deploy and can't be backed up or shared by two copies, so we make MySQL for it instead: Laravel works with it as it is. If you really want the file, choose Keep SQLite (one copy only) on the plan; the file then lives in a folder kept between deploys and the app runs as one copy.
Choose Deploy
Choose Deploy. The button says Making the database… first: the database and cache are made and connected before your app's first version starts. You watch the build's log live; see /docs/apps/deploying.
Your variables, made for you
Open your app's Variables tab. Values are stored encrypted, shown masked, and given to your app when it starts. Before your first deploy we fill them from your code's .env.example, by kind:
| Kind | Example | What we do |
|---|---|---|
| Made | APP_KEY | A new key, base64: and 32 random bytes, kept encrypted |
| Filled | APP_URL, APP_ENV=production, APP_DEBUG=false, LOG_CHANNEL=stderr | Your app's address, and production values |
| Copied | SESSION_DRIVER=file, SESSION_LIFETIME=120, APP_NAME | As your example writes them |
| From a service | DB_*, REDIS_*, MAIL_* | From the database, cache and email made for the app |
| Needs your key | PUSHER_*, AWS_*, STRIPE_* | Left empty and listed on the plan; BROADCAST_DRIVER stays on log |
We never copy a password, a token or an address on your own computer (localhost, 127.0.0.1, *.test) from the example, and we never replace a variable you set. A setting whose fallback points at a table your migrations don't make, like CACHE_STORE=database without a cache table, gets a working value: your cache, or file in the kept storage folder.
Email goes out from your project's email domain. If the project has none set up yet, messages go to the app's log and the plan says so, with Set up email. After you change a variable, the page says Redeploy to apply until a deploy uses it.
Migrations before visitors see the new version
When we make the database for your app, Run migrations on each deploy is on, in the app's Laravel card. On every deploy these run once, in their own sandbox, after the build and before visitors switch to the new version, each shown in the log:
php artisan migrate --force
php artisan optimizeA command of your own in Before going live runs after these. The link storage:link makes, from public/storage to your kept storage folder, is made by the build, so uploaded pictures show from the first deploy. artisan optimize is skipped, with a note, when code outside config/ calls env(), because Laravel's cached settings would hide those values.
If it fails, the deploy stops and the version before it keeps running. The deployment shows the command's last lines, so you can see why. The same card has Run migrations, Storage link, Clear cache, Maintenance on and Maintenance off.
Workers and the scheduler
When your code needs a queue worker, the plan adds one, on by default with its price shown: php artisan horizon when you use Horizon, otherwise php artisan queue:work --tries=3. When routes/console.php or withSchedule schedules tasks, the plan adds Laravel's scheduler every minute:
php artisan schedule:runWorkers are charged like an app, for what they use. See /docs/apps/processes and /docs/apps/scheduled-tasks.
Sample data, when you ask
If your code has a database seeder, the app's page offers Add the sample data once, after the first deploy. Nothing is seeded by itself. When the seeder writes a login everyone can read in the code, we say so first: for laravel-blog, "This creates the login demo@demo.com with the password demodemo. Change it straight after."
Connect your domain
Your app is already live on its free address, like blog-7h3k.tanzahost.co. On the app's Domains tab, choose Add your domain: use our nameservers, or add the records we show where your domain is registered. We check every minute. When the records are right, SSL is issued by itself, and the free address sends visitors to your domain. See /docs/domains/add-a-domain.
Every push to your branch now deploys without downtime. If a new version stops by itself within five minutes, visitors go back to the previous one by themselves.
Check that it worked
The build's log on the app's page shows the build finishing and the commands above running.
The Variables tab shows
APP_KEYmade andDB_*,REDIS_*,MAIL_*filled from the services. Values stay masked.The log shows
php artisan migrate --forceandphp artisan optimizerunning after the build.Upload a picture through your app: it appears at
public/storage, which provesstorage:linkwas made.Open the free address, then your domain. The domain answers with SSL, and the free address sends visitors there.
Mistakes people make, and how to fix each
Committing .env. It holds passwords. Leave it out of Git: its settings become encrypted variables on the app's Variables tab.
Picking a PHP version your packages reject. The plan says so before the build and offers the version they accept. To change anything on purpose, change it on the plan, in Set up and run, or in tanzahost.json (see /docs/apps/settings-file): your choice wins.
Needing something we don't offer. The plan says so in one sentence before anything is built, with Ask us to add it. You never wait ten minutes for a build that can't work.
A build that still fails. We read why, fix what we safely can, and try again by ourselves, at most twice: a missing PHP extension from our list, a PHP version your lock rejects, a build that ran out of memory. The next build's log starts with what we did, like "We added the PHP extension gd and tried again". If it still fails, the build's page shows What went wrong, What we did and What you can do, with a Fix it button for anything that needs your yes, and Ask Sali beside it.
A migration that fails. The deploy stops and the old version keeps running. Read the command's last lines in the deployment, fix the migration or the command, and deploy again.
Expecting artisan optimize every time. When code outside config/ calls env(), it is skipped with a note. The deploy still works.
Keeping scheduled tasks in app/Console/Kernel.php on Laravel 11. Laravel 11 doesn't load that file, and the page says so. The plan adds the scheduler when tasks are in routes/console.php or withSchedule.
Changing a variable and wondering why nothing happened. The page says Redeploy to apply until a deploy uses the new value.
Email that never arrives. The project has no email domain set up yet, so messages go to the app's log and the plan says so. Use Set up email.
Next
Watch a build and read a deployment: /docs/apps/deploying
Choose the PHP version, extensions, PHP settings and kept folders yourself: /docs/apps/settings-file
Queue workers and what they cost: /docs/apps/processes
Scheduled tasks: /docs/apps/scheduled-tasks
Point your domain at the app: /docs/domains/add-a-domain
Written with Sali, checked by our team.