提供:EELの自由帳
移動先: 案内検索

ヘルプ:PHP7.2の初期設定(Zend OPcache+APCu)(CentOS7)

メインページ > ヘルプ:目次 > ヘルプ:自宅サーバー構築(CentOS7)  > PHP7.2の初期設定(Zend OPcache+APCu)(CentOS7)

  • 導入部で記載されていますが、設定を再度記載しておきます。
  • phpの最低限の設定と、PHP/OPcache/APCuのメモリ使用量を設定します。
  • MediaWiki 1.30.0 動作しました。
  • WordPress 4.9.5 動作しました。

php.ini の設定

[root@host4 ~]# vi /etc/php.ini

# [PHP]ブロック
expose_php = Off ← レスポンスヘッダにPHPのバージョンを表示させない
error_reporting = E_ALL ← 全てのログを出力させる
display_errors = Off ← ブラウザでのエラー表示させない
log_errors = On ← エラーをログに残す
log_errors_max_len = 4096 ← エラーログの長さを設定、念のため大きめに
error_log = "/var/log/php_errors.log" ← エラーログ出力先
default_charset = "UTF-8" ← 文字エンコーディング

#[Date]ブロック
date.timezone = "Asia/Tokyo" ← タイムゾーン

#[mbstring]ブロック
mbstring.language = Japanese ← デフォルト言語
mbstring.internal_encoding = UTF-8 ← 内部文字エンコーディング
mbstring.http_input = auto ← HTTP入力文字エンコーディングのデフォルト
mbstring.detect_order = auto ← 文字エンコーディング検出順序のデフォルト

APCu のメモリ使用量

[root@host4 ~]# vi /etc/php.d/40-apcu.ini
## APCuの最大メモリ使用量を32MB → 16MB
;apc.shm_size=32M

apc.shm_size=16M

OPcache メモリ使用量

[root@host4 ~]# vi /etc/php.d/10-opcache.ini

; The OPcache shared memory storage size.
## OPcacheの最大メモリ使用量を128MB → 256MB
opcache.memory_consumption=256

Webサーバー再起動

[root@host4 ~]# systemctl restart httpd

Webサーバーステータス

[root@host4 ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since 土 2018-04-07 08:47:34 JST; 10s ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 20724 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=0/SUCCESS)
 Main PID: 20730 (httpd)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
   CGroup: /system.slice/httpd.service
           tq20730 /usr/sbin/httpd -DFOREGROUND
           tq20731 /usr/sbin/httpd -DFOREGROUND
           tq20732 /usr/sbin/httpd -DFOREGROUND
           tq20733 /usr/sbin/httpd -DFOREGROUND
           tq20734 /usr/sbin/httpd -DFOREGROUND
           mq20735 /usr/sbin/httpd -DFOREGROUND

 4月 07 08:47:34 host4.awajp.com systemd[1]: Starting The Apache HTTP Server...
 4月 07 08:47:34 host4.awajp.com systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.