
WordPressのStaticPressを使って静的サイトを作成し、別サーバーにアップするってこと、いろんな環境で運用やっているとあります。
よく忘れるので備忘録。
<?php
// zipファイル名
$fileName = "news";
// 圧縮対象フォルダ
$compressDir = "/var/www/html/static/html/news/";
// zipファイル保存先
$zipFileSavePath = "/var/www/html/tmp/";
// コマンド
// cd:ディレクトリの移動
// zip:zipファイルの作成
$command = "cd ". $compressDir .";".
"zip -r ". $zipFileSavePath . $fileName .".zip .";
// Linuxコマンドの実行
exec($command);
// 圧縮したファイルをダウンロードさせる。
header('Pragma: public');
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=".$fileName.".zip");
readfile($zipFileSavePath.$fileName.".zip");
?>



