Skip to content

Instantly share code, notes, and snippets.

@ksomemo
Last active August 29, 2015 14:08
Show Gist options
  • Save ksomemo/aad9528cea8d3fadea1a to your computer and use it in GitHub Desktop.
Save ksomemo/aad9528cea8d3fadea1a to your computer and use it in GitHub Desktop.

PHP5.5 on EC2

sudo yum remove php-* httpd-*
sudo yum install -y httpd24 
sudo yum install -y php55
sudo yum install -y php55-cli
sudo yum install -y php55-common
sudo yum install -y php55-devel
sudo yum install -y php55-intl
sudo yum install -y php55-mbstring
sudo yum install -y php55-mcrypt
sudo yum install -y php55-mysqlnd
sudo yum install -y php55-opcache
sudo yum install -y php55-pdo
sudo yum install -y php55-pecl-apcu
sudo yum install -y php55-pecl-jsonc
sudo yum install -y php55-pecl-memcache
sudo yum install -y php55-pecl-memcached
sudo yum install -y php55-pecl-oauth
sudo yum install -y php55-pecl-redis
sudo yum install -y php55-pecl-ssh2
sudo yum install -y php55-pecl-xdebug
sudo yum install -y php55-xml
sudo service httpd start
sudo chkconfig httpd on

php.ini

default_charset = "UTF-8"

mbstring.language = Japanese
mbstring.internal_encoding = UTF-8
mbstring.http_input = pass
mbstring.http_output = pass
mbstring.encoding_translation=off
mbstring.detect_order=auto

; date.timezone = Asia/Tokyo

apcu

TODO

opcache

http://php.net/manual/ja/opcache.configuration.php

xdebug

$ vi /usr/local/etc/php/5.5/conf.d/ext-xdebug.ini
[xdebug]
zend_extension="/usr/local/Cellar/php55-xdebug/2.2.3/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_port="9000"
xdebug.profiler_enable=0
xdebug.profiler_output_dir="/tmp"
xdebug.max_nesting_level=1000
xdebug.idekey = "PHPSTORM"

laravel

chmod 777 app/storage/logs
chmod 777 app/storage/sessions

td-agent

curl -L http://toolbelt.treasuredata.com/sh/install-redhat.sh | sh

td-agent --version

td-agent 0.10.55

default plugins

td-agent-gem list --local
  • fluent-plugin-flume (0.1.1)
  • fluent-plugin-mongo (0.7.3)
  • fluent-plugin-rewrite-tag-filter (1.4.1)
  • fluent-plugin-s3 (0.4.1)
  • fluent-plugin-scribe (0.10.12)
  • fluent-plugin-td (0.10.22)
  • fluent-plugin-td-monitoring (0.1.3)
  • fluent-plugin-webhdfs (0.3.1)

file dir

sudo mkdir /var/log/mf_recommend/
sudo mkdir /var/log/mf_recommend/s3
sudo chmod 777 /var/log/mf_recommend/
sudo chmod 777 /var/log/mf_recommend/s3
# for request action log
<match mf_recommend>
  type file
  path /var/log/mf_recommend/mf_recommend
  time_slice_format %Y%m%d
  time_slice_wait 5s
  time_format %Y-%m-%d %H:%M:%S
</match>
<match pattern>
  type s3

  aws_key_id xxx
  aws_sec_key yyy/zzz
  s3_bucket mf.recommend
  s3_region ap-southeast-1
#  s3_endpoint s3-ap-southeast-1.amazonaws.com
  s3_object_key_format %{path}%{time_slice}_%{index}.%{file_extension}
  path logs/
  buffer_path /var/log/mf_recommend/s3
  time_slice_format %Y%m%d-%H
#  time_slice_wait 10m
  utc
#  flush_interval 5s
  flush_interval 60m
</match>

composer

  • laravle
  • fluent-logger-php
  • aws-sdk-php (2.7.4
  • generator
	"require": {
		"laravel/framework": "4.2.0",
		"fluent/logger": "v0.3.7",
		"aws/aws-sdk-php": "*"
	},
	"require-dev": {
		"way/generators": "~2.0"
	}

vendor/composer/autoload_namespaces.php が更新される

MongoDB

repository

echo "[MongoDB]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64
gpgcheck=0
enabled=1" | sudo tee -a /etc/yum.repos.d/mongodb.repo

install

sudo yum install -y mongodb-org-server mongodb-org-shell mongodb-org-tools

php library

sudo pecl install mongo

Error(not found required software)

Build with Cyrus SASL (MongoDB Enterprise Authentication) support? [no] :
ERROR: `/var/tmp/mongo/configure --with-mongo-sasl=no' failed

http://www.mongodb.org/about/contributors/tutorial/build-mongodb-from-source/#dependencies-installation

add gcc and glibc

required gcc, glibc

sudo yum install -y gcc glibc
(1/9): cpp48-4.8.2-16.2.99.amzn1.x86_64.rpm          
(2/9): gcc-4.8.2-3.19.amzn1.noarch.rpm               
(3/9): gcc48-4.8.2-16.2.99.amzn1.x86_64.rpm          
(4/9): glibc-devel-2.17-55.87.amzn1.x86_64.rpm       
(5/9): glibc-headers-2.17-55.87.amzn1.x86_64.rpm     
(6/9): kernel-headers-3.14.20-20.44.amzn1.x86_64.rpm 
(7/9): libgomp-4.8.2-16.2.99.amzn1.x86_64.rpm        
(8/9): libmpc-0.8.2-1.4.amzn1.x86_64.rpm             
(9/9): mpfr-2.4.2-1.7.amzn1.x86_64.rpm

config

sudo touch /etc/php.d/mongo.ini
echo "extension=mongo.so" | sudo tee -a /etc/php.d/mongo.ini
php -m | grep mongo

service settings

sudo chkconfig --list | grep mongo
mongod          0:off   1:off   2:off   3:on    4:off   5:on    6:off

confirm server process

sudo service mongod start
ps aux | grep mongod
mongod    /usr/bin/mongod -f /etc/mongod.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment