Web管理 · 2 min read · Feb 14, 2026

Ubuntu 16.04でsitecopyを使用してリモートウェブサイトを維持する

sitecopyは、ローカルに保存されたウェブサイトをリモートウェブサーバーにコピーするためのツールです(FTPまたはWebDAVを使用)。これは、変更されたローカルファイルをアップロードし、ローカルコンピュータで削除されたリモートファイルを削除することによって、リモートサイトをローカルコピーと同期させるのに役立ちます。このチュートリアルでは、sitecopyを使用してローカルのUbuntu 16.04デスクトップからリモートウェブサイトを管理する方法を示します。

1 予備ノート

私はローカルのUbuntuデスクトップでユーザー名tillを使用しています(そのユーザーとしてローカルLinuxデスクトップにログインしています - rootとしてログインしないでください)。リモートウェブサイトexample.comのファイルは、ローカルコンピュータのディレクトリ/home/till/sites/example.com/に保存されています。リモートドキュメントルートは/var/www/example.com/web/です。

sitecopyはFTPとWebDAVの両方で使用できるため、リモートサーバーにFTPまたはWebDAVアカウントが必要です。ここではFTPユーザー名defaulttillとパスワードhowtoforgeを使用しています。

私がこれらの例で使用するリモートウェブサイトはISPConfigで作成されています。しかし、FTPまたはWebDAVアクセスがある任意のサイトで機能します。

2 sitecopyのインストール

sitecopyはローカルデスクトップに次のようにインストールできます(root権限が必要なため、sudoを使用します):

sudo apt-get -y install sitecopy

これで、sitecopyのマニュアルページを見て、そのオプションに慣れてください:

man sitecopy

3 sitecopyの設定

ローカルデスクトップのホームディレクトリに移動します…

cd ~

…そして、ファイルの詳細を保存するためにsitecopyが使用するディレクトリ.sitecopyを700の権限で作成します:

mkdir -m 700 .sitecopy

次に、sitecopyの設定ファイル.sitecopyrcを作成します:

touch .sitecopyrc  
chmod 600 .sitecopyrc

ファイルを開きます…

nano .sitecopyrc

…そして、example.comサイトの設定を記入します。ここに2つの例があります。1つはFTP用…

site example.com
  server example.com
  username defaulttill
  password howtoforge
  local /home/till/sites/example.com/
  remote ~/web/
  exclude *.bak
  exclude *~

…もう1つはWebDAV用です:

site example.com
  server example.com
  protocol webdav
  username defaulttill
  password howtoforge
  local /home/till/sites/example.com/
  remote /var/www/example.com/web/
  exclude *.bak
  exclude *~

(sitecopyで管理したい各ウェブサイトのためにスタンザを定義できます。)

siteディレクティブの後にはウェブサイトの名前が必要です - 例としてexample.comやmysiteなど、自由に選択できます。この名前は後でsitecopyコマンドで使用されます。そのサイトに属する次の設定オプションはインデントされている必要があります!

以下の設定オプションのほとんどは自己説明的です。デフォルトのプロトコルはFTPです。WebDAVを使用したい場合は、プロトコルwebdavを指定してください。localディレクティブにはウェブサイトコピーのローカルパスが含まれ、remoteにはリモートサーバー上のウェブサイトのパスが含まれます - 絶対パスまたは相対パスのいずれかです。ユーザーがchrootされている場合(通常はFTPユーザーに当てはまります)、相対パス(~/または~/webなど)を使用する必要があります。そうでない場合は絶対パスを使用してください。

exclude行はオプションであり、sitecopyによって管理されないファイルを除外する方法を示すためにここにあります。

sitecopyの設定についての詳細は、そのマニュアルページで確認できます:

man sitecopy

4 初回使用

sitecopyを初めて使用する前に、次の3つのシナリオのうちどれがあなたの状況に合うかを決める必要があります:

  1. 既存のリモートサイトとローカルコピー、両方とも同期している。
  2. 既存のリモートサイト、ローカルコピーなし。
  3. 新しいリモートサイト、既存のローカルコピー。

4.1 既存のリモートサイトとローカルコピー、両方とも同期している

リモートサイトとローカルコピーの両方が存在し、同期している場合は、次のコマンドを実行します。

sitecopy --catchup example.com

これにより、sitecopyはローカルサイトがリモートコピーと正確に同じであると考えます。example.comを.sitecopyrcファイルで使用しているサイトの名前に置き換えます。

