2017年11月28日 星期二

Centos sendmail by gmail

#install ssmtp
sudo yum install ssmtp -y
sudo cp /etc/ssmtp/ssmtp.conf /etc/ssmtp/ssmtp.conf.bak

vim /etc/ssmtp/ssmtp.conf
====
root=xxxxx@gmail.com
mailhub=smtp.gmail.com:587
Hostname=localhost
FromLineOverride=YES
UseTLS=YES
UseSTARTTLS=YES
AuthUser=xxxx@gmail.com
AuthPass=xxxxx
=====

#send test mail by ssmtp
echo "This is a test" | ssmtp recipient@your.domain.com

#change command mail default
alternatives --config mta
(choose)

echo "This is a test"  | mail -s "Title" xxxxx@gmail.com

#set server reboot and mail to admin
sudo vim /etc/rc.d/rc.local 
===
# wait 2min to sure all service open
(sleep 120
echo -e "`who -b`\n`ifconfig`\n`systemctl list-units | grep running`" | mail -s "Server on" xxxx@gmail.com
)&
====
sudo chmod u+x /etc/rc.d/rc.local


Install Juypter

#install jupyter
sudo pip3 install jupyter
# generate config file
jupyter notebook --generate-config

#generate hashcode
python3
===
from notebook.auth import passwd
passwd()
(password)
(password)
...
sha1:63d137bxxxxxxxxxxxxxxxxxxxxxxxxxx
exit()
=====

vim ~/.jupyter/jupyter_notebook_config.py
====
c.NotebookApp.ip='*'
c.NotebookApp.password = u'sha:ce...刚才复制的那个密文'
c.NotebookApp.open_browser = False
c.NotebookApp.port =8888 #随便指定一个端口
====

# firewall
firewall-cmd --zone=public --add-port=8888/tcp --permanent
systemctl restart firewalld.service
#or use ssh tunnel
ssh username@address_of_remote -L127.0.0.1:1234:127.0.0.1:8888 

#centos restart autostart by screen 
vim /etc/crontab
===
@reboot username screen -dmS jupyter jupyter notebook
===

screen -r jupyter
#===Int Screen: Jupyter====
#can see information
#========

## if open multijuyter must type following command first
unset XDG_RUNTIME_DIR

ref:
http://blog.leanote.com/post/jevonswang/%E8%BF%9C%E7%A8%8B%E8%AE%BF%E9%97%AEjupyter-notebook
http://jupyter.org/install.html

Centos GUI Webserver 設定

新灌的一台Centos7可以做以下的設定 語系設定: - sudo localectl set-locale LC_CTYPE=zh_TW.UTF-8 修改ssh port - http://linux.vbird.org/linux_server/0310telne...