Php/Symfony/Symfony2/インストール
提供: 初心者エンジニアの簡易メモ
目次
composer追加
$ curl -s http://getcomposer.org/installer | php $ sudo mv composer.phar /usr/local/bin/composer.phar $ composer -V Composer version 1.2.4 2016-12-06 22:00:51
symfonyインストーラーのDL
curl -LsS http://symfony.com/installer > symfony.phar sudo mv symfony.phar /usr/local/bin/symfony chmod a+x /usr/local/bin/symfony symfony --help
symfony2.3のプロジェクトを作成
$ symfony new leaning-symfony2 2.3 Symfony 2.3.42 was successfully installed. Now you can:
symfony2.8のプロジェクトを作成
$ symfony new leaning-symfony2_8 2.8 Symfony 2.8.19 was successfully installed. Now you can:
composer実行
composer.phar install
準備
mkdir app/cache
simplexml_import_dom() must be available がでた場合
(debian系の場合) sudo apt-get install php7.0-xml
the requested PHP extension mbstring is missing from your system. がでた場合
(debian系の場合) sudo apt-get install php7.0-mbstring
the requested PHP extension soap is missing from your system.
(debian系の場合) sudo apt-get install php7.0-soap
Install PDO drivers (mandatory for Doctrine).
(debian系の場合) sudo apt-get install php7.0-pdo php7.0-mysql
インストール確認
php app/check.php
timezone修正
$ php -r "phpinfo();" | grep php.ini $ vi /etc/php5/cli/php.ini date.timezone = Asia/Tokyo
設定ファイル
$ vi app/config/parameters.yml parameters: database_driver: pdo_mysql database_host: 127.0.0.1 database_port: null database_name: symfony database_user: root database_password: null mailer_transport: smtp mailer_host: 127.0.0.1 mailer_user: null mailer_password: null locale: en secret: e1d43f3fa7a03ac8dc47196fd9ffb4xxxxxxxxxx
ビルトインサーバで起動
php app/console server:run localhost:8000
localhost:8000をブラウザで開く
バージョン確認方法
$ app/console -V Symfony version 2.3.42 - app/dev/debug
venderがない時
php composer.phar install
webの下に.cssなどがない時
$ app/console assets:install $ tree web web/bundles/ ├── framework │ ├── css │ │ ├── body.css │ │ ├── exception.css │ │ └── structure.css │ └── images │ ├── blue_picto_less.gif │ ├── blue_picto_more.gif │ ├── grey_magnifier.png │ └── logo_symfony.png └── sensiodistribution └── webconfigurator ├── css │ ├── configurator.css │ └── install.css └── images ├── blue-arrow.png ├── favicon.ico └── notification.gif
cacheディレクトリ権限
sudo chmod 777 -R app/cache/dev sudo chmod 777 -R app/cache/prod
logディレクトリ権限
sudo chmod 777 -R app/logs
cacheクリア
本番
php app/console cache:clear --env=prod --no-debug
開発
php app/console cache:clear --env=dev --no-debug
bootstrap.php.cache再作成
php ./vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php
nginxのlogに502の以下エラーが出る場合
*1 upstream sent too big header while reading response header from upstream, client:
vi /etc/nginx/conf.d/hogehoge.confのhttp{}内に以下を追加 fastcgi_intercept_errors on; fastcgi_ignore_client_abort off; fastcgi_connect_timeout 60; fastcgi_send_timeout 180; fastcgi_read_timeout 180; fastcgi_buffer_size 128k; fastcgi_buffers 4 256k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k;