Ubuntu11.04にSymfony2をインストール

Symfony2をインストールした際のメモです。

sudo apt-get install apache2
sudo apt-get install mysql-server
sudo apt-get install php5 php5-mysql php-pear php-apc php5-intl
sudo apt-get install sqlite3 php5-sqlite
sudo apt-get install make libpcre3-dev                 

mkdir ~/installed
wget -O ~/installed/Symfony_Standard_2.0.4.tgz "http://symfony.com/download?v=Symfony_Standard_2.0.4.tgz" 
tar -xzpf ~/installed/Symfony_Standard_2.0.4.tgz

cd /var/www
sudo ln -s /home/user/installed/Symfony

sudo vi /etc/php5/apache2/php.ini
sudo nano /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.3 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
  OK        Checking that the token_get_all() is available
  OK        Checking that the APC version is at least 3.0.17

** Optional checks **

  OK        Checking that the PHP-XML module is installed
  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 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


php bin/vendors install --reinstall
http://(サーバーアドレス)/Symfony/web/config.php


localhost以外のアスセスして、以下のエラーが出た場合は、

error: This script is only accessible from localhost.
nano /var/www/Symfony/web/config.php
nano /var/www/Symfony/web/app_dev.php

# 以下削除
if (!in_array(@$_SERVER['REMOTE_ADDR'], array(
    '127.0.0.1',
    '::1',
))) {
    header('HTTP/1.0 403 Forbidden');
    die('This script is only accessible from localhost.');
}

f:id:t-taira:20111030114104p:image