Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

rajusutra's avatar

Laravel in GCP with Forge

Hi, is there any idea how to use forge with GCP?

0 likes
11 replies
bobbybouwmann's avatar

As far as I know you can't at this point. Forge is focused on a VPS where you can host your application. However Google Cloud doesn't work like that exactly. In general you connect a domain to Google Cloud and they provide you with a server. However Forge is focused on having your own server.

You can deploy to GCP, but just not with Forge AFAIK.

This might help: https://cloud.google.com/community/tutorials/run-laravel-on-appengine-flexible

rajusutra's avatar

Well AWS has this feature & AWS is listed in forge. GCP also has similar compute engine where it provides VPS like instance. I am not interested in GCP App Engine. Can someone give me idea how to use compute engine for laravel.

BGWeb's avatar

@bobbybouwmann It is definitely possible to use Forge (and Envoyer) with GCP. I am using them both for production grade applications. The process is not as straightforward/simple as using one of the included server providers (i.e. AWS, Linode, DO). See below for some info.

@rajusutra Like I said above, the process is not entirely as straight forward as using one of Forge's server providers. The basic process is below:

  1. Create a new Compute Engine instance to your specification. Wait for it to finish provisioning and copy the server's public IP.
  2. Sign into Forge and click the Custom VPS option. Fill in the details from your Compute Engine instance from step 1. Note, you have to specify the RAM size.
  3. Forge will give you a bash script/command to run on the server. This will provision the server with Forge's setup. Copy the ENTIRE script.
  4. You need to SSH into the CE instance by one of two ways: 1) Use the GCP Console, or 2) Add a SSH key to the server and SSH in from your desktop terminal.
  5. Paste the script from step 3 into the terminal and let it run. This will take some time as it installs the necessary software on your server. PHP, Nginx, etc.
  6. As this process is working, you should see the server listed in your Forge dashboard and showing a "Provisioning.." status. There should also be some logs for your server, indicating what is happening on the server.
  7. Once this process completes, you should be able to test the connection to your server through Forge and see "Successful."
  8. To test that the web server and default site are live, copy and paste the server IP into your browser. You should see a PHP Info page.

A couple things to note here: if you did not enabled HTTPS support on the CE Instance, you must explicitly tell your browser to visit http:// or you wont see the site. This also does not cover setting up the database or any "real" sites. Additional work is needed for these to work, although the process for doing so is no different than if you used any other provider in Forge.

This is a pretty high-level overview that I provided just off the top of my head after doing this for several projects and lots of practice. Hopefully this gets you going and if not, I can provide additional resources that will help.

4 likes
rajusutra's avatar

@bgweb Thanks for your reply. I will try it this week & surely inform you about the situation.

Unilorin's avatar

Wow thanks guys, Facing same challenge. now i wouldn't stress my self to create new discussion.

BGWeb's avatar

@rajusutra Have you had a chance to work through my suggestions? If it helped, please be sure to select my reply as the best answer. Thanks!

@bobbybouwmann Indeed, Forge is fairly flexible. You can basically connect it to any VPS you like. Obviously it is easier to use one of the pre-defined providers.

Miguejarias's avatar

Hi @bgweb. I tried your suggestions but the script seems to end yet the server still shows as "provisioning" on forge. When i check the events it says: "Performing Forge Nginx Maintenance. Permission denied (publickey)." Any thoughts?

Robstar's avatar

As this page ranks highly in Google I'll add some very concise instructions, as GCP (Goole Cloud Platform) does work on Laravel Forge:

  • On the GCP dashboard visit "Compute Instance" and then click "create instance"
  • Select your instance type ensuring the disk size is >= 25 GB and Operating System is Ubuntu 20.04 LTS (important: ensure you select the LTS version as specified at https://forge.laravel.com/docs/1.0/servers/providers.html#bring-your-own-server, otherwise certain Forge features won't work)
  • When the server has been created login as the root user (I'd recommend copying the gcloud command)
  • leave your terminal open
  • Within Forge visit https://forge.laravel.com/servers and click "custom VDS"
  • Enter the server IP address (copy from the GCP site)
  • Click "create server" and await for a modal to appear
  • Save the root password
  • Copy the provisoon command i.e. the string starting with "wget -O forge.sh ..."
  • Jump back to your terminal (ensuring you're the root user) and paste in the provision command
  • When the script has finished running you can visit the server public IP address and view a nice Forge landing page

That's it to be honest.

3 likes
Robstar's avatar

@extrabright Thanks, I literally just followed the same steps 3 days ago :)

Only thing I'd wish the Forge UI would mention and would stress here is the LTS point I mentioned.

It would be great if the Forge UI somehow indicated if the choice of a none LTS version of Ubuntu. I stupidly did this and couldn't upgrade to PHP 8.1 via Forge. Forge support recommended I create a new server from scratch.

Quick note too about the 20.04 vs 22.04 LTS choice. I did initially try 22.04 but found some essential packages I use don't work i.e. wkhtmltopdf. There were also other weird errors. I asume this is because 22.04 is still pretty new. I therefore used 20.04.

Please or to participate in this conversation.