2014年5月2日金曜日

Symfony2をComposerでインストール

Vagrant/CentOSにSymfony2をインストールしようとしたら手こずったのでメモする。


Symfony2の公式サイトにある通りコマンドを実行する。

まずComposerを用意する。
$ curl -s https://getcomposer.org/installer | php

次にSymfony2をインストールする。
$ php composer.phar create-project symfony/framework-standard-edition /path/to/webroot/Symfony 2.4.4

> /path/to/webroot/
この部分はSymfony2を配置したいディレクトリ(Webサーバーのドキュメントルート)を指定する

> 2.4.4
この部分は最新バージョンを指定する。

実行した結果・・・
Fatal error: Class 'DOMDocument' not found in /vagrant/Symfony/Symfony/vendor/symfony/symfony/src/Symfony/Component/Config/Util/XmlUtils.php on line 52
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-install-cmd event terminated with an exception
  [RuntimeException]                                                       
  An error occurred when executing the "'cache:clear --no-warmup'" command.
こんなエラーが出た。

> Fatal error: Class 'DOMDocument' not found
これを調べてみるとphp-xmlが無いとのこと。

yumでphp-xmlをインストールする。
$ sudo yum install php-xml

こっちでもエラー発生
--> Finished Dependency Resolution
Error: Package: php-xml-5.3.3-27.el6_5.x86_64 (updates)
           Requires: php-common(x86-64) = 5.3.3-27.el6_5
           Installed: php-common-5.4.22-1.el6.remi.x86_64 (@remi)
               php-common(x86-64) = 5.4.22-1.el6.remi
           Available: php-common-5.3.3-26.el6.x86_64 (base)
               php-common(x86-64) = 5.3.3-26.el6
           Available: php-common-5.3.3-27.el6_5.x86_64 (updates)
               php-common(x86-64) = 5.3.3-27.el6_5
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

Installed: php-common-5.4.22-1.el6.remi.x86_64 (@remi)
そういえばPHPはremiでインストールしていた。

ということで、こっちのコマンドでphp-xmlをインストール
$ sudo yum install --enablerepo=remi php-xml

無事にインストールできたので、Symfony2を再度インストールする・・・その前に、
インストール先のディレクトリに中途半端なSymfony2が作られているので削除してから再度インストールコマンドを実行して完了。

0 件のコメント:

コメントを投稿