{"id":2334,"date":"2019-08-19T23:43:58","date_gmt":"2019-08-19T14:43:58","guid":{"rendered":"https:\/\/test.ji0vwl.net\/?p=2334"},"modified":"2019-11-05T20:44:31","modified_gmt":"2019-11-05T11:44:31","slug":"php7%e3%81%abapcu%e3%82%92%e5%b0%8e%e5%85%a5%e3%81%97web%e3%82%b5%e3%82%a4%e3%83%88%e3%82%92%e9%ab%98%e9%80%9f%e5%8c%96","status":"publish","type":"post","link":"https:\/\/ji0vwl.net\/index.php\/2019\/08\/19\/2334\/","title":{"rendered":"PHP7\u306bAPCu\u3092\u5c0e\u5165\u3057Web\u30b5\u30a4\u30c8\u3092\u9ad8\u901f\u5316"},"content":{"rendered":"<p>\u5f53Blog\u30b5\u30a4\u30c8\u306f<a href=\"https:\/\/www.php.net\/manual\/ja\/intro-whatis.php\">PHP<\/a>\u30d9\u30fc\u30b9\u306e<a href=\"https:\/\/ja.wordpress.org\">WordPress<\/a>\u3067\u52d5\u4f5c\u3057\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001html\u306e\u9759\u7684\u30da\u30fc\u30b8\u306b\u6bd4\u3079\u308b\u3068\u975e\u5e38\u306b\u52d5\u4f5c\u304c\u9045\u3044\u3067\u3059\u3002<\/p>\n<p>\u4eca\u56de\u3001PHP7\u306b<a href=\"https:\/\/www.php.net\/manual\/ja\/book.apcu.php\">APCu<\/a>\u3092\u5c0e\u5165\uff08\u30bd\u30fc\u30b9\u30d3\u30eb\u30c9\uff09\u3059\u308b\u3053\u3068\u30673\u500d\u8fd1\u304f\u9ad8\u901f\u5316\u306b\u6210\u529f\u3057\u307e\u3057\u305f\u306e\u3067\u6295\u7a3f\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<p>\u79c1\u306eWeb\u30b5\u30fc\u30d0\u30fc\uff08CentOS 7 + Apache 2.4 + PHP 7\uff09\u306f\u3001yum\u3067\u306f\u306a\u304f\u30bd\u30fc\u30b9\u304b\u3089\u30d3\u30eb\u30c9\u3057\u3066\u52d5\u4f5c\u3055\u305b\u3066\u3044\u308b\u306e\u3067\u3001\u5df7\u306b\u6ea2\u308c\u308b\u9ad8\u901f\u5316\u624b\u6bb5\u3092\u7c21\u5358\u306b\u5c0e\u5165\u3067\u304d\u305a\u306b\u3044\u307e\u3057\u305f\u304c\u3001\u305f\u307e\u305f\u307e\u898b\u304b\u3051\u305f<a href=\"https:\/\/www.riscascape.net\/archives\/4461\">\u3053\u306e\u30b5\u30a4\u30c8<\/a>\u3092\u53c2\u8003\u306b\u3055\u305b\u3066\u3044\u305f\u3060\u304d\u7121\u4e8b\u6539\u5584\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u3002\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3057\u305f\uff01<\/p>\n<h3>\u307e\u305a\u7d50\u679c\u304b\u3089<\/h3>\n<p>Server Software: Apache\/2.4.41<br \/>\nServer Hostname: ji0vwl.net<br \/>\nServer Port: 443<br \/>\nSSL\/TLS Protocol: TLSv1.2,ECDHE-RSA-AES128-GCM-SHA256,4096,128<br \/>\nTLS Server Name: ji0vwl.net<\/p>\n<table>\n<tbody>\n<tr>\n<td><\/td>\n<td>\u672a\u5bfe\u7b56<\/td>\n<td>APCu\u3092\u5c0e\u5165<\/td>\n<\/tr>\n<tr>\n<td>Requests per second:<\/td>\n<td><strong>3.33 [#\/sec]<\/strong><\/td>\n<td><strong>10.30 [#\/sec] (x3.1) <\/strong><\/td>\n<\/tr>\n<tr>\n<td>Connect (min):<\/td>\n<td>43 [ms]<\/td>\n<td>46 [ms]<\/td>\n<\/tr>\n<tr>\n<td>Processing (min):<\/td>\n<td>372 [ms]<\/td>\n<td>137 [ms] \u00a0(\u00f72.7)<\/td>\n<\/tr>\n<tr>\n<td>Waiting (min):<\/td>\n<td>361 [ms]<\/td>\n<td>124 [ms] \u00a0 (\u00f72.9)<\/td>\n<\/tr>\n<tr>\n<td>Total (min):<\/td>\n<td>415 [ms]<\/td>\n<td>183 [ms]<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u63a5\u7d9a\u6642\u9593\u306f\u5909\u308f\u308a\u307e\u305b\u3093\u304c\u3001\u51e6\u7406\u6642\u9593\u3068\u5f85\u3061\u6642\u9593\u304c3\u5206\u306e1\u307b\u3069\u306b\u77ed\u7e2e\u3055\u308c\u3001\u3053\u306eWeb\u30b5\u30fc\u30d0\u30fc\u3067\u634c\u3051\u308b<strong>\u79d2\u9593\u30ea\u30af\u30a8\u30b9\u30c8\u6570\u304c\u7d043\u500d<\/strong>\u3068\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>&nbsp;<\/p>\n<h3>\u5c0e\u5165<\/h3>\n<p>\u57fa\u672c\u7684\u306b\u306f<a href=\"https:\/\/test.ji0vwl.net\/index.php\/2019\/08\/16\/2306\/\">\u3053\u306e\u30da\u30fc\u30b8<\/a>\u306e\u901a\u308a\u306a\u306e\u3067\u3059\u304c\u3001PHP\u306e\u30d3\u30eb\u30c9\u306e\u3068\u3053\u308d\u3060\u3051\u9055\u3044\u307e\u3059\u3002Apache 2.4.41\u3068OpennSSL 1.1.1c\u306f\u3059\u3067\u306b\u5c0e\u5165\u6e08\u307f\u306a\u306e\u3067\u3001PHP\u3060\u3051\u518d\u30d3\u30eb\u30c9\u3059\u308c\u3070OK\u3067\u3059\u3002<\/p>\n<h4>5. PHP 7.3.8 \u3092 \/usr\/local\/php7.3.8 \u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<\/h4>\n<h5>5.1. <a href=\"https:\/\/secure.php.net\/downloads.php\">PHP<\/a>\u3068<a href=\"https:\/\/pecl.php.net\/package\/APCu\">APCu<\/a>\/<a href=\"https:\/\/pecl.php.net\/package\/apcu_bc\">APCu_bc<\/a>\u306e\u6e96\u5099<\/h5>\n<p>\u305d\u308c\u305e\u308c\u6700\u65b0\u306e\u30bd\u30fc\u30b9\u3092wget\u3067\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u304d\u307e\u3059\u3002apcu\u3068apcu_bc\u306f\u3001PHP\u306e\u30bd\u30fc\u30b9\u5c55\u958b\u5f8c\u00a0php-7.3.8\/ext\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5185\u306b\u5c55\u958b\u3057\u3001\u305d\u308c\u305e\u308c\u30ea\u30cd\u30fc\u30e0\u3057\u307e\u3059\u3002<\/p>\n<pre>$ sudo -i\r\n# cd \/usr\/local\/src\r\n# yum -y install libxml2-devel systemd-devel libpng-devel libwebp libwebp-devel libwebp-tools\r\n# wget http:\/\/jp2.php.net\/get\/php-7.3.8.tar.gz\/from\/this\/mirror -O \/usr\/local\/src\/php-7.3.8.tar.gz\r\n# tar -xvzf php-7.3.8.tar.gz\r\n# cd php-7.3.8\/ext\r\n# wget -q https:\/\/pecl.php.net\/get\/apcu-5.1.17.tgz\r\n# wget -q https:\/\/pecl.php.net\/get\/apcu_bc-1.0.5.tgz\r\n# tar zxvf apcu-5.1.17.tgz\r\n# tar zxvf apcu_bc-1.0.5.tgz\r\n# mv apcu-5.1.17 apcu\r\n# mv apcu_bc-1.0.5 apcu_bc\r\n# cd ..\r\n# rm -rf configure\r\n# .\/buildconf --force\r\nForcing buildconf\r\nRemoving configure caches\r\nbuildconf: checking installation...\r\nbuildconf: autoconf version 2.69 (ok)\r\nrebuilding aclocal.m4\r\nrebuilding configure\r\nrebuilding main\/php_config.h.in\r\n<\/pre>\n<p>&nbsp;<\/p>\n<h5>5.2.\u00a0PHP 7.3.8 \u3092 \/usr\/local\/php7.3.8 \u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<\/h5>\n<p>&#8211;with-apxs2=[dir]\u3067PHP\u3068Apache\u3092\u3001&#8211;with-openssl=[dir]\u3067PHP\u3068OpenSSL\u3092\u3001&#8211;with-mysql-sock=[dir]\u3067PHP\u3068mySQL\u3092\u7d50\u3073\u3064\u3051\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306f&#8211;enale-apc\u3068&#8211;enable-apcu\u3092\u8ffd\u52a0\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre># .\/configure \\\r\n--prefix=\/usr\/local\/php7.3.8 \\\r\n--with-apxs2=\/usr\/local\/httpd4\/bin\/apxs \\\r\n--with-openssl=\/usr\/local\/ssl \\\r\n--with-mysql-sock=\/var\/lib\/mysql\/mysql.sock \\\r\n--with-mysqli \\\r\n--with-pdo-mysql \\\r\n--enable-mbstring \\\r\n--with-freetype-dir=\/usr \\\r\n--with-png-dir=\/usr \\\r\n--with-jpeg-dir=\/usr \\\r\n--with-webp-dir=\/usr \\\r\n--with-gd=shared \\\r\n--with-zlib \\\r\n--with-fpm-systemd \\\r\n--with-fpm-user=apache \\\r\n--with-fpm-group=apache \\\r\n--enable-gd-jis-conv \\\r\n--enable-fpm \\\r\n--enable-apc \\\r\n--enable-apcu\r\n# make\r\n# make install\r\n# libtool --finish \/usr\/local\/src\/php-7.3.8\/libs<\/pre>\n<p>&nbsp;<\/p>\n<h5>5.3. php.ini\u3092\u4f5c\u6210\u3059\u308b<\/h5>\n<p>\u3044\u307e\u307e\u3067php.ini\u3092\u4f5c\u3089\u305a\u306b\u7d20\u306e\u72b6\u614b\u3067\u3084\u3063\u3066\u304d\u307e\u3057\u305f\u304c\u3001APCu\u3092\u6709\u52b9\u306b\u3059\u308b\u305f\u3081\u306b\u4f5c\u6210\u3057\u307e\u3059\u3002Opcache\u3082\u6709\u52b9\u306b\u3057\u3066\u304a\u304d\u307e\u3059\u3002php.ini\u3092\u4f5c\u308b\u5834\u6240\u3067\u3059\u304c\u3001\u79c1\u306e\u5834\u5408PHP\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u914d\u4e0b\u306elib\/\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5185\u3067\u3057\u305f\u3002\u5206\u304b\u3089\u306a\u3044\u5834\u5408\u306f<a href=\"https:\/\/qiita.com\/ritukiii\/items\/624eb475b85e28613a70\">\u3053\u3061\u3089<\/a>\u3002<\/p>\n<pre># cd \/usr\/local\/php7.3.8\/lib\r\n# vim php.ini<\/pre>\n<pre>max_execution_time=600\r\nmemory_limit=128M\r\nerror_reporting=0\r\ndisplay_errors=0\r\nlog_errors=0\r\nuser_ini.filename=\r\nrealpath_cache_size=2M\r\ncgi.check_shebang_line=0\r\ndate.timezone = \"Asia\/Tokyo\"\r\nzend_extension=opcache.so\r\n\r\n[opcache]\r\nopcache.enable=1\r\n;opcache.enable_cli=0\r\nopcache.memory_consumption=64\r\nopcache.interned_strings_buffer=8\r\nopcache.max_accelerated_files=4000\r\n;opcache.max_wasted_percentage=5\r\n;opcache.use_cwd=1\r\n;opcache.validate_timestamps=1\r\nopcache.revalidate_freq=2\r\nopcache.revalidate_path=0\r\n;opcache.save_comments=1\r\nopcache.fast_shutdown=1\r\n;opcache.enable_file_override=0\r\nopcache.optimization_level=0xffffffff\r\n;opcache.inherited_hack=1\r\n;opcache.dups_fix=0\r\n;opcache.blacklist_filename=\/etc\/php.d\/opcache*.blacklist\r\n;opcache.max_file_size=0\r\n;opcache.consistency_checks=0\r\n;opcache.force_restart_timeout=180\r\n;opcache.error_log=\r\n;opcache.log_verbosity_level=1\r\n;opcache.preferred_memory_model=\r\n;opcache.protect_memory=0\r\n;opcache.restrict_api=\r\n;opcache.file_cache=\r\n;opcache.file_cache_only=0\r\n;\r\napc.enabled = 1\r\napc.enable_cli=1\r\napc.shm_size=40M\r\napc.ttl=3600\r\napc.gc_ttl=3600\r\n;apc.mmap_file_mask=\/tmp\/apc.XXXXXX\r\n;\r\n;;mbstring\r\nmbstring.language = Japanese\r\nmbstring.internal_encoding = UTF-8\r\nmbstring.http_input = UTF-8\r\nmbstring.http_output = pass\r\nmbstring.detect_order = UTF-8,SJIS,EUC-JP,JIS,ASCII<\/pre>\n<p>&nbsp;<\/p>\n<p>:wq\u3067\u4fdd\u5b58\u3057\u305f\u3089\u3001\u6700\u5f8c\u306bhttpd4\uff08\u79c1\u306eWeb\u30b5\u30fc\u30d0\u30fc\u306e\u540d\u524d\uff09\u3092\u518d\u8d77\u52d5\u3057\u3066\u5b8c\u4e86\uff01<\/p>\n<pre># systemctl restart httpd4<\/pre>\n<h3><\/h3>\n<p>&nbsp;<\/p>\n<h3>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u78ba\u8a8d\u65b9\u6cd5<\/h3>\n<p>Mac\u306e\u30b3\u30f3\u30bd\u30fc\u30eb\u304b\u3089\u3001<a href=\"https:\/\/qiita.com\/wifecooky\/items\/1fc87bcdf6fdcf80637e\">ab\uff08Apache Bench\uff09<\/a>\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3002\u7c21\u5358\u3067\u3059\u306d\u3002<\/p>\n<p>$ ab -n [\u7dcf\u30ea\u30af\u30a8\u30b9\u30c8\u6570] -c [\u540c\u6642\u30ea\u30af\u30a8\u30b9\u30c8\u6570] [URL]<\/p>\n<pre>$ ab -n 10 -c 10 https:\/\/test.ji0vwl.net\/\r\n<\/pre>\n<pre>This is ApacheBench, Version 2.3 &lt;$Revision: 1826891 $&gt;\r\nCopyright 1996 Adam Twiss, Zeus Technology Ltd, http:\/\/www.zeustech.net\/\r\nLicensed to The Apache Software Foundation, http:\/\/www.apache.org\/\r\n\r\nBenchmarking ji0vwl.net (be patient).....done\r\n\r\n\r\nServer Software:        Apache\/2.4.41\r\nServer Hostname:        ji0vwl.net\r\nServer Port:            443\r\nSSL\/TLS Protocol:       TLSv1.2,ECDHE-RSA-AES128-GCM-SHA256,4096,128\r\nTLS Server Name:        ji0vwl.net\r\n\r\nDocument Path:          \/\r\nDocument Length:        26601 bytes\r\n\r\nConcurrency Level:      10\r\nTime taken for tests:   0.971 seconds\r\nComplete requests:      10\r\nFailed requests:        0\r\nTotal transferred:      271380 bytes\r\nHTML transferred:       266010 bytes\r\nRequests per second:    10.30 [#\/sec] (mean)\r\nTime per request:       971.152 [ms] (mean)\r\nTime per request:       97.115 [ms] (mean, across all concurrent requests)\r\nTransfer rate:          272.89 [Kbytes\/sec] received\r\n\r\nConnection Times (ms)\r\n              min  mean[+\/-sd] median   max\r\nConnect:       46  183 212.3     89     586\r\nProcessing:   137  410 165.4    466     578\r\nWaiting:      124  398 165.5    453     566\r\nTotal:        183  593 171.0    628     799\r\n\r\nPercentage of the requests served within a certain time (ms)\r\n  50%    628\r\n  66%    652\r\n  75%    664\r\n  80%    777\r\n  90%    799\r\n  95%    799\r\n  98%    799\r\n  99%    799\r\n 100%    799 (longest request)\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>t3a.nano\u3068\u3044\u3046\u8ca7\u5f31\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3067\u3082 Google\u306e<a href=\"https:\/\/developers.google.com\/speed\/pagespeed\/insights\/?hl=JA&amp;url=https%3A%2F%2Ftest.ji0vwl.net\">PageSpeed Insights<\/a>\u3067\u3082\u9ad8\u5f97\u70b9\u304c\u51fa\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002\u30d1\u30bd\u30b3\u30f3\u306e\u65b9\u306f\u7518\u3044\u306e\u3067\u6bd4\u8f03\u7684\u7c21\u5358\u306b100\u70b9\u8fd1\u304f\u304c\u51fa\u307e\u3059\u304c\u3001\u30e2\u30d0\u30a4\u30eb\u306e\u65b9\u306f\u304b\u306a\u308a\u8f9b\u3081\u3067\u3001\u3044\u307e\u307e\u3067\u826f\u304f\u3066\u308280\u70b9\u4ee3\u5f8c\u534a\u3067\u3057\u305f\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2360\" src=\"https:\/\/test.ji0vwl.net\/wp-content\/uploads\/2019\/08\/dad7102955dfab79ac1c3ae7e5b669de-1.jpg\" alt=\"\" width=\"796\" height=\"800\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f53Blog\u30b5\u30a4\u30c8\u306fPHP\u30d9\u30fc\u30b9\u306eWordPress\u3067\u52d5\u4f5c\u3057\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001html\u306e\u9759\u7684\u30da\u30fc\u30b8\u306b\u6bd4\u3079\u308b\u3068\u975e\u5e38\u306b\u52d5\u4f5c\u304c\u9045\u3044\u3067\u3059\u3002 \u4eca\u56de\u3001PHP7\u306bAPCu\u3092\u5c0e\u5165\uff08\u30bd\u30fc\u30b9\u30d3\u30eb\u30c9\uff09\u3059\u308b\u3053\u3068\u30673\u500d\u8fd1\u304f\u9ad8\u901f\u5316\u306b\u6210\u529f\u3057\u307e\u3057\u305f\u306e\u3067\u6295\u7a3f &hellip; <a href=\"https:\/\/ji0vwl.net\/index.php\/2019\/08\/19\/2334\/\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">PHP7\u306bAPCu\u3092\u5c0e\u5165\u3057Web\u30b5\u30a4\u30c8\u3092\u9ad8\u901f\u5316<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2334","post","type-post","status-publish","format-standard","hentry","category-server"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/ji0vwl.net\/index.php\/wp-json\/wp\/v2\/posts\/2334","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ji0vwl.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ji0vwl.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ji0vwl.net\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ji0vwl.net\/index.php\/wp-json\/wp\/v2\/comments?post=2334"}],"version-history":[{"count":0,"href":"https:\/\/ji0vwl.net\/index.php\/wp-json\/wp\/v2\/posts\/2334\/revisions"}],"wp:attachment":[{"href":"https:\/\/ji0vwl.net\/index.php\/wp-json\/wp\/v2\/media?parent=2334"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ji0vwl.net\/index.php\/wp-json\/wp\/v2\/categories?post=2334"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ji0vwl.net\/index.php\/wp-json\/wp\/v2\/tags?post=2334"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}