File: README.md
text</a>
Deployer
The PHP deployment tool with support for popular frameworks out of the box.
</a>
DeployerSee deployer.org for more information and documentation.
Features
- Automatic server provisioning.
- Zero downtime deployments.
- Ready to use recipes for most frameworks.
Additional resources
License
File: docs/getting-started.md
Getting Started
This tutorial walks you through provisioning a server with the provision recipe and running
your first deploy.
Step 1: Install Deployer {#install}
Install Deployer, then run this in your project directory:
dep initAnswer the prompts. Deployer creates a deploy.php or deploy.yaml recipe defining your hosts, tasks, and
imported recipes. Framework recipes extend the common recipe.
Step 2: Provision a New Server {#provision}
:::note
Skip to deployment if your server is already set up.
:::
Setting Up Your VPS
Create an Ubuntu VPS on Linode, DigitalOcean, Vultr, AWS, GCP, or similar. The
provision recipe targets Ubuntu.
Provisioning needs root SSH key auth, which recent Ubuntu images disable by default. Enable it now; you can
disable root SSH again once provisioning finishes.
:::tip
Point a DNS record at the server's IP so you can SSH by domain name.
:::
Configuring `deploy.php`
Define a host with at least these two settings:
remote_userโ SSH username.deploy_pathโ where to deploy on the server.
host('example.org')
->set('remote_user', 'deployer')
->set('deploy_path', '~/example');If the server only has root, the provision recipe creates and configures a deployer user for you.
Adding an Identity Key
Put your SSH key in ~/.ssh/config instead of the recipe:
Host *
IdentityFile ~/.ssh/id_rsaProvisioning the Server
Provision:
dep provision:::tip
- Connect as a non-root user:
dep provision -o provision_user=your-user - Use
sudoto become root:dep provision -o become=root
:::
Provisioning prompts for PHP version, database, and more. It takes about 5 minutes and installs everything
needed to serve a website at deploy_path.
Step 3: Deploy Your Project {#deploy}
Deploy:
dep deployOn failure, Deployer prints the error and the command that failed. Common cause: missing .env or credentials.
SSH into the server to edit files in place:
dep sshResume from a specific step:
dep deploy --start-from deploy:migrateStep 4: Post-Deployment Configuration
After the first deploy, the server layout looks like this:
~/example // deploy_path
|- current -> releases/1 // Symlink to current release
|- releases // Directory for all releases
|- 1 // Latest release
|- ...
|- .env -> shared/.env // Symlink to shared .env file
|- shared // Shared files between releases
|- ...
|- .env // Shared .env file
|- .dep // Deployer configuration filesWeb Server Setup
Point your web server at the current directory. Example for Nginx:
root /home/deployer/example/current/public;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}The provision recipe configures Caddy automatically, serving from
public_path.
Step 5: Adding a Build Step
Add a build task to deploy.php and hook it after code updates:
task('build', function () {
cd('{{release_path}}');
run('npm install');
run('npm run prod');
});
after('deploy:update_code', 'build');Examining Deployments
List deployments with:
dep releasesExample output:
+---------------------+--------- deployer.org -------+--------+-----------+
| Date (UTC) | Release | Author | Target | Commit |
+---------------------+-------------+----------------+--------+-----------+
| 2021-11-05 14:00:22 | 1 (current) | Anton Medvedev | HEAD | 943ded2be |
+---------------------+-------------+----------------+--------+-----------+:::tip
During development, dep push ships a patch of local changes to the host without going
through git.
:::