# Laravel Forge Forge is a server provisioning, and management tool for [[Laravel]] applications. It makes it a breeze to provision, and deploy PHP applications on different target platforms (DigitalOcean, Akamai, Vultr, Amazon, Hetzner, etc). In addition to provisioning the server(s), it also installs all the software we need to deploy/host applications, such as Nginx, PHP, Postgres, Redis, etc. Other features: - Deploys can be triggered by Git changes (e.g., on GitHub, Bitbucket, etc) - It can provision free TLS certificates using LetsEncrypt - It can backup databases - It provides monitoring, logs, etc Forge also supports other types of Web applications: - Static sites - Symfony - ... ## Tiers Laravel Forge has multiple tiers - Hobby: Maximum one server, with as many sites as you want, unlimited deployments, push to deploy, and basic support - Growth: Unlimited servers - Business: Share servers with teammates, database backups, and server metric monitoring ## Servers and sites Each server can be used to host 0-n sites. There is always a default site, but you can add new ones. Each site can be - Mapped to a specific domain and aliases - Mapped to a specific Git repository on GitHub, GitLab, or elsewhere - Automatically deployed - Have its own database on the server's database engine ## Site deployments Each site has a deployment script that can be fully customized, same for the application environment's configuration. During the deployment process, Forge defines and exposes a number of environment variables to the deployment script: https://forge.laravel.com/docs/sites/deployments.html#environment-variables ## PHP versions and settings It's possible to install and manage different versions of [[PHP]] on each server. Those can be managed through the Web interface of Forge. In addition, you can configure the maximum file upload size, the maximum execution time for PHP scripts, which version to use as default (CLI and site), edit the configuration, etc. ## Commands It's possible to execute arbitrary commands on the servers through Forge's website: https://forge.laravel.com/docs/sites/commands.html ## Redirects For each site, it's possible to define (temporary or permanent) redirect rules: https://forge.laravel.com/docs/sites/redirects.html On the servers, those rules are stored under `/etc/nginx/forge-conf/<site name>/server/redirect_rules.conf`. Additional redirect rule files can be added to that folder. ## SSL Using the SSL configuration page, it's possible to request the creation of certificates using LetsEncrypt: https://forge.laravel.com/docs/sites/ssl.html It's also possible to import custom certificates, for example an Origin Server certificate created via CloudFlare (SSL/TLS > Origin Server). This is a best practice to have end-to-end encryption with the "Full (Strict)" TLS option on CloudFlare. ## Site protection using basic access Site can be protected using basic access authentication: https://forge.laravel.com/docs/sites/security-rules.html ## Databases Through the "Database" page, it's possible to get database connection details, and also to create new and list existing databases on the server: https://forge.laravel.com/docs/resources/databases.html Through that, it's also possible to create new database users, restricting access to specific databases. TIP: If you create databases outside of Forge, you'll need to click on "Sync Databases" for those to appear on the Forge website. ## Scheduled tasks It's possible to configure scheduled jobs using Forge: https://forge.laravel.com/docs/resources/scheduler.html Each job has: - A command to execute - The user account to use - The frequency Scheduled jobs are defined as CRON jobs on the server: `/etc/crontab` TIP: This feature can be useful to trigger [[Laravel]] tasks using `artisan`: https://laravel.com/docs/11.x/scheduling ## Queues It's possible to create [Laravel queue workers](https://laravel.com/docs/11.x/queues) (defined via `config/queue.php` in the Laravel app). Those will automatically be monitored by [Supervisor](https://laravel.com/docs/11.x/queues#supervisor-configuration), and will be restarted if they crash. All workers will start automatically if the server crashes: https://forge.laravel.com/docs/sites/queues.html ## Daemons It's possible to create daemons using Forge: https://forge.laravel.com/docs/resources/daemons.html Each daemon runs a specific command, optionally from a specific directory, using a specific user. Daemons can use 1-n processes on the server. With this feature, you can: - Manage daemons (create, delete, start, stop, etc) - Check their status - Look at their logs - Editor the Supervisor configuration - ... ## Related - https://forge.laravel.com/ - Features: https://forge.laravel.com/#features - Documentation: https://forge.laravel.com/docs - Course: https://laracasts.com/series/learn-laravel-forge-2022-edition