8 02

[OpenPNE3]alpha1をインストールした時のメモ

Tag: phpuechoco @ 15 : 37 : 42

OpenPNE3 開発用ページを参考に、OpenPNE3 alpha1をインストールしてみました。

1. OpenPNE3 alpha1 本体のダウンロード

今回はsvnのtagsからエクスポートします。

Bash:
  1. $ cd /var/www  # ここに設置するとする
  2. $ svn export https://trac.openpne.jp/svn/OpenPNE3/tags/OpenPNE-3alpha1/
  3. $ cd ./OpenPNE-3alpha1

エクスポート直後のOpenPNE-3alpha1ディレクトリ階層はこんな感じです。

TEXT:
  1. OpenPNE-3alpha1(ルートディレクトリ)
  2.     apps
  3.         mobile_frontend
  4.         pc_backend
  5.         pc_frontend
  6.     cache
  7.     config
  8.     data
  9.         fixtures
  10.         sql
  11.     doc
  12.     lib
  13.         form
  14.         helper
  15.         model
  16.     log
  17.     plugins
  18.         sfOpenPNEAuthLoginIDPlugin
  19.         sfOpenPNESecurityUserPlugin
  20.     test
  21.         bootstrap
  22.         functional
  23.         unit
  24.     web
  25.         css
  26.         errors
  27.         images
  28.         js
  29.         uploads

libフォルダの中にformフォルダがある。どうやらsymfony 1.1のようです。
私の環境はいくつかのプロジェクトが入っているサーバなので、サーバ自体にsymfonyをインストールしたくないです。
(パッケージの中にsymfony本体を含めて欲しいんだけどな。。。)

2. symfony 1.1.1 本体のダウンロードと設置

そんなわけで、OpenPNE3 alpha1内にsymfonyを含めることにしました。意外と簡単。というか特に特別なことがいらなかった。

Bash:
  1. $ cd ./lib
  2. $ wget http://www.symfony-project.org/get/symfony-1.1.1.tgz
  3. $ tar zxvf symfony-1.1.1.tgz
  4. $ rm symfony-1.1.1.tgz

これで /lib/symfony-1.1.1のディレクトリの中にsymfonyがたくさんはいっている状態です。

3. 設定ファイルの準備

ここから設定系。まずはconfigディレクトリ内の*.sampleファイルをコピーして、
.sampleなしのファイルを作成します。OpenPNE3 開発用ページに便利コマンドが載ってるので採用します。

