2009年10月21日 星期三

[Tips] 如何在virtual host對php做不同的設定

以顯示/不顯示php錯誤訊息為例
[root@localhost ~]# vi .htaccess 
php_flag error_reporting = E_ALL
php_flag display_errors = Off 

出處: php_flag in .htaccess

[Tips] scp & ssh-agent

如何在local機器與remote機器進行自動化scp?

1.製作public keys & private keys
[root@local ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): <- 不用輸入
Enter same passphrase again: <- 不用輸入
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
7e:16:f4:57:87:5c:60:be:91:70:82:ac:cc:a9:95:74 root@localhost.localdomain

2. 從local機器複製/root/.ssh/id_dsa.pub到remote機器
[root@local ~]# scp /root/.ssh/id_dsa.pub root@remote:/root/.ssh/id_dsa.pub
root@remote 's password:
id_dsa.pub 100% |*****************************| 718 00:00 

3.將id_dsa.pub加到authorized_keys
[root@remote ~]# cat /root/.ssh/id_dsa.pub >> /root/.ssh/authorized_keys 

4.再以ssh連線到遠端機器, 未來將不用再輸入密碼啦
[root@local ~]# ssh root@remote

出處: 請問如何用scp或rsync每天自動備份到不同的日期目錄中?