Making a Symfony2 Application Basic Dev Environment on CentOS7 with SELinux

CentOS7に、Symfony2の環境を作った際の作業ログを残しておきます。SELinuxが有効な状態で作業を行っています。

必要なパッケージをインストール

# yum install httpd mariadb-server
# yum install php
# yum install php-pdo php-xml php-mbstring php-process php-intl php-mysql
# rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
# yum --enablerepo=remi install php-pecl-apc

次のコマンドを実行して、apcが有効になっているか確認しておきます。

 check : php -i | grep apc.enabled

PHP.INIの編集(date.timezoneを設定する)

# vi /etc/php.ini
 [Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
;date.timezone =
date.timezone = 'Asia/Tokyo'

Composerのインストール

# cd /tmp
# curl -sS https://getcomposer.org/installer | php
# mv composer.phar /usr/local/bin/composer

Composeを使ってプロジェクトを作成

ここでは、’testporject’という名前のプロジェクトを作成しています。

# cd /var/www/html
# composer create-project symfony/framework-standard-edition testproject
 全部単にRETURN(あとから修正できる)
# cd testproject
# chown -R apache:apache .
# chcon -R -t httpd_cache_t app/{cache,logs}
# chcon -t httpd_cache_t app/config/parameters.yml
# setsebool httpd_can_network_connect_db 1

次のコマンドで必要なライブラリが揃っているか確認します。

# php app/check.php

HTTPDとMariaDBの起動

# systemctl start httpd
# systemctl start mariadb

アプリケーションの初期設定

ブラウザから http://localhost/testproject/web/config.php にアクセスして必要な設定をして完了。