php_icon

php.ini の編集

標準で設定されているphpは、小さなメモリーサイズでも動作する。サーバーに余裕があるのであれば、ちょと変更してみよう。

WordPressとElementorを使うには

動作の重い WordPress さらに 重い Elementor を快適に動作させるには、ある程度のメモリーを php-fpm に設定する必要があるようです。

nginx で php を扱う場合、php-fpm で動作させるのだが、標準でインストールした php-fpm には、複数の php.ini が存在する。
そのありかは、

/etc/php/8.2/fpm/php.ini

である。

php.ini

				
					less /etc/php/8.2/fpm/php.ini


[PHP]

;;;;;;;;;;;;;;;;;;;
; About php.ini   ;
;;;;;;;;;;;;;;;;;;;
; PHP's initialization file, generally called php.ini, is responsible for
; configuring many of the aspects of PHP's behavior.

; PHP attempts to find and load this configuration from a number of locations.
; The following is a summary of its search order:
; 1. SAPI module specific location.
; 2. The PHPRC environment variable.
; 3. A number of predefined registry keys on Windows
; 4. Current working directory (except CLI)
; 5. The web server's directory (for SAPI modules), or directory of PHP

.............
				
			

まじか?

読むのに何時間かかるの?

「 ; space 」を省いて表示させると

				
					sed -e '/^\s*;/d' -e '/^\s*$/d' -e 's/^[ \t]*//;s/[ \t]*$//' /etc/php/8.2/fpm/php.ini

[PHP]
engine = On
short_open_tag = Off
precision = 14
output_buffering = 4096
zlib.output_compression = Off
implicit_flush = Off
unserialize_callback_func =
serialize_precision = -1
disable_functions =
disable_classes =
zend.enable_gc = On
zend.exception_ignore_args = On
zend.exception_string_param_max_len = 0
expose_php = Off
max_execution_time = 30
max_input_time = 60
memory_limit = 512M
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors = Off
display_startup_errors = Off
log_errors = On
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
variables_order = "GPCS"
request_order = "GP"
register_argc_argv = Off
auto_globals_jit = On
post_max_size = 256M
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"
default_charset = "UTF-8"
doc_root =
user_dir =
enable_dl = Off
file_uploads = On
upload_max_filesize = 128M
max_file_uploads = 120
allow_url_fopen = On
allow_url_include = Off
default_socket_timeout = 60
[CLI Server]
cli_server.color = On
[Date]
[filter]
[iconv]
[imap]
[intl]
[sqlite3]
[Pcre]
[Pdo]
[Pdo_mysql]
pdo_mysql.default_socket=
[Phar]
[mail function]
SMTP = localhost
smtp_port = 25
mail.add_x_header = Off
mail.mixed_lf_and_crlf = Off
[ODBC]
odbc.allow_persistent = On
odbc.check_persistent = On
odbc.max_persistent = -1
odbc.max_links = -1
odbc.defaultlrl = 4096
odbc.defaultbinmode = 1
[MySQLi]
mysqli.max_persistent = -1
mysqli.allow_persistent = On
mysqli.max_links = -1
mysqli.default_port = 3306
mysqli.default_socket =
mysqli.default_host =
mysqli.default_user =
mysqli.default_pw =
[mysqlnd]
mysqlnd.collect_statistics = On
mysqlnd.collect_memory_statistics = Off
[OCI8]
[PostgreSQL]
pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0
[bcmath]
bcmath.scale = 0
[browscap]
[Session]
session.save_handler = files
session.use_strict_mode = 0
session.use_cookies = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.cookie_samesite =
session.serialize_handler = php
session.gc_probability = 0
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.referer_check =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.sid_length = 26
session.trans_sid_tags = "a=href,area=href,frame=src,form="
session.sid_bits_per_character = 5
[Assertion]
zend.assertions = -1
[COM]
[mbstring]
[gd]
[exif]
[Tidy]
tidy.clean_output = Off
[soap]
soap.wsdl_cache_enabled=1
soap.wsdl_cache_dir="/tmp"
soap.wsdl_cache_ttl=86400
soap.wsdl_cache_limit = 5
[sysvshm]
[ldap]
ldap.max_links = -1
[dba]
[opcache]
[curl]
[openssl]
[ffi]
				
			
  • ^\s*;:コメント行を削除

  • ^\s*$:空行を削除

  • s/^[ \t]*//;s/[ \t]*$//:行頭・行末の空白を削除

これでも、設定は、長いけど、

[ kinsta WordPress 推奨]

memory_limit = 128M
post_max_size = 64M
upload_max_filesize = 32M

[ Elementorで必要なメモリー 体験上 ]

memory_limit = 512M
post_max_size = 256M
upload_max_filesize = 128M

[ マルチサイト Elementor だと }

memory_limit = 1024M
post_max_size = 512M
upload_max_filesize =  256M

※ 実際のハードウエアの使えるメモリーのサイズによっても最適は違うかも。最近のminiPCでも最低 16GBくらいあるので、大丈夫かな。

				
					vi /etc/php/8.2/fpm/php.ini


memory_limit = 1024M
post_max_size = 512M
upload_max_filesize =  256M
				
			

変更した設定を適用する

				
					systemctl restart php8.2-fpm.service
				
			

Related Posts

wordpress icon

WP-CLI インストール

WP-CLI は WordPress を管理するためのコマンドラインインターフェースで、プラグインのアップデートなどの実行ができる。