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

thomvincent's avatar

Problem deploying on Forge

Hello,

I need to change the GitHub repository for a website and it's staging website. I read that all I had to do was remove the existing site which uses the old GitHub repository from the server and then add the site again using the new GitHub account.

I thought I would test this with the staging server first. The website was successfully deleted. I then began the process of adding the website using the new GitHub repository.

I start by creating a new .env file using the Environment tab in Forge. I can confirm that the .env is created and that all the details are correct - I've checked five times. Everything is connecting well and the deployment begins, but then the following error is thrown. I've also tried deploying using the old GitHub account, but the same error occurs. It appears that during the process of deployment the .env is deleted which is most likely causing the problem.

Generating autoload files
> php artisan clear-compiled

                                                                                          
  [PDOException]                                                                          
  SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using password: NO)  
                                                                                          

Script php artisan clear-compiled handling the post-install-cmd event returned with an error

                      
  [RuntimeException]  
  Error Output:       
                      

install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-plugins] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--ignore-platform-reqs] [--] [<packages>]...
0 likes
9 replies
alexhackney's avatar

Are you using the database settings for the database that were emailed to you when you provisioned the server in forge?

thomvincent's avatar

I certainly am @alexhackney. And I've confirmed they're correct by connecting to the database using Sequel Pro and typing mysql -p after I sshed into the instance.

alexhackney's avatar

So you are adding the site to the server.

Then going in to the site page and installing the repository.

Then ssh'ing in to the server to setup the .env.

AND adding the database to mysql.

Once thats done, going back to forge and deploying?

Alex

thomvincent's avatar

Hello Alex,

This is my step by step process.

  1. I log into Forge and select my server.
  2. I click on the Sites tab and enter the following details for the site: Root Domain: staging.website.com Web Directory:
  3. I click 'Add Site'.

The website is created. If I ssh into the instance I can see the following directory: /home/forge/staging.website.com/index.php

  1. I click on the 'Manage' link for the website: staging.website.com
  2. I click on the 'Environment' tab, then click 'Edit Environment'. I enter all the relevant data in the pop and save.

If I ssh into the instance I can see the .env file has been created in the following directory: /home/forge/staging.website.com/

  1. I click on the 'Apps' tab, and enter the following information and click 'Install Repository'. Provider: Github Repository: thomvincent/website Branch: develop Installation Options: Checked

The deployment begins, but then throws the error I posted above. If I ssh into the instance I can see the following directory is now empty. The index.php and .env have been deleted. /home/forge/staging.website.com/

I'm using Forge to generate all the relevant files and folders. I only sshed in to see what was happening.

thomvincent's avatar

Hello Alex,

I just tried reversing Step 5 & Step 6.

As expected the 'App' did not install because of the missing DB information because there was no .env file. And then added the relevant environment information via the 'Environment' tab.

My final option is to spin up a new instance and start completely from scratch which makes Forge a little less useful that I had hoped.

Thanks for your suggestions Alex. Thom

alexhackney's avatar

@thomvincent I have 20+ sites on forge and have not had the issue you have.

You have to install the repository before you create the .env.

Then you have to setup the .env before deploying.

You can use the database named forge without logging in to mysql. If not then you have to log in to mysql and

create database whatever; 

or there is no database to install to. That's pretty common and standard.

Installing the repo != deploying the site.

thomvincent's avatar

Hello @alexhackney.

Got it working this morning on the same server. I just unchecked the "Composer" checkbox when I installed the Repository.

Thanks for being a sounding board, Thom

3 likes
jgnasser's avatar

Unchecking "Install Composer dependencies" when installing the repo worked for me too. Thanks!

Please or to participate in this conversation.