$cmd = "tar -C /data/www/ -zcvf /home/x.gz a.txt b.txt"; $pack = exec($cmd); 把/data/www目录下的 a.txt b.txt gzip打包到 /home/x.gz里面.