WSL 的BASHRC 設定紀錄

這是目前有效的設定紀錄

# .bashrc
#ssh for wsl
sudo service ssh start
#docker alias
alias dockerstop=’docker stop $(docker ps -a -q)’
alias dockerclean=’docker rm $(docker ps -a -q)’
alias dockerrmi=’docker rmi $(docker images -q)’

#alias other

alias ll=’ls -al’
# get current branch in git repo
function parse_git_branch() {
BRANCH=`git branch 2> /dev/null | sed -e ‘/^[^*]/d’ -e ‘s/* \(.*\)/\1/’`
if [ ! “${BRANCH}” == “” ]
then
STAT=`parse_git_dirty`
echo “[${BRANCH}${STAT}]”
else
echo “”
fi
}

export LS_OPTIONS=’–color=auto’
#eval “$(dircolors -b)”
alias ls=’ls $LS_OPTIONS’
#LS_COLORS=$LS_COLORS:’di=0;35:’ ; export LS_COLORS
#eval “$(dircolor -b)”
#alias ls =’ls $LS_COLORS’;
# get current status of git repo
function parse_git_dirty {
status=`git status 2>&1 | tee`
dirty=`echo -n “${status}” 2> /dev/null | grep “modified:” &> /dev/null; echo “$?”`
untracked=`echo -n “${status}” 2> /dev/null | grep “Untracked files” &> /dev/null; echo “$?”`
ahead=`echo -n “${status}” 2> /dev/null | grep “Your branch is ahead of” &> /dev/null; echo “$?”`
newfile=`echo -n “${status}” 2> /dev/null | grep “new file:” &> /dev/null; echo “$?”`
renamed=`echo -n “${status}” 2> /dev/null | grep “renamed:” &> /dev/null; echo “$?”`
deleted=`echo -n “${status}” 2> /dev/null | grep “deleted:” &> /dev/null; echo “$?”`
bits=”
if [ “${renamed}” == “0” ]; then
bits=”>${bits}”
fi
if [ “${ahead}” == “0” ]; then
bits=”*${bits}”
fi
if [ “${newfile}” == “0” ]; then
bits=”+${bits}”
fi
if [ “${untracked}” == “0” ]; then
bits=”?${bits}”
fi
if [ “${deleted}” == “0” ]; then
bits=”x${bits}”
fi
if [ “${dirty}” == “0” ]; then
bits=”!${bits}”
fi
if [ ! “${bits}” == “” ]; then
echo ” ${bits}”
else
echo “”
fi
}

export PS1=”[\[\e[36m\]\u\[\e[m\]@\[\e[33m\]\h\[\e[m\]:\[\e[1;31m\]\w\[\e[m\]]\e[1;32m\][\t\[\e[m\]]\[\e[31m\]\`parse_git_branch\`\[\e[m\]$ “

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

linux find 搜尋檔案內容

我們要找一個log內容,就可以用這個方式找

find {path} -name {name} exec grep -H {要搜尋的字串}” {} \;

例如要找檔案內的 Undefind index

find “/var/logs/php-fpm/” -name “*.log” -exec grep -H “Undefined index” {} \;

你也可以進到目錄內找

find . -name “*.log” -exec grep -H “Undefined index” {} \;

安裝 php v8js in centos 7

為了完整性 建議手動安裝

1.先安裝工具包

yum groupinstall ‘Development Tools’

2.安裝git  python libglib2.0-dev

3.安裝depot_tools

git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git

export PATH=`pwd`/depot_tools:”$PATH”

4.下載v8

fetch v8 cd v8

5.設定 GN

tools/dev/v8gen.py -vv x64.release

echo is_component_build = true >> out.gn/x64.release/args.gn

6.編譯

ninja -C out.gn/x64.release/

7.安裝編譯好的檔案

sudo mkdir -p /opt/v8/lib

sudo mkdir -p /opt/v8/include

sudo cp out.gn/x64.release/lib*.so out.gn/x64.release/*_blob.bin /opt/v8/lib/

sudo cp -R include/* /opt/v8/include/

 

9.安裝v8js

git clone https://github.com/phpv8/v8js.git

cd v8js phpize ./configure –with-v8js=/opt/v8

make ; make install

10設定so

vim /etc/php.d/v8js.ini

extension=v8js.so

 

參考文件

 

https://github.com/phpv8/v8js/blob/master/README.Linux.md

 

 

nginx ssl 設定

這採用兩階段設定
第一步先拿到80 port 然後轉 443
話不多說 直接看設定檔

server {
  listen 80 ;
    server_name example.shop;

    # redirects both www and non-www to https
    return 301 https://$server_name$request_uri;

}

server {
    
    listen 443 ssl;
    server_name  example.shop;
    
    #ssl 設定
    ssl on;
    #ssl 認證 ,憑證中心發給的crt檔
    ssl_certificate /etc/nginx/ssl/example.shop.crt;
    #產生ssl的認證前 所使用的private key
    ssl_certificate_key /etc/nginx/ssl/example.shop.key;
    root   /var/www/public_html/;
    index  index.php index.html index.htm;

    error_log  /var/log/nginx/example.shop_error.log  warn;
 
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    location ~ \.php$ {
        fastcgi_read_timeout 3600;
        fastcgi_pass   php-fpm-sock;
        fastcgi_index  index.php;
        include        fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    }

}

升級 centos 7 Kernel 4.x

嚴格說不算升級
算是另外裝一組新的kernel

如果你要在centos 7使用比較新版本的docker,那你必須升級kernel,但內建的kernel只有3.10
所以必須安裝一個相對應的kernel

1.安裝 epel
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
2.安裝kernel
yum –enablerepo=elrepo-kernel install kernel-ml
3.重開機
在選單內就可以看到新的kernel

如果要改預設開機選單 讓4.x 變成預設開機
1.看安裝後的選單項目
awk -F\’ ‘$1==”menuentry ” {print i++ ” : ” $2}’ /etc/grub2.cfg

會展示妳的選單
例如這樣

0 : CentOS Linux (4.13.4-1.el7.elrepo.x86_64) 7 (Core)
1 : CentOS Linux (3.10.0-693.el7.x86_64) 7 (Core)
2 : CentOS Linux (0-rescue-1e36f8e932db4dc5b799fd4a613ecb0f) 7 (Core)

我要把第一個設定為預設開機選項
grub2-set-default 0

查看設定結果
grub2-editenv list
會出現
saved_entry=0
代表成功了
這時候重開機 就可以跑4.x的kernel了

how-to-fix-ubuntu-vmware-shared-folder

VMWARE不知道幹了甚麼奇怪的事情,在某些UBUNTU版本或者是CENTOS 7下,就算安裝了VMWARE TOOLS,也沒辦法使用shared folder…

當你檢查  sudo ls -l /mnt/hgfs 出現 /mnt/hgfs No such file or directory

廢話不多說

$ git clone https://github.com/rasa/vmware-tools-patches.git
$ cd vmware-tools-patches
$ ./patched-open-vm-tools.sh