8
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PHP-FPM

Last updated at Posted at 2014-11-11

インストール

phpenv install で以下にインストールされる。

# ll /usr/local/phpenv/versions/5.5.18/sbin/
total 37416
-rwxr-xr-x 1 root root 38310629 Nov 11 04:18 php-fpm

設定ファイル作成

php-fpm.conf

  • 以下の内容で /usr/local/phpenv/versions/5.5.18/etc/php-fpm.conf を作成
include=etc/fpm.d/*.conf

[global]
pid = run/php-fpm/php-fpm.pid
error_log = log/php-fpm/error.log

www.conf

  • 以下の内容で /usr/local/phpenv/versions/5.5.18/etc/fpm.d/www.conf を作成
[www]
listen = var/run/php-fpm/php-fpm.sock
listen.allowed_clients = 127.0.0.1
listen.owner = nginx
listen.group = nginx
listen.mode = 0660

user = nginx
group = nginx

pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35

access.log = var/log/php-fpm/$pool.access.log
access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"

slowlog = var/log/php-fpm/www-slow.log

php_value[session.save_handler] = files
php_value[session.save_path] = var/lib/php/session

シンボリックリンク作成

  • /var/log/php-fpm
# cd /usr/local/phpenv/versions/5.5.18/var/log
# mkdir -p /var/log/php-fpm
# ln -s /var/log/php-fpm php-fpm
  • /var/run/php-fpm
# cd /usr/local/phpenv/versions/5.5.18/var/run
# mkdir -p /var/run/php-fpm
# chown nginx:nginx /var/run/php-fpm
# ln -s /var/run/php-fpm php-fpm
  • /var/lib/php/session
# cd /usr/local/phpenv/versions/5.5.18/var/lib/php
# mkdir -p /var/lib/php/session
# ln -s /var/lib/php/session session

起動スクリプト作成

  • phpenv install 時に /tmp にダウンロードされたソースからコピー。
# cd /tmp/php-build/source/5.5.18/sapi/fpm/
# cp -ip init.d.php-fpm /etc/init.d/php-fpm
  • 若干修正
(変更前)
php_fpm_PID=${prefix}/var/run/php-fpm.pid

(変更後)
php_fpm_PID=${prefix}/var/run/php-fpm/php-fpm.pid
  • パーミッション設定
# chmod 755 /etc/init.d/php-fpm

起動

  • サービス登録
# chkconfig --add php-fpm

# chkconfig --list php-fpm
php-fpm         0:off   1:off   2:on    3:on    4:on    5:on    6:off
  • サービス起動
# service php-fpm start
  • 自動起動設定
# chkconfig php-fpm on
8
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?