Amazon Linux에 php7.1.2 + Symfony3.2 + New Relic Servers/APM 설치 노트

New Relic은 로그인한 전제

필요에 따라


$ sudo yum update -y
$ sudo yum install -y vim zsh git wget curl tmux bzip2

NGINX


$ sudo yum install -y nginx

sudoedit/etc/nginx/conf.d/default.conf

/etc/nginx/conf.d/default.conf
server {
  listen "8071";
  root /var/www/hoge/web;
  location ~ \.php.*$ {
    fastcgi_split_path_info ^(.+\.php)(.*)$;
    fastcgi_pass unix:/var/run/php-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
    include fastcgi_params;
  }
}

사용자


$ sudo useradd -g nginx -s /bin/bash www

PHP



필요한 컴파일러, 라이브러리 설치
$ sudo yum install -y gcc gcc-c++ libgcc cmake ncurses-devel re2c autoconf automake bison libxml2 libxml2-devel openssl-devel curl-devel libpng libpng-devel libmcrypt libmcrypt-devel readline-devel libtidy libtidy-devel libxslt libxslt-devel zlib-devel libjpeg-turbo libjpeg-turbo-devel libcurl-devel libicu-devel freetype freetype-devel

intl에 필요한 icu 설치
$ wget http://download.icu-project.org/files/icu4c/58.2/icu4c-58_2-src.tgz
$ tar xvzf icu4c-58_2-src.tgz
$ cd ./icu/source
$ ./configure --prefix=/opt/icu
$ make
$ sudo make install

라이브러리 설정

sudoedit/etc/ld.so.conf

/etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/local/lib
/usr/lib64
sudo ldconfig

php 설치
$ wget -O php-7.1.2.tar.gz http://jp2.php.net/get/php-7.1.2.tar.gz/from/this/mirror
$ tar xvzf php-7.1.2.tar.gz
$ cd php-7.1.2
$ ./configure \
--without-pear \
--with-gd \
--enable-sockets \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--enable-exif \
--enable-zip \
--with-zlib \
--with-zlib-dir=/usr \
--with-kerberos \
--with-openssl \
--with-mcrypt=/usr \
--enable-soap \
--enable-xmlreader \
--with-xsl \
--enable-ftp \
--enable-cgi \
--with-curl=/usr \
--with-tidy \
--with-xmlrpc \
--enable-sysvsem \
--enable-sysvshm \
--enable-shmop \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-pdo-sqlite \
--enable-pcntl \
--with-readline \
--enable-mbstring \
--disable-debug \
--enable-fpm \
--enable-bcmath \
--enable-phpdbg \
--enable-mbregex \
--enable-gd-native-ttf \
--with-freetype-dir=/usr/local/ \
--with-libdir=lib \
--enable-intl \
--with-icu-dir=/opt/icu \
--with-config-file-path=/etc/ \
--with-config-file-scan-dir=/etc/php.d
$ make
$ sudo make install
$ sudo cp ./php.ini-production /etc/php.ini
$ sudo cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
$ sudo chmod 755 /etc/init.d/php-fpm
$ sudo cp /usr/local/etc/php-fpm.d/www.conf.default /usr/local/etc/php-fpm.conf

php 설정



sudoedit/etc/php.ini

/etc/php.ini
date.timezone = Asia/Tokyo
[opcache]
zend_extension=opcache.so
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.max_wasted_percentage=5

PHP-FPM 설정



sudoedit/usr/local/etc/php-fpm.conf

/usr/local/etc/php-fpm.conf
listen = /var/run/php-fpm.sock
pm = ondemand
pm.max_children = 5
user = www
group = nginx
listen.owner = www
listen.group = nginx

composer


$ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
$ php -r "if (hash_file('SHA384', 'composer-setup.php') === '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
$ sudo /usr/local/bin/php composer-setup.php --install-dir=/usr/local/bin --filename=composer
$ php -r "unlink('composer-setup.php');"

New Relic



서버


$ sudo rpm -Uvh http://yum.newrelic.com/pub/newrelic/el5/x86_64/newrelic-repo-5-3.noarch.rpm
$ sudo yum -y install newrelic-sysmond
$ sudo nrsysmond-config --set license_key="ライセンスキー"
$ sudo /etc/init.d/newrelic-sysmond start

APM


$ sudo yum install newrelic-php5
$ sudo newrelic-install

대화형 모드에서 라이센스 키 등록

sudoedit/etc/php.d/newrelic.ini

/etc/php.d/newrelic.ini
newrelic.enabled=true
newrelic.appname="symfony3"
newrelic.framework="symfony2"
newrelic.transaction_tracer.detail=1

심포니3


$ sudo mkdir -p /var/www
$ sudo chown www.nginx /var/www
$ sudo su - www
$ cd /var/www
$ composer create-project symfony/framework-standard-edition hoge "3.2.*"
$ exit

php-fpm 시작


$ sudo /etc/init.d/php-fpm start

nginx 시작


$ sudo /etc/init.d/nginx start

New Relic SERVERS





New Relic APM





좋은 웹페이지 즐겨찾기