baserCMSのワンラインインストール+起動の解説
昨日の記事(酔っ払ってからbaserCMSをインストールしてみた - Uemmra3のフルスタックエンジニア?日記)で、baserCMSをインストールできました。
ただ外谷さんがこちらで(http://bluestyle.publog.jp/archives/67963814.html)書いているように、ユーザー寄りの方や初心者の方の参加が求められています。そうした方にはチンプンカンプンなものになるかもしれません。
つまり昨日の記事でインストールできた事実は良いのですが、それだけだと不親切な気がします。なので、kaburkさんの記事(http://blog.kaburk.com/tools/oneliner_install_basercms4.html)に対して、少し解説を書くことにしました。
元々のコマンドはワンラインになっています。
git clone git@github.com:baserproject/basercms.git; ./basercms/app/Console/cake bc_manager install "http://localhost:8080/" "sqlite" "admin" "password" "webmaster@example.org" --host "localhost" --database "basercms" --data "bccolumn.default"; php -S localhost:8080 -t basercms/app/webroot
で私の場合はこれをWindows上のGit Bashで実行したのですが、UNIXライクOSのシェルの機能として、「;」で複数行のコマンドを連続させる機能を利用しています。
例えばtestというディレクトリを作って移動するのをワンライナで書くと、次のようになります。
mkdir test; cd test
ワンライナはコピペが簡単なのですが、解説するにはそれぞれのコマンド単独の方が良いと思いますので、1コマンドずつ説明しましょう。
1コマンド目
git clone git@github.com:baserproject/basercms.git;
baserCMSは、githubというインターネット上のリポジトリ(ソースコードなどの置き場)に保管されています。このコマンドでは、githubからソースコードを取得します。
なおこのリポジトリはウェブブラウザーからも見ることができます(GitHub - baserproject/basercms: baserCMS : Based Website Development Project)。
2コマンド目
2コマンド目を整理して書いてみます
./basercms/app/Console/cake bc_manager install
"http://localhost:8080/"
"sqlite"
"admin"
"password"
"webmaster@example.org"
--host "localhost"
--database "basercms"
--data "bccolumn.default";
元記事にも記載のあるこちら(コマンドインストール | baserCMS - 国産オープンソース!フリー(無料)でコンテンツ管理に強いCMS)がコマンドリファレンスです。このコメント(#より右がコメントです)を付けてみると、おぼろげながら理解が進むのではないでしょうか。
./basercms/app/Console/cake bc_manager install
"http://localhost:8080/" # サイトURL
"sqlite" # DB種類
"admin" # 管理システムログイン名
"password" # 管理システムログインパスワード
"webmaster@example.org" # 管理者メールアドレス
--host "localhost" # DBサーバホスト名
--database "basercms" # DB名
--data "bccolumn.default"; # 初期データのパターン
実際私も正確に理解しているのではないですが、DB(データベース)サーバと、管理システムをインストールしている、ということがわかります。
あと「cake」というのは、CakePHP(PHPのWebアプリケーションフレームワーク)のコマンドだと思います。詳しくはCakePHPの解説書、解説をご覧ください。
3コマンド目
インストールが終わったので、実行します。
PHPの簡易ヘルプを出すと、次のようになります。
$ php --help
Usage: php [options] [-f]
[--] [args...]
php [options] -r[--] [args...]
php [options] [-B] -R [-E
] [--] [args...]
php [options] [-B] -F [-E ] [--] [args...]
php [options] -S: [-t docroot]
php [options] -- [args...]
php [options] -a-a Run interactively
-c| Look for php.ini file in this directory
-n No php.ini file will be used
-d foo[=bar] Define INI entry foo with value 'bar'
-e Generate extended information for debugger/profiler
-fParse and execute .
-h This help
-i PHP information
-l Syntax check only (lint)
-m Show compiled in modules
-rRun PHP
without using script tags
-BRun PHP before processing input lines
-RRun PHP
for every input line
-FParse and execute for every input line
-ERun PHP after processing all input lines
-H Hide any passed arguments from external tools.
-S: Run with built-in web server.
-tSpecify document root for built-in web server.
-s Output HTML syntax highlighted source.
-v Version number
-w Output source with stripped comments and whitespace.
-zLoad Zend extension . args... Arguments passed to script. Use -- args when first argument
starts with - or script is read from stdin--ini Show configuration file names
--rf
Show information about function .
--rcShow information about class .
--reShow information about extension .
--rzShow information about Zend extension .
--riShow configuration for extension .
この
php [options] -S
: [-t docroot]
がここで使っている引数ですが、
php -S localhost:8080 -t basercms/app/webroot
では、Webアプリケーションサーバーのアドレスがlocalhost、ポートが8080
でドキュメントのルート(置き場所を指定する)がbasercms/app/webroot、になっています。
ちょっと初心者向けの説明をすると、
Webアプリケーションサーバーを情報を表示・操作するお店の店員さんだとします。お店がどこにあるかを指定しているのが -S の直後の引数です。そのうち、localhostとは自分自身の場所を指し、ポートはさしずめ窓口やカウンターのようなものです。つまり、あなたがインストールしたPC自身の、8080という窓口からアクセスできるようになります。そして、トップページの情報を置いている場所はbasercms/app/webrootになります。アクセスしてきたユーザーの要求に対して、店員(Webアプリケーションサーバー)は、最初はbasercms/app/webrootという棚から情報を取って、そこにあるマニュアルに沿って(PHPプログラムを解釈して)お客さん(ユーザー)に返事をする。そんな流れでしょうか。
まとめ
1行に連結されていた3つのコマンドを順に説明しました。
- githubからのソースコード取得(ダウンロード)
- 取得した環境を用いたbaserCMSのインストール
- Webサーバーの起動
というステップに分かれていました。当然ですが、次回起動するには3ステップ目だけを実行すればよいですね。
ではあなたもステキなbaserCMSライフを!ビバ!