Introduction
Laravel Forge makes it easy to install and configure multiple versions of PHP on your server. Each installed PHP version runs its own FPM process. In addition, you may update the PHP version used by specific sites at any time.Laravel Forge is only aware of PHP installations that are managed through the Forge dashboard and not manually installed on the server.
Managing PHP versions
When provisioning a server, you must decide which version of PHP you want to install by default. Thephp
binary on your server will point to the installed version selected at the time of its creation.
Once the server has been created, Laravel Forge makes it easy to install additional versions alongside the default version.
Installing PHP versions
To install a PHP version, navigate to the server’s dashboard and click the PHP tab. Then, click the Install version button, select the version to install and decide whether you want it to become the CLI default. Click Install to begin the installation process. When you install a new version of PHP onto your server, Laravel Forge will create and configure the PHP-FPM process for that version. This means that your server will be running multiple versions of PHP at once.Uninstalling PHP versions
To uninstall a PHP version, navigate to the server’s dashboard and click the PHP tab. Locate the version of PHP you want to remove, open the dropdown menu and click Uninstall PHP X.X and confirm the removal. PHP versions may be removed so long as:- There are other versions installed
- The version you wish to uninstall is not the server’s default version for new sites
- The version you wish to uninstall is not the server’s default version on the CLI
- The version you wish to uninstall is not used by any sites
PHP on the CLI
When an additional version of PHP has been installed, you may reference it on the CLI viaphpx.x
, replacing the x.x
with the version number (e.g., php8.4
). The php
binary will always point to the active CLI version (if changed from the default).
Default PHP installation
The “default” PHP version is the version of PHP that will be used by default when creating a new site on the server. When selecting a new version of PHP as your server’s “default” version, the PHP versions used by existing sites will not be updated.Patching PHP versions
To patch a PHP version, navigate to the server’s dashboard and click the PHP tab. Identify the version of PHP you want to patch, open the dropdown menu and click Update.Typically, patch updates should not cause any breaking changes to your server, although a few seconds of downtime is possible. We recommend that you exercise caution when patching PHP.
Common PHP configuration settings
Changing the following settings will apply the changes to all versions of PHP installed on the server.Max file upload size
You may configure the maximum file upload size through the PHP tab of the server management dashboard. This value should be provided in megabytes. For reference,1024MB
is 1GB
.
Max execution time
You may configure the maximum execution time through the PHP tab of the server management dashboard. This value should be provided in seconds.OPcache
Optimizing the PHP OPcache for production will configure OPcache to store your compiled PHP code in memory to greatly improve performance. If you choose to optimize OPcache for production, you should verify that your deployment script reloads the PHP-FPM service at the end of each deployment.OPcache is enabled by default for all newly created servers.
Beta and release candidates
PHP “beta” and “release candidate” releases are often available on Laravel Forge weeks before their final release. This allows you to experiment with upcoming major PHP versions on sites that are not in production. However, some Forge features, PHP features, and PHP extensions may not work as expected during that period.Once that PHP version becomes stable, you will need to fully uninstall and re-install the PHP version.