synouser --setpw root
2017年12月29日
PHP CURL 設定筆記
PHP CURL 設定筆記
GET
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://somewhere/?var=val");
//curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//不直接輸出
$result = curl_exec($ch);
curl_close($ch);
POST
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://somewhere/");
curl_setopt($ch, CURL_POST, true);
curl_setopt($ch, CURL_POSTFIELDS, http_build_query( array() ) );
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//不直接輸出
$result = curl_exec($ch);
curl_close($ch);
GET
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://somewhere/?var=val");
//curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//不直接輸出
$result = curl_exec($ch);
curl_close($ch);
POST
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://somewhere/");
curl_setopt($ch, CURL_POST, true);
curl_setopt($ch, CURL_POSTFIELDS, http_build_query( array() ) );
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//不直接輸出
$result = curl_exec($ch);
curl_close($ch);
2017年10月5日
Debian Fail2Ban 安裝設定筆記
安裝
apt-get install fail2ban
設定檔
/etc/fail2ban/fail2ban.conf
check
logtarget = /var/log/fail2ban.log
cp jail.conf jail.local
修改jail.local內容就好, 原始檔不動
jail.local設定會覆蓋jail.conf
注意事項
ignoreip = 127.0.0.1/8 192.168.1.0/24 (空白區隔)
bantime = 600(秒)
maxretry = 10 (失敗幾次封鎖)
增加dovecot
[dovecot]
enabled = true
port = pop3,pop3s,imap,imaps
filter = dovecot
logpath = /var/log/dovecot (看實際 log檔放哪)
maxretry = 10
/etc/fail2ban/filter.d/dovecot.conf
[Definition]
failregex = (?: pop3-login|imap-login): .*(?:Authentication failure|Aborted login \(auth failed|Aborted login \(tried to use disabled|Disconnected \(auth failed).*rip=(?P\S*),.*
ignoreregex =
apt-get install fail2ban
設定檔
/etc/fail2ban/fail2ban.conf
check
logtarget = /var/log/fail2ban.log
cp jail.conf jail.local
修改jail.local內容就好, 原始檔不動
jail.local設定會覆蓋jail.conf
注意事項
ignoreip = 127.0.0.1/8 192.168.1.0/24 (空白區隔)
bantime = 600(秒)
maxretry = 10 (失敗幾次封鎖)
增加dovecot
[dovecot]
enabled = true
port = pop3,pop3s,imap,imaps
filter = dovecot
logpath = /var/log/dovecot (看實際 log檔放哪)
maxretry = 10
/etc/fail2ban/filter.d/dovecot.conf
[Definition]
failregex = (?: pop3-login|imap-login): .*(?:Authentication failure|Aborted login \(auth failed|Aborted login \(tried to use disabled|Disconnected \(auth failed).*rip=(?P
ignoreregex =
/etc/fail2ban/filter.d/sasl.conf
failregex = (?i): warning: [-._\w]+\[<HOST>\]: SASL (?:LOGIN|PLAIN|(?:CRAM|DIGEST)-MD5) authentication failed(: [A-Za-z0-9+/ ]*={0,2})?$
=========
測規則
Example1
fail2ban-regex /var/log/dovecot /etc/fail2ban/filter.d/dovecot.conf
Example2
fail2ban-regex /var/log/mail.log /etc/fail2ban/filter.d/postfix.conf
Example3
fail2ban-regex /var/log/mail.log /etc/fail2ban/filter.d/sasl.conf
2017年9月4日
Git stash指令記錄
儲存stash(僅追蹤中已修改)
git stash
儲存stash(包含未追蹤)
git stash -u
顯示已存的stash
git stash list
讀取stash
git stash apply
讀取stash (指定stash)
git stash apply stash@{1}
取出stash(原本stash會刪除)
git stash pop
刪除stash
git stash drop
刪除stash (指定stash)
git stash drop stash@{1}
清除stash
git stash clear
2017年6月6日
Git 使用情境 記錄
*建立branch
$git branch NewBranch
*切換branch
$git checkout TargetBranch
$git co TargetBranch
*假設目前有二個branch叫做master與bugfix
*為了方便理解 我會在提示字元前面加上目前的branch名稱,例如:
master$ 代表目前在master 這個branch下
bugfix$ 代表目前在bugfix 這個branch下
*Merge
將一個branch的內容合併到另一支branch
EX:把bugfix的修改內容,合併到master
master$ git merge bugfix
*Rebase
將一個branch 基於另一支branch 合併起來
EX:把bugfix的修改內容,合併到master 這個branch之下
bugfix$ git rebase master
*取消上一次的操作
$ git reset --hard ORIG_HEAD
*取消已暫存的檔案
不小心用add加入了stage
$ git add filename
使用指令取消
$ git reset HEAD filename
*取消修改過的檔案(回復到本來的內容)
$ git checkout -- filename
*取消目前為止修改過的檔案
$ git checkout .
*merge中發生confict,想放棄merge,要取消merge
$ git reset --hard 可取消這次的merge
$ git reset --hard ORIG_HEAD
取消最近一次成功的merge以及所有在這次merge後的修改
*忽略chmod的修改(chmod造成的檔案修改)
$ git config core.filemode false
有時檔案會因為chmod的關係會讓git認為檔案已修改,造成無法順利pull
MYSQL on MAC 設定筆記
/usr/local/mysql/my.cnf
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
MySQL5.0.2版本中的The Server SQL Mode 中新加了幾種 sql_mode,並且在sql的my.ini文件中的sql-mode 默認增加了其中的二種,一個是STRICT_TRANS_TABLES,就是導致auto_increament失敗的mode,這個sql_mode主要用于 當一個值不能插入到表中是,則産生一個錯誤而不是一個警告並終止會話。
#有時太小會導致寫入失敗,預設值好像才1M
max_allowed_packet = 20M
2016年10月21日
訂閱:
文章 (Atom)