Skip to content

Instantly share code, notes, and snippets.

@makinuk
Last active September 18, 2019 17:17
Show Gist options
  • Save makinuk/48297001daab5b4e8bab to your computer and use it in GitHub Desktop.
Save makinuk/48297001daab5b4e8bab to your computer and use it in GitHub Desktop.
Capistrano Configuration with Gitlab

Capistrano Configuration

Configure Server

  • configure deploy user
groupadd deployers
adduser deploy
usermod -a -G deployers deploy
  • to give the deployers group the permissions, run the following and edit the /etc/sudoers file: visudo
  • Add the following line to after the groups:
..
## Allows people in group wheel to run all commands
%deployers      ALL=(ALL) ALL

..
  • generate ssh-key for deploy user
su deploy
ssh-keygen -t rsa -b 2048
  • add new deploy key to gitlab on http://gitlabserver/admin/deploy_keys from new server cat ~/.ssh/id_rsa.pub

  • enable new deploy-key on gitlab project

  • copy gitlab-runner key from gitlab-machine su gitlab-runner -c "cat ~/.ssh/id_rsa.pub"

  • paste gitlab ssh-key to new server via deploy user vi ~/.ssh/authorized_keys

  • change file mode chmod 700 ~/.ssh/authorized_keys

  • install git on new server yum -y install git

  • change project installation folder group chgrp -hR deployers /var/www

  • change project installation folder permission chmod 775 -R /var/www

  • optional visudo add %deploy ALL=(ALL)NOPASSWD:/bin/chown, /bin/chmod

first create capistrano config file with cap install command on project root folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment