月度归档:2012年08月

利用rsync做异地备份

这几天公司服务器硬盘坏了,去恢复数据 折腾了半天,突然意识到数据备份的重要性。所以索性做成异地备份。。。

准备是把公司本地的测试服务器拿来备份生产服务器上面的数据,但是 公司本地的服务器操作系统是windows,生产服务器操作系统是 linux。rsync支持从linux同步到windows。所以就用这个了。。。

windows下面的rsync软件叫cwRsync

主要用的软件是 cwRsync。。。此处就跳过服务器配置,客户端安装,直接说几个重要的地方
Linux服务器端的配置跟普通都是一样的。可以网上搜一下。。。这里主要说 Windows客户端同步Linux服务器端的文件。。。

命令如下:
“F:\Program Files\cwRsync\bin\rsync.exe” -rlptvzD –delete 219.153.42.78::cqd2d/bbs ../public_html
F:\Program Files\cwRsync\bin\rsync.exe为cwRsync安装的地址。。。
同步的目录只能用相对路径,不然没法更新
会报
The source and destination cannot both be remote.
rsync error: syntax or usage error (code 1) at main.c(1148) [Receiver=3.0.8]
这种错误

rsync参数不能用 -avz,因为 windows的文件权限跟linux的不一样。如果参数里面有a的话,也不能同步。
解决方法就是用 -rlptD 参数代替 -a
会报 rsync chown 您的目录 failed: invalid argument(22) 这样的错误。。。。

因为 -a = -rlptgoD, 所以实际上就是去掉了 –owner –group
暨是不保留以前的用户和用户组

基本上搞定,然后直接写个脚本,加入到计划任务 就自动离地备份了

debian隐藏Apache和PHP版本信息

隐藏 Apache 版本

apache 的 httpd.conf 有两个配置可以控制是否显示服务器信息给用户。
ServerTokens
ServerSignature
默认条件下会把apache版本 系统 模块都显示出来 (HTTP 返回头)
设置为:
ServerTokens ProductOnly
ServerSignature Off
就隐藏Apache的Apache Version信息。
ServerTokens Prod
服务器会发送(比如): Server: Apache
ServerTokens Major
服务器会发送(比如): Server: Apache/2
ServerTokens Minor
服务器会发送(比如): Server: Apache/2.0
ServerTokens Min
服务器会发送(比如): Server: Apache/2.0.41
ServerTokens OS
服务器会发送(比如): Server: Apache/2.0.41 (Unix)
ServerTokens Full (或未指定)
服务器会发送(比如): Server: Apache/2.0.41 (Unix) PHP/4.2.2 MyMod/1.2
如果是debian系统,则是在 /etc/apache2/conf.d/security 里面进行设置。。。
隐藏 PHP 版本
php.ini
expose_php On
改成
expose_php Off
重启apache后,php版本在http头中隐藏了。