CentOS7 Sendmail test send email


# Install sendmail sendmail-cf m4
yum install sendmail sendmail-cf m4

# edit local host name
vi /etc/mail/local-host-names
xxx.com

# edit sendmail.mc
vi /etc/mail/sendmail.mc

#change 127.0.0.1 to 0.0.0.0
DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA')dnl

# change sendmail setting
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

# setting relay
vi /etc/mail/access
Connect:xxx.com RELAY

# hash database
makemap hash access < access

# restart sendmail
systemctl restart sendmail

# test php send mail
php -a
mail('user@receiver.com', "Test email", "Test email from the Internet", null, "-f user@sender.com");

Google Drive API 重新授權

1. 移除 json
2. 使手 CLI 取得網址,再取得 code 重新授權

CentOS 7 Systemd PHP


CentOS 7 Systemd 預設會打開 PrivateTmp 需要將它關掉才能與其他服務共用 /tmp

Close Systemd PHP Private Tmp
/usr/lib/systemd/system/php-fpm.service
PrivateTmp=false

Save reload daemon
systemctl daemon-reload

Restart php-fpm
systemctl restart php-fpm.service

VirtualBox CentOS 加大硬碟空間

1. 關閉虛擬機器
poweroff

2. 以指令增加資料卷容量
VBoxManage  modifyhd  "D:\VDI\CentOS7.vdi"  --resize  40960 (40G)

3. 虛擬機器設定 EFI 開機並掛載 GParted
https://downloads.sourceforge.net/project/gparted/gparted-live-stable/0.31.0-1/gparted-live-0.31.0-1-i686.iso

4. 使用 GParted 開機並 Resize 磁區後 Apply 關機, 取消虛擬機器的 EFI 開機並載卸 GParted

5. 進入系統取得 LV Path
lvdisplay 

6. 重新大小 LV Path
lvresize  -l  +100%FREE  /dev/centos/root

7. 重新大小 xfs
xfs_growfs  /dev/centos/root


ref:
http://oldgrayduck.blogspot.com/2016/07/virtualbox-centos.html

MySQL Get Tree Parents, Childrens

// get childrens
SELECT GROUP_CONCAT(lv SEPARATOR ',') as childrens 
FROM 
(
SELECT @pv:=( SELECT GROUP_CONCAT( uid SEPARATOR ',' ) FROM __table__ WHERE parent_id IN ( @pv ) ) AS lv  
FROM __table__
JOIN ( SELECT @pv:='__parent_id__' ) tmp 
WHERE parent_id IN (@pv)
) a;

// get parents
SELECT  
`_id` AS `file_id`, 
`q`.`parent_id`, 
(SELECT name FROM files AS `r` WHERE `r`.`file_id` = `q`.`_id` ) AS `name`
FROM 
( SELECT @r AS `_id`, ( SELECT @r := `parent_id` FROM `files` WHERE `file_id` = `_id` ) AS `parent_id` FROM ( SELECT  @r := '__id__', @l := '0' ) AS `vars`, `files` WHERE @r <> '0' ) AS `q`