Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Set Up a CentOS Server on EC2 with Git Deployment

#CentOS Server on EC2 with Git Deployment


##Use Rightscale CentOS Community Server Image ami-09496d4c

###Step 1: SSH into the server and do the following

BE SURE YOU PERFORM THESE ACTIONS AS ROOT OR SU

$ 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/

###Step 2: 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

###Step 3: On local machine $ cd my_project $ git init $ git add * $ git commit -m "initial commit" $ git remote add aws git@example.com:my_project.git $ git push aws master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.