{
    "url": "https://delaparra-services.nl/manuals/je-laravel-app-online-zetten",
    "locale": "en",
    "title": "Deploying a Laravel app · DeLaParra Services",
    "description": "Choosing between shared hosting, a VPS or a managed platform, and the steps to securely deploy and update a Laravel app.",
    "alternates": {
        "en": "https://delaparra-services.nl/manuals/je-laravel-app-online-zetten",
        "nl": "https://delaparra-services.nl/nl/handleidingen/je-laravel-app-online-zetten"
    },
    "formats": {
        "csv": "https://delaparra-services.nl/manuals/je-laravel-app-online-zetten.csv",
        "md": "https://delaparra-services.nl/manuals/je-laravel-app-online-zetten.md",
        "json": "https://delaparra-services.nl/manuals/je-laravel-app-online-zetten.json",
        "zip": "https://delaparra-services.nl/manuals/je-laravel-app-online-zetten.zip",
        "pdf": "https://delaparra-services.nl/manuals/je-laravel-app-online-zetten.pdf"
    },
    "downloads": [
        {
            "url": "https://delaparra-services.nl/manuals/je-laravel-app-online-zetten.csv",
            "encodingFormat": "text/csv",
            "name": "je-laravel-app-online-zetten.csv"
        },
        {
            "url": "https://delaparra-services.nl/manuals/je-laravel-app-online-zetten.json",
            "encodingFormat": "application/json",
            "name": "je-laravel-app-online-zetten.json"
        },
        {
            "url": "https://delaparra-services.nl/manuals/je-laravel-app-online-zetten.md",
            "encodingFormat": "text/markdown",
            "name": "je-laravel-app-online-zetten.md"
        },
        {
            "url": "https://delaparra-services.nl/manuals/je-laravel-app-online-zetten.pdf",
            "encodingFormat": "application/pdf",
            "name": "je-laravel-app-online-zetten.pdf"
        },
        {
            "url": "https://delaparra-services.nl/manuals/je-laravel-app-online-zetten.zip",
            "encodingFormat": "application/zip",
            "name": "je-laravel-app-online-zetten.zip"
        }
    ],
    "markdown": "# Putting your Laravel app online\n\nYour app works on your laptop. Now it needs to run on a server so that others can use it. This is called **deployment**.\n\n## Step 1: Choose where your app will run\n\n| Option | For whom | Please note |\n|---|---|---|\n| **Managed platform** (Laravel Cloud, or a PaaS that supports PHP) | You don’t want to manage servers | More expensive per month, but low maintenance |\n| **VPS with a management tool** (e.g. Laravel Forge or Ploi on a VPS) | You want control but not the hassle | You pay for the VPS and the tool separately |\n| **Bare-metal VPS** | You’re familiar with Linux | You’re responsible for updates and security |\n| **Shared hosting** | Small websites with no queues | Often no SSH, no queue workers, outdated PHP versions |\n\nFor most small business apps, a managed platform or a VPS with a management tool is the best choice.\n\n## Step 2: Prepare the server\n\nThe server requires: the correct **PHP version** (the same as on your local machine), **Composer**, a **database**, and **Node.js** if you are building the front-end on the server.\n\nImportant: the web server must point to the **`public/`** folder, not to your project’s root folder. Otherwise, anyone will be able to download your `.env` file.\n\n## Step 3: Set up the environment properly\n\nCreate a `.env` file on the server (see *.env and environment variables*) containing at least the following:\n\n```dotenv\nAPP_ENV=production\nAPP_DEBUG=false\nAPP_URL=https://jouwdomein.nl\n```\n\nGenerate a key once: `php artisan key:generate`. Never change it again.\n\n## Step 4: the deployment steps\n\nThese are the commands that run with every new version (an administration tool does this automatically):\n\n```bash\ngit pull origin main\ncomposer install --no-dev --optimize-autoloader\nnpm ci && npm run build\nphp artisan migrate --force\nphp artisan optimize\nphp artisan storage:link      # alleen de eerste keer\nphp artisan queue:restart\n```\n\nThe `--force` option with `migrate` is required in production, as Laravel would otherwise ask for confirmation. **Make a backup of your database before running a migration.**\n\n## Step 5: Background tasks\n\n- **Queue workers** (sending emails, generating PDFs) must continue to run. On a VPS, you can manage this using Supervisor; managed platforms have a setting for this.\n- **Scheduled tasks:** Add one cron job that runs `php artisan schedule:run` every minute.\n\n## Step 6: HTTPS and domain\n\nPoint your domain (DNS) to your server and obtain a free certificate via Let’s Encrypt. Most management tools allow you to do this with a single click. Ensure that `APP_URL` begins with `https://`.\n\n## Automatic deployment\n\nUsing GitHub Actions or your management tool’s deploy hook, your app will be updated automatically after every push to `main`. Run your tests first, and only deploy if they pass.\n\n## Errors after deployment\n\n| What you see | Probable cause |\n|---|---|\n| 500 error | Check `storage/logs/laravel.log`; often caused by a missing `.env` value or directory permissions |\n| 502 Bad Gateway | PHP-FPM is not running or the wrong version of PHP is being used |\n| 503 | The app is still undergoing maintenance: `php artisan up` |\n| Styles missing | `npm run build` not run or incorrect `APP_URL` |\n| 419 in forms | Session/cookie settings or HTTPS configuration |\n\nSee also *Understanding HTTP status codes and troubleshooting API errors*.\n\n## Need help?\n\nWould you like to have your app built in a reliable, low-maintenance way? This falls under **Bespoke software and web applications**. For websites: **Web design and development**.\n\n## Skills\n\n- [Deploying with Laravel Cloud] (/nl/skills/deploying-to-cloud)\n- [Deployment Pipeline Design] (/nl/skills/deployment-pipeline-design)\n- [GitHub Actions Templates] (/nl/skills/github-actions-templates)\n- [Laravel environment and config] (/nl/skills/laravel-env-config)\n\n## Related services\n\n- [Maatwerk software en webapplicaties] (/nl/services#service-03)\n- [Webdesign en -ontwikkeling] (/nl/services#service-01)\n\n",
    "structured_data": {
        "@context": "https://schema.org",
        "@graph": [
            {
                "@type": "TechArticle",
                "@id": "https://delaparra-services.nl/manuals/je-laravel-app-online-zetten#article",
                "url": "https://delaparra-services.nl/manuals/je-laravel-app-online-zetten",
                "headline": "Deploying a Laravel app",
                "description": "Choosing between shared hosting, a VPS or a managed platform, and the steps to securely deploy and update a Laravel app.",
                "inLanguage": "en",
                "subjectOf": {
                    "@id": "https://delaparra-services.nl/manuals/je-laravel-app-online-zetten#dataset"
                }
            },
            {
                "@type": "Dataset",
                "@id": "https://delaparra-services.nl/manuals/je-laravel-app-online-zetten#dataset",
                "name": "Deploying a Laravel app",
                "description": "Choosing between shared hosting, a VPS or a managed platform, and the steps to securely deploy and update a Laravel app.",
                "url": "https://delaparra-services.nl/manuals/je-laravel-app-online-zetten",
                "identifier": "https://delaparra-services.nl/manuals/je-laravel-app-online-zetten#dataset",
                "about": {
                    "@id": "https://delaparra-services.nl/manuals/je-laravel-app-online-zetten#article"
                },
                "publisher": {
                    "@type": "Organization",
                    "name": "DeLaParra Services",
                    "url": "https://delaparra-services.nl/"
                },
                "isAccessibleForFree": true,
                "inLanguage": "en",
                "isPartOf": {
                    "@type": "Dataset",
                    "@id": "https://delaparra-services.nl/manuals#dataset",
                    "name": "Manuals for working on your own app",
                    "url": "https://delaparra-services.nl/manuals"
                },
                "includedInDataCatalog": {
                    "@type": "DataCatalog",
                    "@id": "https://delaparra-services.nl/knowledge-hub#catalog",
                    "name": "Knowledge hub data catalog",
                    "url": "https://delaparra-services.nl/knowledge-hub"
                },
                "distribution": [
                    {
                        "@type": "DataDownload",
                        "name": "je-laravel-app-online-zetten.csv",
                        "encodingFormat": "text/csv",
                        "contentUrl": "https://delaparra-services.nl/manuals/je-laravel-app-online-zetten.csv",
                        "inLanguage": "en"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "je-laravel-app-online-zetten.json",
                        "encodingFormat": "application/json",
                        "contentUrl": "https://delaparra-services.nl/manuals/je-laravel-app-online-zetten.json",
                        "inLanguage": "en"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "je-laravel-app-online-zetten.md",
                        "encodingFormat": "text/markdown",
                        "contentUrl": "https://delaparra-services.nl/manuals/je-laravel-app-online-zetten.md",
                        "inLanguage": "en"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "je-laravel-app-online-zetten.pdf",
                        "encodingFormat": "application/pdf",
                        "contentUrl": "https://delaparra-services.nl/manuals/je-laravel-app-online-zetten.pdf",
                        "inLanguage": "en"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "je-laravel-app-online-zetten.zip",
                        "encodingFormat": "application/zip",
                        "contentUrl": "https://delaparra-services.nl/manuals/je-laravel-app-online-zetten.zip",
                        "inLanguage": "en"
                    }
                ]
            }
        ]
    }
}