さてsymfonyまで無事にインストールできたということで、いよいよOpenPNE3本体のインストールに入ります。
基本的なことは全てOpenPNE3開発用ページに書かれていますので、これに従います。
ソースをGET
とりあえず今回インストール用に「pne3」というユーザを作成、そこにOpenPNE3のソースをセッティングしていきます、ユーザ pne3 のホームディレクトリから svn コマンドを入力、リビジョン管理されたファイルをローカルへ取得します。
# svn co https://trac.openpne.jp/svn/OpenPNE3/trunk OpenPNE3_trunk_20080827
↓チェックアウトに成功するとこんな感じ
drwx------ 5 pne3 pne3 4096 8月 29 19:36 Maildir
drwxrwxr-x 13 pne3 pne3 4096 8月 30 19:35 OpenPNE3_trunk_20080827
drwxr-xr-x 2 pne3 pne3 4096 8月 29 19:36 public_html
設定ファイルの作成
configディレクトー内の *.sample を .sample なしのファイルにコピー
(ソースディレクトリへ移動後、まとめて.sampleのコピーを作成)
# cd OpenPNE3_trunk_20080827
# ls config/*.sample | sed -e 's/\.sample$//g' | awk '{print "cp "$1".sample "$1}' | sh
sampleのファイル群が
-rw-rw-r-- 1 config/ProjectConfiguration.class.php.sample
-rw-rw-r-- 1 config/databases.yml.sample
-rw-rw-r-- 1 config/propel.ini.sample
↓コマンド適応後(configフォルダー内)
-rw-rw-r-- 1 ProjectConfiguration.class.php
-rw-rw-r-- 1 ProjectConfiguration.class.php.sample
-rw-rw-r-- 1 databases.yml
-rw-rw-r-- 1 databases.yml.sample
-rw-rw-r-- 1 propel.ini
-rw-rw-r-- 1 propel.ini.sample
config/ProjectConfiguration.class.php を編集、##SYMFONY_LIB_DIR## の箇所をsymfony のライブラリ群がインストールされているディレクトリのパスに置換します(例:/usr/share/php/data/symfony)。
#
vi config/ProjectConfiguration.class.php
symfonyのバージョン表示(# symfony -V)で表示されるパスに置き換えればよいのではないでしょうか?
私の環境では symfony version 1.1.1 (/usr/share/pear/symfony)でしたので。
require_once ‘##SYMFONY_LIB_DIR##/autoload/sfCoreAutoload.class.php’;
sfCoreAutoload::register();class ProjectConfiguration extends sfProjectConfiguration
{
public function setup()
{
}
}
↓ 編集後 ↓
require_once ‘/usr/share/pear/symfony/autoload/sfCoreAutoload.class.php’;
sfCoreAutoload::register();class ProjectConfiguration extends sfProjectConfiguration
{
public function setup()
{
}
}
データベースを作成
| データベース名 | OpenPNE3_trunk_20080827 |
| ユーザー名 | (例)pne3 |
| パスワード | (例)pne3pass |
まず、symfony側の設定
# symfony configure:database mysql://pne3:pne3pass@localhost/OpenPNE3_trunk_20080827
実際にデータベースを作成
# mysql -u root -p(要password入力)
mysql> CREATE DATABASE OpenPNE3_trunk_20080827 DEFAULT CHARACTER SET utf8;
mysql> grant ALL PRIVILEGES on OpenPNE3_trunk_20080827.* to pne3@localhost identified by ‘pne3pass’;
mysql> exit
config/databases.yml の編集、最後に「encoding: utf8」を追加
# vi config/databases.yml
all:
propel:
class: sfPropelDatabase
param:
dsn: ‘mysql://pne3:pne3pass@localhost/OpenPNE3_trunk_20080827′
encoding: utf8
※yml(YAML)表記とはインデント(行頭の半角スペース)を使い階層を表現するためインデントの調整は重要です、なお全角スペースは当然のことながらタブも使用不可です。
データベースのテーブルを構築します
# symfony propel:build-all-load pc_frontend
これで16個のテーブルが自動生成されました
- admin_user
- authentication_login_id
- authentication_pc_address
- community
- community_member
- friend
- member
- member_config
- member_profile
- navi
- navi_i18n
- profile
- profile_i18n
- profile_option
- profile_option_i18n
- sns_config
実は[config/schema.yml]というファイルがテーブル定義書です。
*config/schema.yml の内容(非常にわかりやすいです)
propel:
member:
id: ~
name: { type: varchar(64), required: true }
is_active: { type: boolean, required: true }
created_at: ~
updated_at: ~
profile:
id: ~
name: { type: varchar(64), index: unique, required: true }
is_required: { type: boolean, required: true }
is_unique: { type: boolean, required: true }
form_type: { type: varchar(32), required: true }
value_type: { type: varchar(32), required: true }
value_regexp: { type: longvarchar }
value_min: { type: integer }
value_max: { type: integer }
is_disp_regist: { type: boolean, required: true }
is_disp_config: { type: boolean, required: true }
is_disp_search: { type: boolean, required: true }
sort_order: { type: integer }
・・・・ 以下略 ・・・・
因みに最初の項目が「フィールド名」、次が「型」になりますが、idはデフォルトでオートインクリメント,created_at、updated_atはタイムスタンプ型と解釈されるようです。
web公開ディレクトリ(ドキュメントルート)の変更
ここまでで設定は終りですが、apacheのドキュメントルート(現在public_html)とPNEのインストール先フォルダが違うためブラウザーからアクセスできません、一番手っ取り早方法として httpd.conf のバーチャルホストを修正して強引に合わせます。
#
vi /etc/httpd/conf/httpd.conf
<virtualhost *:80>
ServerName user.mydomain.net
DocumentRoot /home/user/OpenPNE3_trunk_20080827/web
<directory "/home/user">
AllowOverride All
</Directory>
</VirtualHost>
そしてApacheを再起動
# /etc/rc.d/init.d/httpd restart
アクセスしてみる
ログイン画面はこんな様子。

さっそくログインしてみましょう。

管理画面は。

おや、下の方画像がリンク切れを起こしてます、リンク先を見てみると。。。
/sf/sf_web_debug/images/sf.png
/sf/sf_web_debug/images/config.png
/sf/sf_web_debug/images/comment.png
以下略
これは(OpenPNEではなく)symfonyの「デバックツールバー」が出しているらしく、symfonyのライブラリ参照パスが見つからないため、画像やスタイルシートがロードできずにコケているのでしょう、調べたら、symfony のライブラリは「/usr/share/pear/data/symfony/web/sf」にあったので、これもバーチャルドメイン内でエイリアス (本来はOpenPNEのインストール前に解決しておくべきでしょう)。
symfonyのライブラリのエイリアス
#
vi /etc/httpd/conf/httpd.conf
<virtualhost *:80>
ServerName user.mydomain.net
DocumentRoot /home/user/OpenPNE3_trunk_20080827/web
<directory "/home/user">
AllowOverride All
</Directory>
Alias /sf /usr/share/pear/data/symfony/web/sf
</VirtualHost>
そしてApacheを再起動
# /etc/rc.d/init.d/httpd restart
こんどはちゃんとsymfonyのメニューが(上部)表示されました。

想像してた以上に簡単でした、OpenPNE3自体のインストールは慣れてしまえば10分くらいでしょうかね。。。



