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:
- Get domain
- Point to the server IP
- A record that points domain to IP @ => IP, * => IP
- 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:
- Make sure your project is on GitHub or Bitbucket
- Create a site on Forge and deploy there.
- Add a new project on Envoyer, register the repository.
- Add a new server for the project.
- You get the IP from Forge, port is 22
- Set connect as to
forge
- Set project path to
/home/forge/example.com/envoyer
- You get an SSH key that you need to set on the server through Forge.
- On Forge, set your Meta > Web Directory to
/envoyer/current/public
.