Thursday, May 25, 2017

How to revert yum update

How to revert yum update if face any issue

yum history  it will show when last yum update done and id date & time & Action it will show E,erase I, install U update

for undo changes

yum history undo id number
Tuesday, April 11, 2017

Git Help full command



What is sparse checkout : you basically tell Git to exclude a certain set of files from the working tree. Those files will still be part of the repository but they won't show up in your working directory.

Internally, sparse checkout uses the skip-worktree flag to mark all the excluded files as always updated. 


So onward we can pull particular required directory on that particular server via git pull. E.g. like we will use git pull on web while executing below command.


mkdir configurations
cd  configurations
git init
git remote add -f origin
https://github.com/configurations.git
git config core.sparseCheckout true
echo "web/" > .git/info/sparse-checkout
git pull origin master
git add files
git commit -m 'your comment'
git push --set-upstream origin master
git push


For git merge
git stash
git pull
git stash apply
git add
git commit
git push

For keep data from server
git checkout filename

git pull        for fetch data (checkout)
git diff         for check difference between files
git push       for push data (commit in repo)
git log         check all commit
Tuesday, October 25, 2016

Linux Daily Use Command

How to check Whole folder size exclude particular sub folder

du --exclude=picture -sch *

Find all softlink inside parent folder

find . -type l -ls

Find particular word in side directory

grep -r ' asd' .

For find install php modules

php -m

for find php.ini file which in use.

php --ini

How to find which module are enable and install in apache/ httpd

apachectl -M

or

apachectl -t -D DUMP_MODULES


How to mount windows (CIFS) shares on Linux with credentials in a secure way

yum install cifs-utils

cat /proc/filesystems |grep cifs

Output : nodev cifs

ls /lib/modules/$(uname -r)/kernel/fs/*/*ko|grep cifs

Output :  /lib/modules/3.10.0-123.el7.x86_64/kernel/fs/cifs/cifs.ko

mount -t cifs //192.168.1.111/rns /rns -o user=username

Automatically mount the CIFS share

vi /root/.smbcred

domain=domainname
username=username
password=password

chmod 400 /root/.smbcred

vi /etc/fstab

//192.168.1.111/rns /rns cifs credentials=/root/.smbcred,defaults 0 0

How to define primary & secondary virtual host define in apache

Wildcard include your site configuration files:
Include path/to/site/confs/*httpd.conf
Organize your site conf files so they are loaded in an expected order. Example...
01-httpd.conf
02-site1-httpd.conf
03-site2-httpd.conf
etc...
Apache will read these in order. Then create one that will always load last to catch any unmatched virtual hosts and return a 404 instead of loading a default site.
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";
 }
Monday, July 11, 2016

How to Configure Redmine-3.1.6 with WHM 11.56.25

First Login to WHM and create subdomain and after login Cpanel via phpmyadmin create database



from root

cd /usr/local/src
wget http://rubyforge.org/frs/download.php/XXXXX/redmine-version.tar.gz
tar -xzvf redmine-version.tar.gz
chown -R username:username /usr/local/src/redmine-version/*
mv /usr/local/src/redmine-version/* /home/username/

mv /home/username/public/* /home/username/public_html
rm -rf /home/username/public
ln -s /home/username/public_html /home/username/public

For rvm install 
gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -L get.rvm.io | bash -s stable
source /etc/profile.d/rvm.sh
rvm requirements

rvm install 2.2.3

gem install rails

gem install passenger

yum -y install curl-devel sqlite-devel

passenger-install-apache2-module

vi /usr/local/apache/conf/passenger.conf

LoadModule passenger_module /usr/local/rvm/gems/ruby-2.2.3/gems/passenger-5.0.24/buildout/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-2.2.3/gems/passenger-5.0.24
PassengerDefaultRuby /usr/local/rvm/wrappers/ruby-2.2.3/ruby

vi /usr/local/apache/conf/includes/pre_main_global.conf

Include /usr/local/apache/conf/passenger.conf

/scripts/rebuildhttpdconf
 service httpd restart

From User
cd /home/username
bundle install --without development test postgresql sqlite
cp /home/username/config/database.yml.example /home/username/config/database.yml


cd /home/username
rake generate_secret_token
RAILS_ENV=production rake db:migrate
RAILS_ENV=production rake redmine:load_default_data


from root

mkdir -p /usr/local/apache/conf/userdata/std/2/username/domain.com


edit /usr/local/apache/conf/userdata/std/2/username/domain.com/redmine.conf

PassengerSpawnMethod smart
PassengerPoolIdleTime 300
PassengerMaxPreloaderIdleTime 0
PassengerMaxRequests 5000
PassengerStatThrottleRate 5
PassengerMinInstances 3

Options Indexes -ExecCGI FollowSymLinks -MultiViews
# AllowOverride None
Order allow,deny
Allow from all

# mod_rails
# PassengerUser redmine
#RailsEnv edoceo_live
RackBaseURI /

# environment.rb
# Redmine::Utils::relative_url_root = "/"  


Next, add this to /etc/httpd/conf/includes/post_virtualhost_global.conf

PassengerPreStart http://domain.com

Uncomment the include line, and restart Apache to verify it works fine. Once restarted OK, distill it to the distiller:
 #Include "/usr/local/apache/conf/userdata/std/2/username/domain.com/*.conf"

/usr/local/cpanel/bin/apache_conf_distiller --update
/usr/local/cpanel/bin/build_apache_conf

Your redmine application should now be accessible at http://domain.com