till@ubuntu-desktop:~$ sitecopy --catchup example.com  
sitecopy: Catching up site `example.com' (on example.com in ~/web/)  
sitecopy: All the files and and directories are marked as updated remotely.

4.2 既存のリモートサイト、ローカルコピーなし

既存のリモートウェブサイトのローカルコピーがない場合は、最初に次のコマンドを実行します。

sitecopy --fetch example.com

これにより、sitecopyはリモートサーバーからファイルのリストを取得します(example.comを.sitecopyrcファイルで使用しているサイトの名前に置き換えます):

till@ubuntu-desktop:~$ sitecopy --fetch example.com  
sitecopy: Fetching site `example.com' (on example.com in ~/web/)  
File: error/503.html - size 1906  
File: error/502.html - size 1881  
File: error/500.html - size 1851  
File: error/405.html - size 1810  
File: error/404.html - size 1806  
File: error/403.html - size 1809  
File: error/401.html - size 1806  
File: error/400.html - size 1792  
File: stats/.htaccess - size 128  
File: robots.txt - size 14  
File: index.html - size 1861  
File: favicon.ico - size 7358  
File: .htaccess - size 26  
Directory: error/  
Directory: stats/  
sitecopy: Fetch completed successfully.

次に、次のコマンドを実行します。

sitecopy --synch example.com

これにより、リモートコピーからローカルサイトが更新されます。

sitecopy: Synchronizing site `example.com' (on example.com in ~/web/)  
Creating error/: done.  
Creating stats/: done.  
Downloading error/503.html: [.] done.  
Downloading error/502.html: [.] done.  
Downloading error/500.html: [.] done.  
Downloading error/405.html: [.] done.  
Downloading error/404.html: [.] done.  
Downloading error/403.html: [.] done.  
Downloading error/401.html: [.] done.  
Downloading error/400.html: [.] done.  
Downloading stats/.htaccess: [.] done.  
Downloading robots.txt: [.] done.  
Downloading index.html: [.] done.  
Downloading favicon.ico: [.] done.  
Downloading .htaccess: [.] done.  
sitecopy: Synchronize completed successfully.

4.3 新しいリモートサイト、既存のローカルコピー

ローカルコピーが存在するが、リモートサイトが空の場合は、次のコマンドを実行します。

sitecopy --init example.com

最初にサイトを初期化します。example.comを.sitecopyrcファイルで使用しているサイトの名前に置き換えます。

till@ubuntu-desktop:~$ sitecopy --init example.com  
sitecopy: Initializing site `example.com' (on example.com in ~/web/)  
sitecopy: All the files and directories are marked as NOT updated remotely.  
  

次に、次のコマンドを実行します。

sitecopy --update example.com

これにより、ローカルコピーがリモートサイトにアップロードされます:

till@ubuntu-desktop:~$ sitecopy --update example.com  
sitecopy: Updating site `example.com' (on example.com in ~/web/)  
Creating stats/: done.  
Creating data/: done.  
Creating error/: done.  
Uploading stats/.htaccess: [.] done.  
Uploading data/index.html: [.] done.  
Uploading error/403.html: [.] done.  
Uploading error/401.html: [.] done.  
Uploading error/404.html: [.] done.  
Uploading error/503.html: [.] done.  
Uploading error/400.html: [.] done.  
Uploading error/502.html: [.] done.  
Uploading error/405.html: [.] done.  
Uploading error/500.html: [.] done.  
Uploading index.html: [.] done.  
Uploading robots.txt: [.] done.  
Uploading .htaccess: [.] done.  
Uploading favicon.ico: [.] done.  
sitecopy: Update completed successfully.

5 sitecopyの使用

その後、sitecopyの使用は非常に簡単です。ローカルコピーで作業し、ファイルを更新、作成、削除できます。最初のオプションのステップとして、次のコマンドを実行します。

sitecopy example.com

これにより、ローカルで変更されたファイルが表示されます(example.comを.sitecopyrcファイルで使用しているサイトの名前に置き換えます):

till@ubuntu-desktop:~$ sitecopy example.com  
sitecopy: Showing changes to site `example.com' (on example.com in ~/web/)  
* These items have been added since the last update:  
info.php  
sitecopy: The remote site needs updating (1 item to update).

リモートウェブサイトをローカルコピーと同期させるには(つまり、新しいファイルと変更されたファイルをリモートサーバーにアップロードし、ローカルで削除されたファイルをリモートサーバーから削除する)、次のコマンドを実行します。

sitecopy --update example.com
till@ubuntu-desktop:~$ sitecopy --update example.com  
sitecopy: Updating site `example.com' (on example.com in ~/web/)  
Uploading info.php: [] done.  
sitecopy: Update completed successfully.

それだけです!sitecopyを楽しんでください!

6 リンク

Share: X/Twitter LinkedIn

新しい投稿を受信箱で受け取る

スパムはありません。いつでも購読を解除できます。