Sunday, August 7, 2016

How To configure Git Inhouse server

How To configure Git Inhouse server

Requirement
·         GitLab on CentOS 7
·         Ruby versions 2.3
·         Redis
·         Postgres
·         Nginx

·         1 core CPU can support upto 100 users but recommended 2 core CPU which can easily support up to 500 users.

·         At least 2GB memory combining both RAM and swap. Apart from this we will need to install all the required dependencies

For OS complete Update
yum -y update

For install Openssh server & client and enable ssh
yum -y install openssh-server openssh-clients sudo systemctl enable sshd sudo systemctl start sshd

For install dependency
yum -y install curl policycoreutils postfix sudo systemctl enable postfix sudo systemctl start postfix

For enable http & https globally access
firewall-cmd --permanent --add-service=http sudo firewall-cmd --permanent --add-service=https sudo

For restart firewall
systemctl reload firewalld

For download gitlab repo
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash

For install gitlab community edition
yum -y install gitlab-ce
gitlab-ctl reconfigure


For change external URL change
Edit  /etc/gitlab/gitlab.rb file and change 
external_url 'http://gitlab.example.com'
gitlab-ctl reconfigure   & gitlab-ctl restart

For enable SSL for gitlab


Create the /etc/gitlab/ssl directory and copy your key and certificate there. Now run gitlab-ctl reconfigure . When the reconfigure finishes your GitLab instance should be reachable at https://gitlab.example.com . If you are using a firewall you may have to open port 443 to allow inbound HTTPS traffic as well as need to change external URL again.


Gitlab standered repository path : /var/opt/gitlab/git-data/repositories

For Git backup either clone repo or just copy paste whole repositories folder

for uninstall run

/gitlab-ctl uninstall 
Below code working fine in php 5.2 and php 5.4 and PHP5.6 same code given valid SSL error  so we have to use from  $mail->SMTPSecure = 'ssl'; update $mail->SMTPSecure = 'tls'; and use port 587 and comment $mail->isSMTP(); function. Not known how but it working and able to send mail

$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->Host = "smtp.gmail.com";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->Username = "email@gmail.com";
$mail->Password = "password";
$mail->SetFrom("example@gmail.com");
$mail->Subject = "Test";
$mail->Body = "hello";
$mail->AddAddress("email@gmail.com");

 if(!$mail->Send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
 } else {
    echo "Message has been sent";
 }