debian 8 – quick setup lamp

# how i setup debian 8 as LAMP server

## root login

$ssh root@bluehrd

## create new user

$adduser ub

## root privilege

$aptitude safe-upgrade
$aptitude install sudo
$usermod -a -G sudo ub

## install

$sudo aptitude install apache2
$sudo aptitude install mysql-server php5-mysql
$sudo aptitude install php5-common libapache2-mod-php5 php5-cli

## test info.php

cd /var/ww/html/
echo "<?php phpinfo();?>" > info.php

## set config site

$sudo nano /etc/apache2/sites-available/bluehrd.conf

## isi file config

<VirtualHost *:80>
DocumentRoot "/var/www/html"
ServerName 128.199.103.189
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml
ErrorLog /var/log/apache2/bluehrd-error_log
CustomLog /var/log/apache2/bluehrd-custom_log common
TransferLog "/var/log/apache2/bluehrd-access_log"

<Directory "/var/www/html">
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</Directory>
</VirtualHost>

## enable site

$ sudo a2ensite bluehrd.conf
$ sudo service apache2 restart

## debug phpMyAdmin “lost mysqli module”

$sudo apt-get install php5-mysqlnd

## ubah kepemilikan /var/www/html ke user ub

$sudo chown ub /var/www/html

## upload to server /var/www/html

## ubah folder menjadi 755 dan folder menjadi 644

$cd /var/www/html
$find . -type d -exec chmod 755 {} \;
$find . -type f -exec chmod 644 {} \;

## ubah kepemilikan folder uploads dan folder didalam nya agar bisa di tulis php

$cd /var/www/html/uploads
$sudo chown www-data:ub .thumbs
$sudo chown www-data:ub galleries
$sudo chown www-data:ub profile
$sudo chown www-data:ub .thumbs/images

## referance

https://www.digitalocean.com/community/tutorials/initial-server-setup-with-debian-8

https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-debian-8

Advertisements

debian – change home to new partition space

have bigger partition 200GB to replace /home 32GB folder

1. create new partition using gparted

sudo gparted


get the file /dev/sda4

2. mount to folder /mnt/newhome

sudo mkdir /mnt/newhome
sudo mount /dev/sda4 /mnt/newhome

3. copy all in home folder

cd /home
sudo rsync -a ./ /mnt/newhome

4. unmount partition

sudo umount /mnt/newhome

5. change old home folder to home_old

sudo mv /home /home_old

6. create new /home folder

sudo mkdir /home

7. auto mount /dev/sda4 to /home

sudo echo "/dev/sda4 /home ext4 nodev,nosuid 0 2" >> /etc/fstab

8. restart

sudo reboot

9. and login with your user, check with df command

sudo df -h


10. if anything ok, delete /home_old

sudo rm -rf /home_old

debian 8 – switch java jdk version

i have oracle jdk 6 and want using / switch to oracle jdk 8. but i dont want remove oracle jdk 6, becouse some my software depend by that relic version. so switch is good idea

all my jdk located in /usr/lib/jvm. there will be have 2 folder

# download jdk 8
wget --no-check-certificate --no-cookies --header Cookie: oraclelicense=accept-securebackup-cookie http://download.oracle.com/otn-pub/java/jdk/8u152-b16/aa0333dd3019491ca4f6ddbe78cdb6d0/jdk-8u152-linux-x64.tar.gz

# extract
tar -zxvf jdk-8u*-linux-*.tar.gz

# move to jvm folder
sudo mv jdk1.8.*/ /usr/lib/jvm/

# update alternatives config
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.*/bin/java 2
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.8.*/bin/javac 2
sudo update-alternatives --config java

# check java version
java -version

# got this
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)

and how to switch from jdk 8 to jdk 6, in jdk 8 i just need java and javac, so we switch that file version

# switch java
sudo update-alternatives --config java
# switch javac
sudo update-alternatives --config javac

this my logs

g3n1k@x230:~/Downloads/IONIC$ java -version
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)
g3n1k@x230:~/Downloads/IONIC$ sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                     Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/jdk1.8.0_152/bin/java        2         auto mode
  1            /usr/lib/jvm/java-6-oracle/jre/bin/java   1         manual mode
  2            /usr/lib/jvm/jdk1.8.0_152/bin/java        2         manual mode

Press enter to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/lib/jvm/java-6-oracle/jre/bin/java to provide /usr/bin/java (java) in manual mode
g3n1k@x230:~/Downloads/IONIC$ sudo update-alternatives --config javac
There are 2 choices for the alternative javac (providing /usr/bin/javac).

  Selection    Path                                  Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/jdk1.8.0_152/bin/javac    2         auto mode
  1            /usr/lib/jvm/java-6-oracle/bin/javac   1         manual mode
  2            /usr/lib/jvm/jdk1.8.0_152/bin/javac    2         manual mode

