Skip to content

Instantly share code, notes, and snippets.

@wnoguchi
Forked from makinuk/capistrano.md
Created December 18, 2017 00:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wnoguchi/2ecf0fb61b3d6b86a6d743f9704d4f35 to your computer and use it in GitHub Desktop.
Save wnoguchi/2ecf0fb61b3d6b86a6d743f9704d4f35 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