nginx php-fpm設定

ec2 amazon linux

php 適当 php55-fpmが必要
# yum install php55 php55-cli php55-devel 
php55-common php55-fpm php55-gd php55-mbstring
php55-opcache php55-pdo php55-pecl-memcached php55-pgsql
php55-xml php55-xmlrpc php55-pecl-jsonc php55-pecl-jsonc-devel php55-pecl-memcache

nginx
# yum install nginx

nignx設定
ec2のデフォルトのホスト名はとても長いので
下記が必要 デフォルト32なので64、128とエラーが出ないまで大きくする
# vim /etc/nginx/nginx.conf
http {
    server_names_hash_bucket_size 128;

unix sockでの接続にする
# vim /etc/nginx/conf.d/virtual.conf
server {
    listen      80;
    server_name ec2-xxxxxxxxxx.xxxxxxxxxxxxxxxx.compute.amazonaws.com;

    location / {
        root   /var/web/html;
        index  index.html index.htm;
    }
    location ~ \.php$ {
        #root           html;
        fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /var/web/html/$fastcgi_script_name;
        include        fastcgi_params;
    }
}

php-fpm設定
# vim /etc/php-fpm.d/www.conf
listen = /var/run/php-fpm/php-fpm.sock
listen.owner = nginx
listen.group = nginx
listen.owner = nginx
user=nginx
group = nginx

tcpdump

tcpdumpのオプション

オプション 内容
-X リンクレベルヘッダーを除くすべてのパケットを16進数で表示、さらにASCII文字も出力
-S シーケンス番号を絶対値でなく相対値で表示
-t 時間情報を表示しない
-n アドレス、ポートを名前に変換しない
-w filename ファイルに出力
-i lo インターフェイス指定
-port 80 条件ポート

centos7 コマンド

操作 SysV Init Systemd
起動 /etc/init.d/sshd start systemctl start sshd
終了 /etc/init.d/sshd stop systemctl stop sshd
強制終了 PID探してkill -9 systemctl kill -s 9 sshd
再起動 /etc/init.d/sshd restart systemctl restart sshd
設定反映 /etc/init.d/sshd reload systemctl reload sshd
状態取得 /etc/init.d/sshd status systemctl status sshd
自動起動を有効 chkconfig sshd on systemctl enable sshd
自動起動を無効 chkconfig sshd off systemctl disable sshd
自動起動の状態確認 chkconfig --list sshd systemctl is-enabled sshd(status でも表示される)
サービス一覧の表示 ls /etc/init.d systemctl --type service

参考URL
http://blog.yuryu.jp/2014/07/systemd-quick-guide.html

  • timezone設定
timezone一覧
# timedatectl list-timezones 
設定
# timedatectl set-timezone Asia/Tokyo
確認
# timedatectl
  • 時間同期
# yum install chrony
# vim /etc/chrony.conf
# systemctl start chronyd.service

aws cli

$ aws ec2 start-instances --instance-ids i-******

$ aws ec2 stop-instances --instance-ids i-*******
  • セキュリティグループ設定(追加)
今の設定を取得して
$ aws ec2 describe-instances  --instance-id ${iid} | jq -r '.Reservations.Instances.NetworkInterfaces.Groups.GroupId'
追加したいsgを追記(スペース区切り)
$ aws ec2 modify-instance-attribute --instance-id ${iid} --groups ${sgs}
  • ELB関連
情報
$ aws elb  describe-instance-health --load-balancer-name  elbdemo
インスタンス追加
$ aws elb register-instances-with-load-balancer --load-balancer-name  elbdemo --instances i-*****
インスタンス解除
$ aws elb deregister-instances-from-load-balancer --load-balancer-name elbdemo --instances i-******

fluentdからpostgresqlにinsertする

準備

これは必須
# rpm -aq | grep  postgresql93-devel
これはいらないかも
# /usr/lib64/fluent/ruby/bin/fluent-gem install pg -- --with-pg-config=/usr/pgsql-9.3/bin/pg_config
これは必須
# /usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-postgres -- --with-pg-config=/usr/pgsql-9.3/bin/pg_config

今日はここまで

参考
https://github.com/uken/fluent-plugin-postgres