0
0

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 1 year has passed since last update.

Apache+php-fpmの構築

Posted at

環境

・CentOS7.3
・Apache2.4
・php5.4

Apahceのインストール


# yum install httpd

phpのインストール


# yum install php

php-fpmのインストール


# yum install php-fpm

php-fpmの設定

/etc/php-fpm.d/www.confの下記を変更

# vi /etc/php-fpm.d/www.conf

listen = /var/run/php-fpm/php-fpm.sock ← 好み

listen.owner = apache
listen.group = apache
listen.mode = 0660

#phpの設定

下記コマンドでphp.iniの場所を確認

# php --ini

(出力例)
Loaded Configure File: /etc/php.ini

php.iniの下記を変更

# vi /etc/php.ini

default_charset = UTF-8            ← 使用したいもの
date.timezone = Asia/Tokyo         ← 実態に合わせて
mbstring.language = Japanese       ← 実態に合わせて
mbstring.internal_encoding = UTF-8 ← 使用したいもの
mbstring.http_outpu = UTF-8        ← 使用したいもの

Apacheの設定

/etc/httpd/conf/httpd.confに下記を追加


# vi /etc/httpd/conf/httpd.conf

<Directory "/var/www/php-fpm/">                                            ← php-fpmで動かしたいプログラムの格納場所
  <FileMatch (.+\.php)$>                                                   ← 拡張子に合わせて
    SetHandler "proxy:unix:/var/run/php-fpm/php-fpm.sock|fcgi://localhost" ← /etc/php-fpm.d/www.confに設定したもの
  </FileMatch>
</Directory>

php-fpmの起動

systemctl start php-fpm

apacheの起動

systemctl start httpd

困った時には

php-fpmのログを確認する
私は下記のような設定にしている

/etc/php-fpm.d/www.conf
php_admin_value[error_log] = /var/log/php-fpm/www-error.log
php_admin_value[log_errors] = on

/etc/php-fpm.conf
log_level = error

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?