|
| 1 | +--- |
| 2 | +id: 68d936b0-b1b0-431d-bbe0-a8356decf251 |
| 3 | +blueprint: page |
| 4 | +title: 'Deploying Statamic with Laravel Cloud' |
| 5 | +intro: |- |
| 6 | + Laravel Cloud is a fully managed infrastructure platform. It's relentlessly optimized for Laravel and PHP. It's our favorite way to deploy Statamic sites that need to scale. |
| 7 | +parent: c4f17d05-78bd-41bf-8e06-8dd52f6ec154 |
| 8 | +--- |
| 9 | +Before deploying to Laravel Cloud, there are a few things you should do to prepare your Statamic site: |
| 10 | + |
| 11 | +* Right now, Statamic's [Git automation](/git-automation) doesn't work on Laravel Cloud. You can work around this by either: |
| 12 | + * Moving [content](/tips/storing-content-in-a-database) and [users](https://statamic.dev/tips/storing-users-in-a-database) into the database. |
| 13 | + * Disabling the Control Panel on Laravel Cloud, and pushing any content changes from your local environment. |
| 14 | +* You should move any assets from the local filesystem to Laravel Cloud's object storage feature. |
| 15 | + |
| 16 | +If you don't want to move content to a database, we recommend using a VPS-based solution, like [Laravel Forge](/deploying/laravel-forge). |
| 17 | + |
| 18 | + |
| 19 | +## Creating your application |
| 20 | + |
| 21 | +Once you've created your [Laravel Cloud](https://app.laravel.cloud) account, click "New application" to get started. |
| 22 | + |
| 23 | +If it's your first application, you'll be asked to connect your Git provider of choice (GitHub, GitLab or Bitbucket). |
| 24 | + |
| 25 | +From there, select the repository you want to deploy, give it a name and pick the region where you want your application deployed. |
| 26 | + |
| 27 | +<figure> |
| 28 | + <img src="/img/deployment-cloud-new-application.png" alt="New application modal"> |
| 29 | +</figure> |
| 30 | + |
| 31 | +Upon creation, you can setup any "resources" needed for your application, like a database or object storage bucket. |
| 32 | + |
| 33 | +<figure> |
| 34 | + <img src="/img/deployment-cloud-project-overview.png" alt="Application overview"> |
| 35 | +</figure> |
| 36 | + |
| 37 | +Make sure to click "Save" after making changes to your application's resources. |
| 38 | + |
| 39 | +:::tip Note |
| 40 | +New applications on Laravel Cloud use PHP 8.4 by default. However, some of Statamic's third-party dependencies still need to be updated for PHP 8.4. |
| 41 | + |
| 42 | +For the time being, we recommend downgrading to PHP 8.3 in your environment's settings. |
| 43 | +::: |
| 44 | + |
| 45 | +### Creating a database |
| 46 | + |
| 47 | +If you're storing content and users in the database (which), you'll need to create a database cluster in Laravel Cloud. You can do this from the environment overview page: |
| 48 | + |
| 49 | +<figure> |
| 50 | + <img src="/img/deployment-cloud-new-database-cluster.png" alt="New database cluster modal"> |
| 51 | +</figure> |
| 52 | + |
| 53 | +Once you've created your database cluster, you'll probably need to import data from an existing database you might have, whether that be locally or from a staging server. |
| 54 | + |
| 55 | +You can use a database GUI, like [TablePlus](https://tableplus.com/) to do this. |
| 56 | + |
| 57 | +1. Open your existing database, select all of the tables, and right click "Export". Make sure to save your export as a `.sql` file. |
| 58 | +2. Connect to your new Laravel Cloud database using the "View credentials" button. |
| 59 | + |
| 60 | + <figure> |
| 61 | + <img src="/img/deployment-cloud-db-credentials.png" alt="Database credentials modal"> |
| 62 | + </figure> |
| 63 | + |
| 64 | + If you're using TablePlus (or another GUI that supports it), you can open the database directly from the "Deeplink" tab. |
| 65 | +3. Finally, import your database by right-clicking the tables list and selecting "Import -> From SQL File". From here, you can choose the `.sql` file you just exported. |
| 66 | + |
| 67 | + |
| 68 | +### Creating an object storage bucket |
| 69 | + |
| 70 | +Since the [Git Automation](/git-automation) doesn’t work on Laravel Cloud, we recommend moving assets to Laravel Cloud's object storage service. |
| 71 | + |
| 72 | +You can create a new bucket from the environment overview page: |
| 73 | + |
| 74 | +<figure> |
| 75 | + <img src="/img/deployment-cloud-new-bucket.png" alt=""> |
| 76 | +</figure> |
| 77 | + |
| 78 | +It'll ask you which filesystem disk the bucket should provide. This should match a disk in your `config/filesystems.php` config file. |
| 79 | + |
| 80 | +Once created, you can upload existing assets using an app like [Transmit](https://panic.com/transmit/), [Cyberduck](https://cyberduck.io/), or any similar app that supports S3-compatible filesystems. |
| 81 | + |
| 82 | +## Deploying your application |
| 83 | + |
| 84 | +Now that you've got everything set up, all thats left to do is trigger your first deployment. 🚀 |
| 85 | + |
| 86 | +If you're using Vite to build CSS/JavaScript, make sure to uncomment the `npm` commands in your application's deployment settings. |
| 87 | + |
| 88 | +For more information about Laravel Cloud, please see its [documentation](https://cloud.laravel.com/docs). |
| 89 | + |
| 90 | + |
| 91 | +## Troubleshooting |
| 92 | + |
| 93 | +### Upstream sent too big header while reading response header from upstream |
| 94 | + |
| 95 | +You may encounter this error when submitting a form on the frontend, or updating content in the Control Panel. |
| 96 | + |
| 97 | +You can fix it by changing your application's session driver from `cookie` to another driver, like `database` or `redis`. |
| 98 | + |
| 99 | +You can find more information about session drivers on the [Laravel documentation](https://laravel.com/docs/12.x/session#introduction). |
0 commit comments