Category: Linux

Home / Category: Linux

What is Git

Git is a version control system (VCS) that is used for software development and other version control tasks. As a distributed revision control system it is aimed at speed, data integrity, and support for distributed, non-linear workflows.

Git was created by Linus Torvalds in 2005 for the development of the Linux kernel, with other kernel developers contributing to its initial development. Its current maintainer is Junio Hamano.

Run your own Git server

Git manages the version control of applications and there are many git repositories. All git repositories which are free is having some limitations.

GitHub is one of the great services but we can’t create private repository in  GitHub free . For Private repo, you have to pay minimum 7$ per month, and the expenses go up with more repos.

In cases you don’t want to pay any extra for version control then the best is to create your own Git server. Not only do you save costs, you also have more control over your server.

Install Git on your server

In this installation methods, we are going to use two host machines one for the server (Linux) where we are going to make our repository and another the local machine through which we are going to connect the git server so let start .

Step1 : Install Git In both machine

Server Machine:

Linux

sudo yum install git
sudo apt-get install git

Local Machine :

Linux  :

sudo yum install git
sudo apt-get install git

Windows :

Visit https://git-scm.com/ and download the latest version for your windows

Step2 : Install Git-core In server

sudo yum install git-all
sudo apt-get install git-core

Step3 : Create user : git

sudo useradd git
passwd git

Step4 : Create SSH Key for local Linux machine (Optional)

Create ssh keys on your local machine to avoid asking password only for Linux Based Local System:

ssh-keygen -t rsa

leave all as default by press Enter and save it in a secure location .

Now you have to copy these keys to the server so that the two machines can talk to each other. Run the following command on your local machine:

cat ~/.ssh/id_rsa.pub | ssh [email protected] "mkdir -p ~/.ssh && cat >>  ~/.ssh/authorized_keys"

Step5 : Create a repository

Create a directory on your server machine and remember this will be your repository URL

[email protected]:~ $ mkdir -p /home/git/repo-name.git

Then change to this directory:

cd /home/git/repo-name.git

Then create an empty repo:

git init --bare
Initialized empty Git repository in /home/git/repo-name.git

Step6 : Create a Git repo in local machine

Linux users can use Terminal and windows users should us GIT BASH

mkdir -p /home/ramith/Desktop/Arduino

And change to this directory:

cd /home/ramith/Desktop/Arduino

Now create the files that you need for the project in this directory.

git init 
Initialized empty Git repository in /home/ramith/Desktop/Arduino

Now add files to the repo:

git add .

Now write your commit message

git commit -m "First Commit" -a
[master (root-commit) 57331ee] message
 1 files changed, 1 insertions(+)
 create mode 100644 script.txt

Till now you were working on the local machines repo.Now we need to push this to our git server so that team can collaborate. To do this we need to push this to the remote location in our Git Server. To add the location need to type below command

git remote add origin ssh://[email protected]/home/git/repo-name.git

Now you can push or pull changes between the server and local machine using the ‘push’ or ‘pull’ option:

git push origin master

Step7 :Cloning the repo with local machine

If there are other team members who want to work with the project they need to clone the repo from the server to their local machine:

git clone [email protected]:/home/git/repo-name.git

Then change directory on the local machine (exchange project with the name of the project on your server):

cd /repo-name

Now they can edit files, write commit change messages and then push them to the server:

git commit -m 'Second Commit Edited in script.txt' -a

And then push changes:

git push origin master

What is Lamp?

LAMP stack is a collection of 4 open source software which will help to create a web server in your Linux system. LAMP stands for Linux, Apache, MySQL, and PHP. To make a website live in public using VPS  you need to install apache . In this post we are trying to explain entire step how to install in in Your Ubuntu or Debian Server.

We also created and automated shell script so that you can install entire LAMP by running shell file.

Requirements

  1. Linux Server with static IP (Ubuntu/Debian) / ( Click here for RedHat/Centos Installation )
  2. Minimum 128 MB Ram
  3. 600 Mhz Processor

 

Steps

Connect your VPS Server using ssh

Automated Script Installation

# Coming soon

Steps 1 – Update Server

sudo apt-get update
sudo apt-get upgrade

Step 2 – Installing Apache

sudo apt-get install apache2

Step 3 – Installing Mysql

sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql

Once you have installed MySQL, we should activate it with this command:

sudo mysql_install_db

Finish up by running the MySQL set up script:

sudo /usr/bin/mysql_secure_installation

The prompt will ask you for your current root password.

Type it in.

Enter current password for root (enter for none):

OK, successfully used password, moving on…

Then the prompt will ask you if you want to change the root password. Go ahead and choose N and move on to the next steps.

It’s easiest just to say Yes to all the options. At the end, MySQL will reload and implement the new changes.

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y                                            
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

Once you’re done with that you can finish up by installing PHP.

Step 4 – Installing PHP

sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt

Step 5 – Installing PhpMyAdmin

sudo apt-get install phpmyadmin apache2-utils
  • Select Apache2 for the server
  • Choose YES when asked about whether to Configure the database for phpmyadmin with dbconfig-common
  • Enter your MySQL password when prompted
  • Enter the password that you want to use to log into phpmyadmin

After the installation has completed, add phpmyadmin to the apache configuration.

sudo nano /etc/apache2/apache2.conf

Add the phpmyadmin config to the file.

Include /etc/phpmyadmin/apache.conf

Step 6 – Restarting Apache

sudo service apache2 restart