GIT & EC2
How to install GIT on AWS EC2 and push your project on the GitHub repository.
Git plays a very important role in the developer's life. It helps to maintain code versions and has an immensely used branch system. In this blog, we'll cover the installation process of GIT on AWS EC2 and how to push your code/project in the GitHub account.
To get this task complete you need to have
Knowledge of AWS EC2
LINUX commands knowledge
To get a GitHub account click here.
Create a new repository in GitHub and make it public. Once we have pushed our project you can make it private later.
To get an AWS account click here
Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides resizable computing capacity—literally, servers in Amazon's data centers—that you use to build and host your software systems.
If you are creating an instance first time from AWS, you can follow this link. This link will help you to launch and connect your LINUX EC2 instance through PUTTY and WinSCP. But for this task, we'll be using PUTTY because we're launching an ec2 Linux server.
Once you have created your ec2 server you have to type the below command.
sudo su //press enter yum update -y //press enter yum install httpd -y //press enter yum install git -y //press enter
The first command will give the root user privileges.
The second command will install updates in the EC2 instance.
The third command will install apache in the EC2 instance.
And the last command will install the GIT in the EC2 instance.
Once we completed all installation and updates, we can create our new project in /var/www/html folder. type below command to get into the folder.
sudo chmod 7777 /var/www/html //permissions to read/write/executable cd /var/www/html
If you have any project which is already developed and you want to upload all files on the EC2 server, you can use WinSCP software. Follow this link
Or you can install or create a project from scratch in /var/www/html folder.
We have our github account and repository, git installed on EC2, Apache installed, project folders are also uploaded through WinSCP. Now push your code with the below command.
git init git add . git commit -m "YOUR MESSAGE" git remote add origin "your repository url" git push -u origin master
git add . will add your files.
git commit -m "message", save your project changes.
git remote add origin "your repository url"
See the below image to can get your repository URL and replace "your repository url" with it.
git push -u origin master command will push all your added code in your repository. Once it has done, all your project files will be visible in your GitHub repository.
YOUR PROJECT CHANGES DONE!!