English
Deployment
Deployment is the process of downloading your code from your Git provider onto your server and running the deploy script. The site's Deployments page contains the following sections: Deploy Script, Deployment Histories, Site deploy key, Auto deploy and Deploy trigger URL.
The Deployment Histories table shows the date, branch, author, commit, duration, status and log of each deployment.
.env file
Some applications, such as Laravel applications, need an .env file to configure the database, cache, and so on. You can create and edit this file directly in FlashPanel.
On the site's Overview page > Utilities section > select .env. The file opens in an editor where you can edit and save it.
! Automatic .env file
When you install a Git repository containing a Laravel application, FlashPanel automatically creates the .env file from .env.example (or an empty .env file if the project has no .env.example), then sets the production environment, turns off debug mode and fills in the server's database connection details.
Automatic deployment
Auto deploy lets you deploy your project as soon as you push code to your Git provider. When you push to the configured deployment branch, FlashPanel pulls the latest code and runs your application's deploy script.
Steps to enable auto deploy:
- On the site management page, open Deployments in the left-hand menu
- In the Auto deploy section, click the
Enable auto deploybutton and confirm
INFO
The Auto deploy section only appears for sites installed from GitHub, GitLab or Bitbucket. For a self-hosted Git repository, use the deploy trigger URL.
Deployment script
The commands executed on your server when your project is deployed are defined by your site's deploy script. You can edit it in the Deploy Script section of the Deployments page, then click Update (or press Ctrl/⌘ + S) to save. Click the Custom Scripts icon in the corner of the editor to paste a saved script.
FlashPanel provides several variables for you to use; their actual values for your site are shown right above the editor:
bash
FLASHPANEL_SITE_ROOT='/path/to/yoursite.com'
FLASHPANEL_SITE_OWNER='site-owner'
FLASHPANEL_CODE_BRANCH='siteBranch'
FLASHPANEL_PHP='your-phpVersion'
FLASHPANEL_PHP_FPM='your-phpVersion-fpm'The default deploy script for a site installed from Git looks like this:
bash
cd $FLASHPANEL_SITE_ROOT
# Checkout lock file
if [ -f composer.lock ]; then
git checkout composer.lock
fi
if [ -f package-lock.json ]; then
git checkout package-lock.json
fi
git pull origin $FLASHPANEL_CODE_BRANCH
# Install Composer
# $FLASHPANEL_PHP /usr/local/bin/composer install --no-dev --optimize-autoloader --no-ansi
# echo 'Restarting FPM...';
# sudo -S service $FLASHPANEL_PHP_FPM reloadRemove the leading # from the commands you want to run.
PHP Versions
If you have multiple PHP versions installed on your server, your deploy script may need to be updated to use the correct PHP version.
By default, php always points to the PHP version used on the command line (CLI). If you need a different PHP version, call phpx.x, where x.x is the version (e.g. php8.3).
The deploy script for newly created sites uses the $FLASHPANEL_PHP environment variable. This environment variable always contains the site's current PHP version, so you don't need to change your deploy script when you switch the site's PHP version.
Environment variables
FlashPanel automatically injects the following environment variables into your deploy script at runtime:
| Variable | Description |
|---|---|
FLASHPANEL_SITE_ROOT | The site's root directory, e.g. /home/flashpanel/mysite.com |
FLASHPANEL_SITE_OWNER | The Linux user that owns the site. |
FLASHPANEL_CODE_BRANCH | The name of the branch to be deployed. |
FLASHPANEL_PHP | The PHP command for the site's PHP version (e.g. php8.3). |
FLASHPANEL_PHP_FPM | The site's PHP-FPM service name (e.g. php8.3-fpm). |
FLASHPANEL_PNPM | Path to the pnpm command of the site owner. |
WARNING
Environment Variables
FlashPanel prefixes every injected variable with FLASHPANEL_. Please do not use this prefix when defining your own environment variables.
Deploy from CI
Besides deploying from the FlashPanel dashboard or with Auto deploy, you can also deploy from the CI platform of your choice using the Deploy trigger URL.
- On the Deployments page > Deploy trigger URL section
- Click
Refresh trigger URLand confirm to generate a new URL, then copy it
INFO
Refreshing the trigger URL is available for paid users only.
Use the Deployment Trigger
You can deploy at any time by having your CI platform send a GET or POST request to the trigger URL.
You can refresh the URL at any time, but you'll then need to update every service that uses the old URL.
Deployment branch
You can change the branch deployed for your site. After changing the branch, click Deploy Now to deploy the code from the new branch.
Steps to update the deployment branch:
- On the site management page > open Settings > Update Git Branch section
- Select or enter the new branch name
- Click
Update
Steps to deploy manually:
- On the site management page > open Deployments
- Click
Deploy Nowat the top of the Deploy Script section
Git Remote
Updating the Git remote changes the repository URL on your server; the site is not removed or interrupted during this process. The new Git remote must contain the same repository/Git history as the currently installed repository.
You should not use this function to install a completely different project. If you want to install a different project, completely remove the existing code with Remove Code first.
Steps to update the Git remote:
- On the site management page > open Settings > Update Git Remote section
- Change the provider, Git account or repository address. See Site settings for details.
- Click
Update
Steps to remove code:
- On the site's Overview page > Danger Zone section > select
Remove Code - (Optional) Check
Delete Database,Delete Database User(only shown when the site has an attached database) andRestore default page? - Check
Yes, Do it!and clickRemove Code