Press enter to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/lib/jvm/java-6-oracle/bin/javac to provide /usr/bin/javac (javac) in manual mode
g3n1k@x230:~/Downloads/IONIC$ java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)
g3n1k@x230:~/Downloads/IONIC$ 

install oracle java 6 in debian 8

i have oracle java 6 in laptop, my vpn client depent with this relic version, its issue with development which using new jdk version (8 or 9).

before i think to switch version, i must make sure the old version will run if (worst case) laptop reinstall. so i using virtualbox and install my distro version, copy java-6-oracle and running my vpn clinet

for simple access from anywhere i had create github repo

https://github.com/g3n1k/java-6-oracle-manual-install

# clone java-6-oracle from repo
clone https://github.com/g3n1k/java-6-oracle-manual-install.git
# run the installer script
sudo sh java-6-oracle-manual-install/run.sh
# check java version
java -version

VIM get config and shorcut cheatset

clone vim config from https://github.com/julienschmidt/vim

cd ~
git clone https://github.com/julienschmidt/vim.git ~/.vim
ln -s ~/.vim/vimrc ~/.vimrc
cd ~/.vim
git submodule update --init
git submodule foreach git pull origin master

cheatset

split vertical
:vs filepath

split horizontal
:sp filepath

switch in windows buffer
Ctrl+w

switch from vertical to horizontal layout
Ctr+w H (or) :wincmd H

switch from horizontal to vertical layout
Ctrl+w J (or) :wincmd J

swap buffer but keep layout same 	 	
Ctrl+w r (or) :wincmd r

open file buffer
:e filepath

list all buffer 
:ls

buffer next
:bn

buffer prev
:bp

switch buffer in current windows
Ctrl+6

close buffer
:bd

close tab/file & remove from buffer
:bd!

search 
/

using command system in vim (ex: git)
:!git status

cut line
dd

paste line
p

select entire line and delete
Shift v then d

git(hub) – download all branch from repo

when your repo (github) have multiple branchs, using git clone command will only download “master” branch and other branch still not or remotely

this log when i download from https://github.com/GoesToEleven/golang-web-dev.git and get all his branch to locally

# mkdir for repo
$ mkdir golang-web-dev && cd golang-web-dev

# get download .git folder from repo
# git clone --bare <repository url goes here> .git
$ git clone --bare https://github.com/GoesToEleven/golang-web-dev.git .git

# doing some config
$ git config --bool core.bare false

# check status
$ git status


# reset to get deleted file & and show branch
$ git reset --hard && git branch

 

gitlab – colaboration with git

this secenario using two user first “g3n1k” second “sadik”
using gitlab comunity edition 9.5.4 in debian 8

g3n1k user: create, update, push master
$ git clone http://10.54.4.4:81/g3n1k/myproject.git
$ cd myproject
$ touch README.md
$ git add README.md
$ git commit -m "add README"
$ git push -u origin master

sadik user: fork, branc, change, push branch, send merge request 
# fork http://10.54.4.4:81/g3n1k/myproject.git
$ git clone http://10.54.4.4:81/sadik/myproject.git
$ cd myproject
# create and go to branch "sadik-menambah"
$ git checkout -b "sadik-menambah"
$ wget http://bit.ly/jqsource -O jquery.js
$ echo "Add the line to README.md" >> README.md
$ git add .
$ git commit -m "sadik menambah file"
# push branch "sadik-menambah"
$ git push origin sadik-menambah
# doing branch merge request

g3n1k user: see merge request, review change, merge n fix conflict, checkout master, doing merge, push to master
$ git fetch http://10.54.4.4:81/sadik/myproject.git sadik-menambah
$ git checkout -b sadik/myproject-sadik-menambah FETCH_HEAD
# review change local
# merge the brances and fix any conflicts thats come up
$ git checkout master
$ git merge --no-ff sadik/myproject-sadik-menambah
# push result of the merge to GitLab
$ git push origin master

sadik user: add remote original, remote update, doing update to master local, 
# check which branch are we
$ git status
# update master in fork at sadik user
$ git checkout master
# add remote user
$ git remote add g3n1k http://10.54.4.4:81/g3n1k/myproject.git
$ git remote 
# get pointing
$ git remote -v
$ git remote update
$ git merge g3n1k/master
# now your master is uptodate from g3n1k/master

reference: https://dev.acquia.com/blog/getting-started-collaborative-development-git