ruk·si

Forge

Updated at 2015-12-31 22:49

Forge is a web service that rents and manages PHP servers for you:

  • Forge automates PHP server management and deployment.
  • Mainly meant to host Laravel but should work with any PHP code.
  • Rents a server from a provider like DigitalOcean, Linode and AWS.
  • Forge costs $10 / month, then you must pay at least $5 per month for a server.
  • Installs PHP for you.
  • You assign a GitHub repository that you can deploy from.
  • Provides scheduled actions using cron.
  • Integrations for New Relic and Papertrail.
  • Automated SSL certificate setup, even for free if you want.
  • You bind local directory like public to a GitHub repository branch. So technically you can host multiple sites from a single server.

To SSH in, add SSH key through the web interface.

ssh-keygen -t rsa -C "me@ruk.si"
# copy the .pub

Use envs to connect PostgreSQL.

DB_HOST
DB_NAME
# $_ENV['DB_HOST'] etc in PHP...

Scheduler is usually used through artisan in Laravel.

php artisan command:make AddTaskCommand
# app/start/artisan
#    Artisan::add(new AddTaskCommand);

php artisan
# lists all commands
  • queue workers are automatically maintained by Forge
  • scheduler tasks are restarted on failure
  • beanstalk is the default queue
  • automatically uses supervisor

Always remove composer.lock from .gitignore. Otherwise Forge deployments might install wrong dependency versions.

Adding custom domain:

  1. Get domain
  2. Point to the server IP
  3. A record that points domain to IP @ => IP, * => IP
  4. CNAME... www => laracasts-demos.com

Laravel Forge integrates New Relic with one click. Just go to the integrations tab and set your keys.

Forge to Envoyer to get zero downtime deployments:

  1. Make sure your project is on GitHub or Bitbucket
  2. Create a site on Forge and deploy there.
  3. Add a new project on Envoyer, register the repository.
  4. Add a new server for the project.
    1. You get the IP from Forge, port is 22
    2. Set connect as to forge
    3. Set project path to /home/forge/example.com/envoyer
    4. You get an SSH key that you need to set on the server through Forge.
  5. On Forge, set your Meta > Web Directory to /envoyer/current/public.

Source