Bash:
  1. $ cd ../
  2. $ pwd
  3. /var/www/OpenPNE-3alpha1
  4. $ ls config/*.sample | sed -e 's/\.sample$//g' | awk '{print "cp "$1".sample "$1}' | sh

すると、databases.yml、ProjectConfiguration.class.php、propel.iniの3つが作成されます。

4. プロジェクト設定とsymfonyライブラリへのパスの指定

まずはconfig/ProjectConfiguration.class.php を編集して、さっきのsymfonyライブラリのディレクトリを指定してあげます。

Bash:
  1. $ vim config/ProjectConfiguration.class.php

スクリプト中に##SYMFONY_LIB_DIR#という文字列があるので、パスを指定します。さきほど解凍したsymfony-1.1.1ディレクトリの中のlibディレクトリが該当します。書き換えると、以下のようなスクリプトになります。(ルートは/var/www/OpenPNE- 3alpha1と仮定)

php:
  1. <?php
  2.  
  3. require_once '/var/www/OpenPNE-3alpha1/lib/symfony-1.1.1/lib/autoload/sfCoreAutoload.class.php';
  4. sfCoreAutoload::register();
  5.  
  6. class ProjectConfiguration extends sfProjectConfiguration
  7. {
  8.   public function setup()
  9.   {
  10.   }
  11. }

これでsymfonyライブラリへのパスが通ったので、symfonyコマンドも動くようになります。./symfonyを実行すると以下のようなコマンド一覧が表示されれば、パスの設定が正しいことを表します。逆に実行しても何も表示されずに終了してしまった場合、パスの設定が間違っているので、もう1 度確認してみてください。

Bash:
  1. $ pwd
  2. /var/www/OpenPNE-3alpha1
  3. $ ./symfony
  4. Available tasks:
  5.   :help               Displays help for a task (h)
  6.   :list               Lists tasks
  7. cache
  8.   :clear              Clears the cache (cc, clear-cache)
  9. configure
  10.   :author             Configure project author
  11.   :database           Configure database DSN
  12. generate
  13.   :app                Generates a new application (init-app)
  14.   :module             Generates a new module (init-module)
  15.   :project            Generates a new project (init-project)
  16.   :task               Creates a skeleton class for a new task
  17. i18n
  18.   :extract            Extracts i18n strings from php files
  19.   :find               Finds non "i18n ready" strings in an application
  20. log
  21.   :clear              Clears log files (log-purge)
  22.   :rotate             Rotates an application log files (log-rotate)
  23. plugin
  24.   :add-channel        Add a new PEAR channel
  25.   :install            Installs a plugin (plugin-install)
  26.   :list               Lists installed plugins (plugin-list)
  27.   :uninstall          Uninstalls a plugin (plugin-uninstall)
  28.   :upgrade            Upgrades a plugin (plugin-upgrade)
  29. project
  30.   :clear-controllers  Clears all non production environment controllers (clear-controllers)
  31.   :deploy             Deploys a project to another server (sync)
  32.   :disable            Disables an application in a given environment (disable)
  33.   :enable             Enables an application in a given environment (enable)
  34.   :freeze             Freezes symfony libraries (freeze)
  35.   :permissions        Fixes symfony directory permissions (permissions, fix-perms)
  36.   :unfreeze           Unfreezes symfony libraries (unfreeze)
  37.   :upgrade1.1         Upgrade a symfony project to the 1.1 symfony release
  38. propel
  39.   :build-all          Generates Propel model, SQL and initializes the database (propel-build-all)
  40.   :build-all-load     Generates Propel model, SQL, initializes database, and load data (propel-build-all-load)
  41.   :build-db           Creates database for current model (propel-build-db)
  42.   :build-forms        Creates form classes for the current model
  43.   :build-model        Creates classes for the current model (propel-build-model)
  44.   :build-schema       Creates a schema.xml from an existing database (propel-build-schema)
  45.   :build-sql          Creates SQL for the current model (propel-build-sql)
  46.   :data-dump          Dumps data to the fixtures directory (propel-dump-data)
  47.   :data-load          Loads data from fixtures directory (propel-load-data)
  48.   :generate-crud      Generates a Propel CRUD module (propel-generate-crud)
  49.   :init-admin         Initializes a Propel admin module (propel-init-admin)
  50.   :insert-sql         Inserts SQL for current model (propel-insert-sql)
  51.   :schema-to-xml      Creates schema.xml from schema.yml (propel-convert-yml-schema)
  52.   :schema-to-yml      Creates schema.yml from schema.xml (propel-convert-xml-schema)
  53. test
  54.   :all                Launches all tests (test-all)
  55.   :functional         Launches functional tests (test-functional)
  56.   :unit               Launches unit tests (test-unit)

5. データベースの設定

次はMySQLにユーザーとデータベースを新規に作成します。DB名は「openpne3alpha1」、ユーザー名も「openpne3alpha1」、パスワードは「123456」と仮定します。

Bash:
  1. $ mysql -u root
  2. Welcome to the MySQL monitor.  Commands end with ; or \g.
  3. Your MySQL connection id is 10 to server version: 5.0.22
  4.  
  5. Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
  6.  
  7. mysql> CREATE DATABASE openpne3alpha1 DEFAULT CHARACTER SET utf8;
  8. Query OK, 1 row affected (0.22 sec)
  9.  
  10. mysql> GRANT ALL ON openpne3alpha1.* TO openpne3alpha1@localhost IDENTIFIED BY "123456";
  11. Query OK, 0 rows affected (0.07 sec)
  12.  
  13. mysql> exit
  14. Bye

MySQLの設定が終了次第、symfonyコマンドを用いてDSN(Data Source Name)を一括設定します。以下のコマンドを実行すると、configディレクトリ内のdatabases.ymlやpropel.iniの中のDSN 部分が一括で書き換えられます。

Bash:
  1. $ ./symfony configure:database mysql://openpne3alpha1:123456@localhost/openpne3alpha1

忘れてはいけないのが、config/databases.ymlにデータベースのエンコードを指定することです。「encoding: utf8」という記述を含めます。

Bash:
  1. $ vim config/databases.yml

YAMLファイルは以下のようになります。

TEXT:
  1. all:
  2.   propel:
  3.     class: sfPropelDatabase
  4.     param:
  5.       dsn: 'mysql://openpne3alpha1:123456@localhost/openpne3alpha1'
  6.       encoding: utf8

最後に、symfonyコマンドのpropel:build-all-loadを実行して、スキーマファイルに基づきモデルとCREATE TABLE文を作成し、TABLEは実際に作成し、さらにテストデータも挿入します。

Bash:
  1. $ ./symfony propel:build-all-load pc_frontend
  2. >> schema    converting "/var/www/OpenPNE-3alpha1/config/schema.yml" to XML
  3. >> schema    putting /var/www/OpenPNE-3alpha1/config/generated-schema.xml
  4. >> schema    converting "/var/www/OpenPNE-3a...lugin/config/schema.yml" to XML
  5. >> schema    putting /var/www/OpenPNE-3alpha...PNEAuthLoginIDPlugin-schema.xml
  6. >> file+     config/generated-sfOpenPNEAuthLoginIDPlugin-schema.xml
  7. >> file-     /var/www/OpenPNE-3alpha1/plugin...PNEAuthLoginIDPlugin-schema.xml
  8. Buildfile: /var/www/OpenPNE-3alpha1/lib/symfony-1.1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/build.xml
  9. [resolvepath] Resolved /var/www/OpenPNE-3alpha1/config to /var/www/OpenPNE-3alpha1/config
  10.  
  11. propel-project-builder> check-project-or-dir-set:
  12.  
  13. propel-project-builder> check-project-set:
  14.  
  15. propel-project-builder> set-project-dir:
  16.  
  17. propel-project-builder> check-buildprops-exists:
  18.  
  19. propel-project-builder> check-buildprops-for-propel-gen:
  20.  
  21. propel-project-builder> check-buildprops:
  22.  
  23. propel-project-builder> configure:
  24.      [echo] Loading project-specific props from /var/www/OpenPNE-3alpha1/config/propel.ini
  25.  [property] Loading /var/www/OpenPNE-3alpha1/config/propel.ini
  26.  
  27. propel-project-builder> om:
  28.     [phing] Calling Buildfile '/var/www/OpenPNE-3alpha1/lib/symfony-1.1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/build-propel.xml' with target 'om'
  29.  [property] Loading /var/www/OpenPNE-3alpha1/lib/symfony-1.1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/./default.properties
  30.  
  31. propel> check-run-only-on-schema-change:
  32.  
  33. propel> om-check:
  34.  
  35. propel> om:
  36.      [echo] +------------------------------------------+
  37.      [echo] |                                          |
  38.      [echo] | Generating Peer-based Object Model for   |
  39.      [echo] | YOUR Propel project! (NEW OM BUILDERS)!  |
  40.      [echo] |                                          |
  41.      [echo] +------------------------------------------+
  42. [phingcall] Calling Buildfile '/var/www/OpenPNE-3alpha1/lib/symfony-1.1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/build-propel.xml' with target 'om-template'
  43.  [property] Loading /var/www/OpenPNE-3alpha1/lib/symfony-1.1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/./default.properties
  44.  
  45. propel> om-template:
  46. [propel-om] Target database type: mysql
  47. [propel-om] Target package: lib.model
  48. [propel-om] Using template path: /var/www/OpenPNE-3alpha1/lib/symfony-1.1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/templates
  49. [propel-om] Output directory: /var/www/OpenPNE-3alpha1
  50. [propel-om] Processing: generated-schema.xml
  51. [propel-om] Could not perform XLST transformation.  Make sure PHP has been compiled/configured to support XSLT.
  52. [propel-om] Processing: generated-sfOpenPNEAuthLoginIDPlugin-schema.xml
  53. [propel-om] Could not perform XLST transformation.  Make sure PHP has been compiled/configured to support XSLT.
  54. [propel-om] Processing Datamodel : JoinedDataModel
  55. [propel-om]   - processing database : propel
  56. [propel-om]     + member
  57. [propel-om]             -> BaseMemberPeer [builder: SfPeerBuilder]
  58. [propel-om]             -> BaseMember [builder: SfObjectBuilder]
  59. [propel-om]             -> MemberMapBuilder [builder: SfMapBuilderBuilder]
  60. [propel-om]             -> (exists) MemberPeer
  61. [propel-om]             -> (exists) Member
  62. [propel-om]     + profile
  63. [propel-om]             -> BaseProfilePeer [builder: SfPeerBuilder]
  64. [propel-om]             -> BaseProfile [builder: SfObjectBuilder]
  65. [propel-om]             -> ProfileMapBuilder [builder: SfMapBuilderBuilder]
  66. [propel-om]             -> (exists) ProfilePeer
  67. [propel-om]             -> (exists) Profile
  68. [propel-om]     + profile_i18n
  69. [propel-om]             -> BaseProfileI18nPeer [builder: SfPeerBuilder]
  70. [propel-om]             -> BaseProfileI18n [builder: SfObjectBuilder]
  71. [propel-om]             -> ProfileI18nMapBuilder [builder: SfMapBuilderBuilder]
  72. [propel-om]             -> (exists) ProfileI18nPeer
  73. [propel-om]             -> (exists) ProfileI18n
  74. [propel-om]     + profile_option
  75. [propel-om]             -> BaseProfileOptionPeer [builder: SfPeerBuilder]
  76. [propel-om]             -> BaseProfileOption [builder: SfObjectBuilder]
  77. [propel-om]             -> ProfileOptionMapBuilder [builder: SfMapBuilderBuilder]
  78. [propel-om]             -> (exists) ProfileOptionPeer
  79. [propel-om]             -> (exists) ProfileOption
  80. [propel-om]     + profile_option_i18n
  81. [propel-om]             -> BaseProfileOptionI18nPeer [builder: SfPeerBuilder]
  82. [propel-om]             -> BaseProfileOptionI18n [builder: SfObjectBuilder]
  83. [propel-om]             -> ProfileOptionI18nMapBuilder [builder: SfMapBuilderBuilder]
  84. [propel-om]             -> (exists) ProfileOptionI18nPeer
  85. [propel-om]             -> (exists) ProfileOptionI18n
  86. [propel-om]     + member_profile
  87. [propel-om]             -> BaseMemberProfilePeer [builder: SfPeerBuilder]
  88. [propel-om]             -> BaseMemberProfile [builder: SfObjectBuilder]
  89. [propel-om]             -> MemberProfileMapBuilder [builder: SfMapBuilderBuilder]
  90. [propel-om]             -> (exists) MemberProfilePeer
  91. [propel-om]             -> (exists) MemberProfile
  92. [propel-om]     + friend
  93. [propel-om]             -> BaseFriendPeer [builder: SfPeerBuilder]
  94. [propel-om]             -> BaseFriend [builder: SfObjectBuilder]
  95. [propel-om]             -> FriendMapBuilder [builder: SfMapBuilderBuilder]
  96. [propel-om]             -> (exists) FriendPeer
  97. [propel-om]             -> (exists) Friend
  98. [propel-om]     + community
  99. [propel-om]             -> BaseCommunityPeer [builder: SfPeerBuilder]
  100. [propel-om]             -> BaseCommunity [builder: SfObjectBuilder]
  101. [propel-om]             -> CommunityMapBuilder [builder: SfMapBuilderBuilder]
  102. [propel-om]             -> (exists) CommunityPeer
  103. [propel-om]             -> (exists) Community
  104. [propel-om]     + community_member
  105. [propel-om]             -> BaseCommunityMemberPeer [builder: SfPeerBuilder]
  106. [propel-om]             -> BaseCommunityMember [builder: SfObjectBuilder]
  107. [propel-om]             -> CommunityMemberMapBuilder [builder: SfMapBuilderBuilder]
  108. [propel-om]             -> (exists) CommunityMemberPeer
  109. [propel-om]             -> (exists) CommunityMember
  110. [propel-om]     + authentication_login_id
  111. [propel-om]             -> BaseAuthenticationLoginIdPeer [builder: SfPeerBuilder]
  112. [propel-om]             -> BaseAuthenticationLoginId [builder: SfObjectBuilder]
  113. [propel-om]             -> AuthenticationLoginIdMapBuilder [builder: SfMapBuilderBuilder]
  114. [propel-om]             -> (exists) AuthenticationLoginIdPeer
  115. [propel-om]             -> (exists) AuthenticationLoginId
  116.  
  117. BUILD FINISHED
  118.  
  119. Total time: 3.3003 seconds
  120. >> file-     /var/www/OpenPNE-3alpha1/config...PNEAuthLoginIDPlugin-schema.xml
  121. >> file-     /var/www/OpenPNE-3alpha1/config/generated-schema.xml
  122. >> autoload  reloading autoloading
  123. >> schema    converting "/var/www/OpenPNE-3alpha1/config/schema.yml" to XML
  124. >> schema    putting /var/www/OpenPNE-3alpha1/config/generated-schema.xml
  125. >> schema    converting "/var/www/OpenPNE-3a...lugin/config/schema.yml" to XML
  126. >> schema    putting /var/www/OpenPNE-3alpha...PNEAuthLoginIDPlugin-schema.xml
  127. >> file+     config/generated-sfOpenPNEAuthLoginIDPlugin-schema.xml
  128. >> file-     /var/www/OpenPNE-3alpha1/plugin...PNEAuthLoginIDPlugin-schema.xml
  129. Buildfile: /var/www/OpenPNE-3alpha1/lib/symfony-1.1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/build.xml
  130. [resolvepath] Resolved /var/www/OpenPNE-3alpha1/config to /var/www/OpenPNE-3alpha1/config
  131.  
  132. propel-project-builder> check-project-or-dir-set:
  133.  
  134. propel-project-builder> check-project-set:
  135.  
  136. propel-project-builder> set-project-dir:
  137.  
  138. propel-project-builder> check-buildprops-exists:
  139.  
  140. propel-project-builder> check-buildprops-for-propel-gen:
  141.  
  142. propel-project-builder> check-buildprops:
  143.  
  144. propel-project-builder> configure:
  145.      [echo] Loading project-specific props from /var/www/OpenPNE-3alpha1/config/propel.ini
  146.  [property] Loading /var/www/OpenPNE-3alpha1/config/propel.ini
  147.  
  148. propel-project-builder> sql:
  149.     [phing] Calling Buildfile '/var/www/OpenPNE-3alpha1/lib/symfony-1.1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/build-propel.xml' with target 'sql'
  150.  [property] Loading /var/www/OpenPNE-3alpha1/lib/symfony-1.1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/./default.properties
  151.  
  152. propel> check-run-only-on-schema-change:
  153.  
  154. propel> sql-check:
  155.  
  156. propel> pgsql-quoting-check:
  157.  
  158. propel> sql:
  159.      [echo] +------------------------------------------+
  160.      [echo] |                                          |
  161.      [echo] | Generating SQL for YOUR Propel project!  |
  162.      [echo] |                                          |
  163.      [echo] +------------------------------------------+
  164. [phingcall] Calling Buildfile '/var/www/OpenPNE-3alpha1/lib/symfony-1.1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/build-propel.xml' with target 'sql-template'
  165.  [property] Loading /var/www/OpenPNE-3alpha1/lib/symfony-1.1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/./default.properties
  166.  
  167. propel> sql-template:
  168. [propel-sql] Processing: generated-schema.xml
  169. [propel-sql] Could not perform XLST transformation.  Make sure PHP has been compiled/configured to support XSLT.
  170. [propel-sql] Processing: generated-sfOpenPNEAuthLoginIDPlugin-schema.xml
  171. [propel-sql] Could not perform XLST transformation.  Make sure PHP has been compiled/configured to support XSLT.
  172. [propel-sql] Writing to SQL file: /var/www/OpenPNE-3alpha1/data/sql/lib.model.schema.sql
  173. [propel-sql]    + member [builder: MysqlDDLBuilder]
  174. [propel-sql]    + profile [builder: MysqlDDLBuilder]
  175. [propel-sql]    + profile_i18n [builder: MysqlDDLBuilder]
  176. [propel-sql]    + profile_option [builder: MysqlDDLBuilder]
  177. [propel-sql]    + profile_option_i18n [builder: MysqlDDLBuilder]
  178. [propel-sql]    + member_profile [builder: MysqlDDLBuilder]
  179. [propel-sql]    + friend [builder: MysqlDDLBuilder]
  180. [propel-sql