Skip to content

Instantly share code, notes, and snippets.

@edwardteach42
Last active October 1, 2015 10:37
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 edwardteach42/1975320 to your computer and use it in GitHub Desktop.
Save edwardteach42/1975320 to your computer and use it in GitHub Desktop.
Host a git repository on Amazon EC2
Set Up CentOS Server
Use Rightscale CentOS Community Server Image ami-09496d4c
*****AS ROOT*****
$ yum update
$ yum install git mysql mysql-libs httpd php php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-pecl-apc php-mcrypt
$ echo 'service httpd restart' >> /etc/rc.local
$ ssh-keygen -t rsa -C "email@example.com"
$ useradd git
$ passwd git
$ cd /home/git
$ mkdir .ssh
$ cat ~/.ssh/id_rsa.pub >> .ssh/authorized_keys
$ chown git:git .ssh
$ chown git:git .ssh/authorized_keys
$ chown git:git /var/www/html/
Setup the remote repository on the EC2 Instance:
$ ssh git@example.com
$ mkdir my_project.git
$ cd my_project.git
$ git init --bare
$ cat > hooks/post-receive
#!/bin/sh
GIT_WORK_TREE=/var/www/html git checkout -f
$ chmod +x hooks/post-receive
On local machine:
$ cd my_project
$ git init
$ git add *
$ git commit -m "My initial commit message"
$ git remote add origin git@example.com:my_project.git
$ git push origin master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment