本站即日起正式部署SSL证书启用https安全连接, 联系站长:416326801#qq.com(#改成@)

Latest from the blog

PHP导出Excel文件

标签: PHP Excel

<?php  
//输出的文件类型为excel  
header("Content-type:application/vnd.ms-excel");  
//提示下载  
header("Content-Disposition:attachement;filename=jishu8_".date("Ymd").".xls");  
//报表数据  
$ReportArr = array(array(1,2,3,4,5),  
                    array('A','B','C','D','E'),  
                    array('up','down','left','right','center'),  
                    array('欢','迎','光','临','技','术','吧','!')  
                );  
$ReportContent = '';  
$num1 = count($ReportArr);  
for($i=0;$i<$num1;$i++){  
    $num2 = count($ReportArr[$i]);  
    for($j=0;$j<$num2;$j++){  
        //ecxel都是一格一格的,用\t将每一行的数据连接起来  
        $ReportContent .= '"'.$ReportArr[$i][$j].'"'."\t";  
    }  
    //最后连接\n 表示换行  
    $ReportContent .= "\n";  
}  
//用的utf-8 最后转换一个编码为gb  
$ReportContent = mb_convert_encoding($ReportContent,"gb2312","utf-8");  
//输出即提示下载  
echo $ReportContent;  
?>  

CentOS安装和配置rsync

标签: 备份 Linux CentOS rsync

1、配置服务端

yum install rsync
vi /root/rsync_user // 设置密码文件
chmod 600 /root/rsync_user // 设置密码文件权限 
vi /etc/rsyncd.conf // 配置服务
vi /etc/xinetd.d/rsync // 配置服务
chkconfig rsync on // 设置开机启动
/usr/bin/rsync --daemon 启动服务
ps -ef | grep rsync // 检查是否启动

密码root_user文件内容

test:123456
配置文件rsyncd.conf内容
uid = nobody
gid = nobody
use chroot = yes
pid file = /var/run/rsyncd.pid
log file = /var/run/rsyncd.log

[www]
uid = root
gid = root
comment = www
path = /data/wwwroot
auth users = test
secrets file = /root/rsync_user
read only = yes

配置文件/etc/xinetd.d/rsync内容

主要修改内容:
disable = no
server_args     = --config=/etc/rsyncd.conf --daemon

# default: off
# description: The rsync server is a good addition to an ftp server, as it \
#       allows crc checksumming etc.
service rsync
{
        disable = no
        flags           = IPv6
        socket_type     = stream
        wait            = no
        user            = root
        server          = /usr/bin/rsync
        server_args     = --config=/etc/rsyncd.conf --daemon
        log_on_failure  += USERID
}


2、配置客户端

yum install rsync
vi /root/rsync_pass

文件/root/rsync_pass内容

123456


3、在客户端测试服务

rsync -az  test@192.168.100.2::www // 需要输入密码
rsync -vzrtopy --progress --delete  test@192.168.100.2::www --password-file=/root/rsync_pass /www

4、写shell脚本、设置定时任务

*/3 * * * * /usr/local/src/test.sh &
test.sh文件内容


#!/bin/bash
cd /www
rsync -vzrtopy --progress --delete  test@192.168.100.2::www--password-file=/root/rsync_pass /www &>/dev/null


1 2 3 4 5 6 7 ... Next »... Last »