インストール
- 各サービスのインストール
- 基本PHPのモジュールインストール
各サービスのインストール
yum install -y httpd24 php56 mysql56 git
基本phpモジュールのインストール
phpのモジュールをインストールする。
yum install -y php56-mcrypt php56-intl php56-mbstring php56-mysqlnd php56-opcache php56-devel
各サービスの設定
git設定
◆gitコマンド時にユーザー、パスワードを省略する
ホームディレクトリ.netrc
を作成
#vi .netrc
machine [ホスト]
login [ユーザー]
password [パスワード]
◆プロジェクトを取得する
ホームディレクトリで取得する。
#git clone [URL]
apache設定
◆virtualconfの設定
構成:
・ホームディレクトリにプロジェクトを置きます。
・ELBのヘルスチェックのログとプロジェクトに対してのログは分けます。
・バーチャルconfに記述のRemoteIPHeader X-Forwarded-For
でログに相手のパブリックIPを表示させる。(/etc/httpd/conf/httpd.conf
のログフォーマットも変えないといけませんので後に記述)
バーチャルconfの作成
#vi /etc/httpd/conf.d/projects.conf
ServerName example.com
<VirtualHost *:80>
DocumentRoot /home/user/projects/
ServerName example.com
SetEnvIf User-Agent "ELB-HealthChecker*" elb
SetEnvIf User-Agent "ELB-HealthChecker*" nolog
SetEnvIf User-Agent "internal dummy connection" nolog
ErrorLog logs/projects-error_log
CustomLog logs/projects-access_log combined env=!nolog
CustomLog logs/elb-helth_log combined env=elb
RemoteIPHeader X-Forwarded-For
<Directory /home/user/projects>
Options +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
◆httpd.confの設定
ログにアクセスしてきた人のパブリックIPを表示させます。
変更前:LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
変更後:LogFormat "%a %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
◆ディレクトリの権限の変更
apacheユーザーがProjectを読み込めるように設定
#chown -R user:apache /home/user
#chmod 2775 /home/user
#find /home/user -type d -exec chmod 2775 {} \;
#find /home/user -type f -exec chmod 0664 {} \;
◆自動起動
#chkconfig httpd on
◆起動
#/etc/init.d/httpd start
mysql
◆RDSへの接続テスト
RDSはauroraかmysqlを想定
mysql -u user -h RDSエンドポイント -D database -p
◆.myconfでmysqlコマンドを省略して接続
ホームディレクトリに.my.conf
を作成する
#vi .my.conf
[client]
host = host
user = user
password ="password"
database = database