Getting Started | Deployer (2024)

Table of Contents
Provision​ Deploy​

In this tutorial we will cover:

  • Setting up a new host with the provision recipe.
  • Configuring a deployment and perfoming our first deploy.

First, install Deployer:

Now lets cd into the project and run the following command:

dep init

Deployer will ask you a few questions, and after finishing you will have adeploy.php or deploy.yaml file. This is our deployment recipe.It contains hosts, tasks and requires other recipes. All framework recipesthat come with Deployer are based on the common recipe.

Provision

note

If you already have a configured webserver you may skip todeployment.

Let's create a new VPS on Linode, DigitalOcean, Vultr, AWS, GCP, etc.

Make sure the image is Ubuntu 20.04 LTS as this version is supported byDeployer's provision recipe.

tip

Configure a DNS record for your domain that points to the IP address of your server.This will allow you to ssh into the server using your domain name instead of the IP address.

Our deploy.php recipe contains a host definition with a few important params:

  • remote_user the user name for the ssh connection,
  • deploy_path the file path on the host where we are going to deploy.

Let's set remote_user to be deployer. Right now our new server probably only has the root user. The provision recipe willcreate and configure a deployer user for us.

host('example.org')
->set('remote_user', 'deployer')
->set('deploy_path', '~/example');

To connect to the remote host we need to specify an identity key or private key.We can add our identity key directly into the host definition, but it's better to put itin the ~/.ssh/config file:

Host *
IdentityFile ~/.ssh/id_rsa

Now let's provision our server. As our host doesn't have a user deployer,we are going to override remote_user for provisioning via -o remote_user=root.

dep provision -o remote_user=root

tip

If your server doesn't have a root user but your remote user can use sudo tobecome root, then use:

dep provision -o become=root

Deployer will ask you a few questions during provisioning: php version,database type, etc. Next, Deployer will configure our server and createthe deployer user. Provisioning takes around 5 minutes and will installeverything we need to run a website. A new website will be configuredat deploy_path.

After we have configured the webserver, let's deploy the project.

Deploy

To deploy the project:

dep deploy

If deploy failed, Deployer will print an error message and which command was unsuccessful.Most likely we need to configure the correct database credentials in the .env file or similar.

Ssh to the host, for example, for editing the .env file:

dep ssh

tip

If your webserver is using an OpenSSH version older than v7.6, updating the code may fail with the errormessage unsupported option "accept-new". In this case, override the Git SSH command with:

set('git_ssh_command', 'ssh');

After everything is configured properly we can resume our deployment from theplace it stopped. However, this is not required; we can just start a new deploy:

dep deploy --start-from deploy:migrate

After our first successful deployment, we can find the following directory structure on our server:

~/example // The deploy_path.
|- current -> releases/1 // Symlink to the current release.
|- releases // Dir for all releases.
|- 1 // Actual files location.
|- ...
|- .env -> shared/.env // Symlink to shared .env file.
|- shared // Dirs for shared files between releases.
|- ...
|- .env // Example: shared .env file.
|- .dep // Deployer configuration files.

Configure you webserver to serve the current directory. For example, for nginx:

root /home/deployer/example/current/public;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}

If you're using the provision recipe, Deployer will automatically configure the Caddywebserver to serve from the public_path.

Now let's add a build step on our host:

task('build', function () {
cd('{{release_path}}');
run('npm install');
run('npm run prod');
});

after('deploy:update_code', 'build');

Deployer has a useful task for examining what is currently deployed.

$ dep releases
task releases
+---------------------+--------- deployer.org -------+--------+-----------+
| Date (UTC) | Release | Author | Target | Commit |
+---------------------+-------------+----------------+--------+-----------+
| 2021-11-05 14:00:22 | 1 (current) | Anton Medvedev | HEAD | 943ded2be |
+---------------------+-------------+----------------+--------+-----------+

tip

During development, the dep push task maybe usefulto create a patch of local changes and push them to the host.

Getting Started | Deployer (2024)
Top Articles
What is Tier 1, Tier 2 and Tier 3
How the $1,000-a-Month Rule Can Save Your Retirement
11 beste sites voor Word-labelsjablonen (2024) [GRATIS]
Enrique Espinosa Melendez Obituary
Http://N14.Ultipro.com
13 Easy Ways to Get Level 99 in Every Skill on RuneScape (F2P)
Did 9Anime Rebrand
oklahoma city for sale "new tulsa" - craigslist
THE 10 BEST Women's Retreats in Germany for September 2024
Best Cheap Action Camera
Mikayla Campino Video Twitter: Unveiling the Viral Sensation and Its Impact on Social Media
Corporate Homepage | Publix Super Markets
Tamilblasters 2023
Unit 1 Lesson 5 Practice Problems Answer Key
FAQ: Pressure-Treated Wood
Pittsburgh Ultra Advanced Stain And Sealant Color Chart
Fairy Liquid Near Me
Craiglist Galveston
Craigslist Farm And Garden Cincinnati Ohio
Arboristsite Forum Chainsaw
Google Feud Unblocked 6969
National Weather Service Denver Co Forecast
Truck Trader Pennsylvania
Q Management Inc
Spider-Man: Across The Spider-Verse Showtimes Near Marcus Bay Park Cinema
Saatva Memory Foam Hybrid mattress review 2024
Used Safari Condo Alto R1723 For Sale
Shoe Station Store Locator
Everything To Know About N Scale Model Trains - My Hobby Models
Spiritual Meaning Of Snake Tattoo: Healing And Rebirth!
Is Poke Healthy? Benefits, Risks, and Tips
Tactical Masters Price Guide
manhattan cars & trucks - by owner - craigslist
The Fabelmans Showtimes Near Baton Rouge
Mississippi Craigslist
Play It Again Sports Forsyth Photos
Downloahub
Why comparing against exchange rates from Google is wrong
October 19 Sunset
Haley Gifts :: Stardew Valley
Wednesday Morning Gifs
Staar English 1 April 2022 Answer Key
Skip The Games Grand Rapids Mi
Taylor University Baseball Roster
Mytime Maple Grove Hospital
814-747-6702
Fatal Accident In Nashville Tn Today
Tìm x , y , z :a, \(\frac{x+z+1}{x}=\frac{z+x+2}{y}=\frac{x+y-3}{z}=\)\(\frac{1}{x+y+z}\)b, 10x = 6y và \(2x^2\)\(-\) \(...
Buildapc Deals
ats: MODIFIED PETERBILT 389 [1.31.X] v update auf 1.48 Trucks Mod für American Truck Simulator
Fishing Hook Memorial Tattoo
Olay Holiday Gift Rebate.com
Latest Posts
Article information

Author: Amb. Frankie Simonis

Last Updated:

Views: 5480

Rating: 4.6 / 5 (76 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Amb. Frankie Simonis

Birthday: 1998-02-19

Address: 64841 Delmar Isle, North Wiley, OR 74073

Phone: +17844167847676

Job: Forward IT Agent

Hobby: LARPing, Kitesurfing, Sewing, Digital arts, Sand art, Gardening, Dance

Introduction: My name is Amb. Frankie Simonis, I am a hilarious, enchanting, energetic, cooperative, innocent, cute, joyous person who loves writing and wants to share my knowledge and understanding with you.