日本時間の2011-07-29にSymfony2がリリースされました。早速ながら使ってみることにしました。
環境
最初に開発を行った環境を記しておきます。サードパーティのパッケージは使っておらず、どれもUbuntu 11.04のaptitudeでインストールしたLAMP環境です。
- OS
- Ubuntu Server 11.04 x64
- Apache
- 2.2.17
- MySQL
- 5.1.54
- PHP
- 5.3.5-1ubuntu7.2
- git
- 1.7.4.1
インストール
まずはSymfony2のアーカイブのダウンロードをします。アーカイブはSymfony2のダウンロードページにあります。通常はSymfony Standardをインストールすると思いますが、gitをインストールしている環境ではSymfony Standard without vendorsを選択しても良いです。私は後者の方をインストールしました。
% wget -O ~/tmp/Symfony_Standard_2.0.0.tgz "http://symfony.com/download?v=Symfony_Standard_2.0.0.tgz"
続いてダウンロードしたアーカイブを任意のディレクトリへ解凍します。任意とは言え、ウェブ上へ公開されていないディレクトリへ解凍します。
% tar -xzpf ~/tmp/Symfony_Standard_2.0.0.tgz % cd Symfony
環境の確認
解凍が終わったところで環境の確認を行います。これは用意されているコマンドを叩けばOKです。
% php app/check.php
不足があると画面へ表示されますので、適宜対応を行います。私の環境では、SQLiteとintl、apcの拡張が不足していると表示されました。
% sudo aptitude install php5-sqlite % sudo aptitude install php5-intl % sudo aptitude install php-apc
拡張だけでなく、設定でいくつかの不備があると表示されました。Ubuntu(Debian)のPHPはSAPIごとに設定ファイルが分かれているので、共通で読み込まれる設定ファイルを新たに用意することで対応しました。
% cat /etc/php5/conf.d/global.ini date.timezone = "Asia/Tokyo" short_open_tag = Off
これで全てのチェックをパスしました。
% php app/check.php ******************************** * * * Symfony requirements check * * * ******************************** php.ini used by PHP: /etc/php5/cli/php.ini ** WARNING ** * The PHP CLI can use a different php.ini file * than the one used with your web server. * If this is the case, please ALSO launch this * utility from your web server. ** WARNING ** ** Mandatory requirements ** OK Checking that PHP version is at least 5.3.2 (5.3.5-1ubuntu7.2 installed) OK Checking that the "date.timezone" setting is set OK Checking that app/cache/ directory is writable OK Checking that the app/logs/ directory is writable OK Checking that the json_encode() is available OK Checking that the SQLite3 or PDO_SQLite extension is available OK Checking that the session_start() is available OK Checking that the ctype_alpha() is available ** Optional checks ** OK Checking that the PHP-XML module is installed OK Checking that the libxml version is at least 2.6.21 OK Checking that the token_get_all() function is available OK Checking that the mb_strlen() function is available OK Checking that the iconv() function is available OK Checking that the utf8_decode() is available OK Checking that the posix_isatty() is available OK Checking that the intl extension is available OK Checking that the intl ICU version is at least 4+ OK Checking that a PHP accelerator is installed OK Checking that the APC version is at least 3.0.17 OK Checking that php.ini has short_open_tag set to off OK Checking that php.ini has magic_quotes_gpc set to off OK Checking that php.ini has register_globals set to off OK Checking that php.ini has session.auto_start set to off ** Optional checks (Doctrine) ** OK Checking that PDO is installed OK Checking that PDO has some drivers installed: mysql, sqlite, sqlite2
ベンダーライブラリのインストール
Symfony Standard without vendorsを選択した場合は次のコマンドを実行し、ベンダーライブラリをインストールします。Symfony Standardを選択した場合は不要であると思います。
% php bin/vendors install
インストールの検証
Symfony2のインストールが無事に完了したか確認を行います。今回はApacheの設定で、DocumentRootをSymfony/webとしました。
% cat cat /etc/apache2/sites-available/default ... DocumentRoot /home/ryosuke/work/Symfony/web ...
続いて設定と確認を行うファイルに、アクセス元のIPアドレスを追加します。ここでは192.168.0.104がそれです。
diff --git a/web/app_dev.php b/web/app_dev.php index d73f157..34fc722 100644 --- a/web/app_dev.php +++ b/web/app_dev.php @@ -4,6 +4,7 @@ // feel free to remove this, extend it, or make something more sophisticated. if (!in_array(@$_SERVER['REMOTE_ADDR'], array( '127.0.0.1', + '192.168.0.104', '::1', ))) { header('HTTP/1.0 403 Forbidden'); diff --git a/web/config.php b/web/config.php index b13ddca..24a1bb7 100644 --- a/web/config.php +++ b/web/config.php @@ -6,6 +6,7 @@ if (!isset($_SERVER['HTTP_HOST'])) { if (!in_array(@$_SERVER['REMOTE_ADDR'], array( '127.0.0.1', + '192.168.0.104', '::1', ))) { header('HTTP/1.0 403 Forbidden');
上記設定ののち、サーバのIPアドレスへ接続し、config.phpとapp_dev.phpへアクセスします。これらが見えるようになっていれば、Symfony2のインストールは完了です。
Leave a Reply