{"id":2186,"date":"2019-09-23T20:45:07","date_gmt":"2019-09-23T13:45:07","guid":{"rendered":"https:\/\/tino.vn\/?post_type=ht_kb&#038;p=2186"},"modified":"2019-09-23T20:45:07","modified_gmt":"2019-09-23T13:45:07","slug":"huong-dan-cai-dat-opcache-tren-direct-admin","status":"publish","type":"ht_kb","link":"https:\/\/tino.vn\/blog\/docs\/huong-dan-cai-dat-opcache-tren-direct-admin\/","title":{"rendered":"H\u01b0\u1edbng d\u1eabn c\u00e0i \u0111\u1eb7t OPcache tr\u00ean Direct Admin"},"content":{"rendered":"<p><strong>PHP OPcache l\u00e0 g\u00ec ?<\/strong> &#8211; C\u00f3 th\u1ec3 hi\u1ec3u \u0111\u01a1n gi\u1ea3n nh\u1ea5t <strong>&#8220;OPcache&#8221;<\/strong> l\u00e0 d\u1ea1ng cache n\u1ed9i d\u1ee5n <strong>Precompile code php<\/strong> tr\u00ean b\u1ed9 nh\u1edb chia s\u1ebb, tr\u01b0\u1edbc khi chuy\u1ec3n sang m\u00e3 m\u00e1y \u0111\u1ec3 th\u1ef1c thi ch\u01b0\u01a1ng tr\u00ecnh. \u0110i\u1ec1u n\u00e0y gi\u00fap vi\u1ec7c \u0111\u1ecdc code PHP \u0111\u01b0\u1ee3c gi\u1ea3m \u0111i t\u1eeb \u1ed5 c\u1ee9ng v\u00e0 compile m\u1ed7i l\u1ea7n c\u00f3 truy c\u1eadp v\u00e0o website v\u00e0 t\u1ec7p m\u00e3 ngu\u1ed3n \u0111\u01b0\u1ee3c th\u1ef1c thi. Ho\u1ea1t \u0111\u1ed9ng c\u1ee7a <strong>OPCache<\/strong> gi\u00fap cho ho\u1ea1t \u0111\u1ed9ng <strong>th\u1ef1c thi m\u00e3 ngu\u1ed3n PHP nhanh h\u01a1n nhi\u1ec1u khi c\u00f3 nhi\u1ec1u k\u1ebft n\u1ed1i \u0111\u1ed3ng th\u1eddi v\u00e0o website<\/strong>, gi\u00fap gi\u1ea3m t\u1ea3i cho CPU t\u1ed1t h\u01a1n v\u00e0 hi\u1ec7u n\u0103ng s\u1eed d\u1ee5ng s\u1ebd cao h\u01a1n.<\/p>\n<p><strong>L\u01b0u \u00fd : B\u1ea1n c\u00f3 th\u1ec3 c\u00e0i OPcache module cho PHP th\u00f4ng qua Custombuild 2.0, c\u00f3 th\u1ec3 theo d\u00f5i h\u01b0\u1edbng d\u1eabn sau :<\/strong><\/p>\n<h2 id=\"H\u01b0\u1edbng_d\u1eabn_n\u00e2ng_c\u1ea5p_l\u00ean_Custombuild_2.0_trong_DirectAdmin\">H\u01b0\u1edbng d\u1eabn n\u00e2ng c\u1ea5p l\u00ean Custombuild 2.0 trong DirectAdmin<\/h2>\n<p>DirectAdmin\u00a0\u0111i k\u00e8m v\u1edbi m\u1ed9t c\u00f4ng c\u1ee5 \u0111\u01b0\u1ee3c x\u00e2y d\u1ef1ng s\u1eb5n c\u00f3 t\u00ean l\u00e0 CustomBuild, cho ph\u00e9p b\u1ea1n c\u00e0i \u0111\u1eb7t, g\u1ee1 b\u1ecf ho\u1eb7c bi\u00ean d\u1ecbch l\u1ea1i c\u00e1c ch\u01b0\u01a1ng tr\u00ecnh. G\u1ea7n \u0111\u00e2y, \u0111\u00e3 c\u00f3 m\u1ed9t s\u1eeda \u0111\u1ed5i c\u1ee7a CustomBuild (th\u01b0\u1eddng \u0111\u01b0\u1ee3c vi\u1ebft t\u1eaft l\u00e0 CB) \u0111\u1ec3 phi\u00ean b\u1ea3n 2.0. Trong h\u01b0\u1edbng d\u1eabn n\u00e0y, b\u1ea1n s\u1ebd th\u1ea5y c\u00e1ch n\u00e2ng c\u1ea5p c\u00e0i \u0111\u1eb7t CustomBuild 1.1 ho\u1eb7c 1.2 l\u00ean 2.0.<\/p>\n<h3 id=\"B\u01b0\u1edbc_1:_C\u00e0i_\u0111\u1eb7t_l\u1ea1i_c\u00e1c_g\u00f3i_h\u1ed7_tr\u1ee3\">B\u01b0\u1edbc 1: C\u00e0i \u0111\u1eb7t l\u1ea1i c\u00e1c g\u00f3i h\u1ed7 tr\u1ee3<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">yum install wget gcc gcc-c++ flex bison make bind bind-libs bind-utils openssl openssl-devel perl quota libaio \\\r\nlibcom_err-devel libcurl-devel gd zlib-devel zip unzip libcap-devel cronie bzip2 cyrus-sasl-devel perl-ExtUtils-Embed \\\r\nautoconf automake libtool which patch mailx bzip2-devel lsof db4-devel psmisc net-tools systemd-devel libdb-devel perl-DBI xfsprogs rsyslog logrotate crontabs<\/pre>\n<h3 id=\"B\u01b0\u1edbc_2:_C\u1eadp_nh\u1eadt_CustomBuild\">B\u01b0\u1edbc 2: C\u1eadp nh\u1eadt CustomBuild<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">cd \/usr\/local\/directadmin\r\nmv custombuild custombuild_1.x\r\nwget -O custombuild.tar.gz http:\/\/files.directadmin.com\/services\/custombuild\/2.0\/custombuild.tar.gz\r\ntar xvzf custombuild.tar.gz\r\ncd custombuild\r\n.\/build<\/pre>\n<h3 id=\"B\u01b0\u1edbc_3:_Thay_\u0111\u1ed5i_c\u00e1c_t\u00f9y_ch\u1ecdn\">B\u01b0\u1edbc 3: Thay \u0111\u1ed5i c\u00e1c t\u00f9y ch\u1ecdn<\/h3>\n<p>Sau khi th\u1ef1c hi\u1ec7n .\/build, t\u1ec7p c\u1ea5u h\u00ecnh t\u00f9y ch\u1ecdn m\u1edbi \u0111\u00e3 \u0111\u01b0\u1ee3c t\u1ea1o. M\u1edf t\u1eadp tin n\u00e0y v\u00e0 th\u1ef1c hi\u1ec7n c\u00e1c thay \u0111\u1ed5i c\u1ea7n thi\u1ebft.<\/p>\n<p>Sau khi x\u00e1c nh\u1eadn thay \u0111\u1ed5i c\u1ee7a b\u1ea1n l\u00e0 ch\u00ednh x\u00e1c, c\u00e0i \u0111\u1eb7t ph\u1ea7n m\u1ec1m theo c\u1ea5u h\u00ecnh CustomBuild:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">.\/build all d\r\n.\/build rewrite_confs<\/pre>\n<h2 id=\"1_:_C\u00e0i_\u0111\u1eb7t_compile_module_OPCache_cho_PHP\">1 : C\u00e0i \u0111\u1eb7t compile module OPCache cho PHP<\/h2>\n<p>` Ki\u1ec3m tra phi\u00ean b\u1ea3n c\u1ee7a Custombuild hi\u1ec7n t\u1ea1i m\u00e0 b\u1ea1n \u0111ang s\u1eed d\u1ee5ng tr\u00ean Direct Admin. N\u1ebfu hi\u1ec3n th\u1ecb phi\u00ean b\u1ea3n PHP th\u00ec b\u1ea1n c\u00f3 th\u1ec3 ti\u1ebfp t\u1ee5c.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">[root@sv ~]# cd \/usr\/local\/directadmin\/custombuild\r\n[root@sv custombuild]# .\/build version\r\n2.0.0 (rev: 2168)<\/pre>\n<p>Thay \u0111\u1ed5i gi\u00e1 tr\u1ecb c\u00e0i \u0111\u1eb7t OPcache sang YES<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">[root@sv custombuild]# cd \/usr\/local\/directadmin\/custombuild\r\n[root@sv custombuild]# .\/build set opcache yes\r\nChanged opcache option from no to yes\r\n[root@sv custombuild]#<\/pre>\n<p>Compile OPache module b\u1eb1ng Custombuild 2.0<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">[root@sv custombuild]# .\/build opcache\r\nopCache is now installed for PHP 7.2.<\/pre>\n<h2 id=\"2_:_Ki\u1ec3m_tra_module_OPcache\">2 : Ki\u1ec3m tra module OPcache<\/h2>\n<p>B\u1ea1n c\u00f3 th\u1ec3 ki\u1ec3m tra b\u1eb1ng l\u1ec7nh sau, n\u1ebfu c\u00f3 ph\u1ea7n Zend OPcache vxxx l\u00e0 b\u1ea1n \u0111\u00e3 c\u00e0i th\u00e0nh c\u00f4ng.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">[root@sv custombuild]# php -v\r\nPHP Warning:  Module 'memcached' already loaded in Unknown on line 0\r\nPHP 7.2.20 (cli) (built: Jul 15 2019 14:38:57) ( NTS )\r\nCopyright (c) 1997-2018 The PHP Group\r\nZend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies\r\n    with Zend OPcache v7.2.20, Copyright (c) 1999-2018, by Zend Technologies\r\n[root@sv custombuild]#<\/pre>\n<p>Ho\u1eb7c n\u1ebfu b\u1ea1n mu\u1ed1n check th\u00f4ng tin qua Domain \u0111\u00e3 g\u1eafn v\u00e0o VPS, b\u1ea1n c\u0169ng c\u00f3 th\u1ec3 t\u1ea1o t\u1ec7p Code PHP phpinfo() r\u1ed3i truy c\u1eadp qua t\u00ean mi\u1ec1n \u0111\u1ec3 ki\u1ec3m tra, v\u00ed d\u1ee5\u00a0 nh\u01b0 m\u00ecnh c\u00f3 user Admin v\u1edbi t\u00ean mi\u1ec1n beeboobee.com th\u00ec m\u00ecnh s\u1ebd l\u00e0m nh\u01b0 n\u00e0y.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\"># cd \/home\/admin\/domains\/beeboobee.com\/public_html\r\n# vi phpinfo.php\r\n&lt;?php\r\nphpinfo();\r\n?&gt;<\/pre>\n<p>L\u01b0u l\u1ea1i v\u00e0 truy c\u1eadp https:\/\/beeboobee.com\/phpinfo.php \u0111\u1ec3 xem th\u00f4ng tin OPcache c\u00f3 th\u00f4ng tin c\u00e0i \u0111\u1eb7t ch\u01b0a. Nh\u01b0 v\u1eady l\u00e0 ho\u00e0n t\u1ea5t.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHP OPcache l\u00e0 g\u00ec ? &#8211; C\u00f3 th\u1ec3 hi\u1ec3u \u0111\u01a1n gi\u1ea3n nh\u1ea5t &#8220;OPcache&#8221; l\u00e0 d\u1ea1ng cache n\u1ed9i d\u1ee5n Precompile code php tr\u00ean b\u1ed9 nh\u1edb chia s\u1ebb, tr\u01b0\u1edbc khi chuy\u1ec3n sang m\u00e3 m\u00e1y \u0111\u1ec3 th\u1ef1c thi ch\u01b0\u01a1ng tr\u00ecnh. \u0110i\u1ec1u n\u00e0y gi\u00fap vi\u1ec7c \u0111\u1ecdc code PHP \u0111\u01b0\u1ee3c gi\u1ea3m \u0111i t\u1eeb \u1ed5 c\u1ee9ng v\u00e0 compile m\u1ed7i l\u1ea7n c\u00f3 [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":16424,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"tags":[],"ht_kb_category":[23],"class_list":["post-2186","ht_kb","type-ht_kb","status-publish","format-standard","has-post-thumbnail","hentry","ht_kb_category-control-panel-direct-admin"],"_links":{"self":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb\/2186","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb"}],"about":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/comments?post=2186"}],"version-history":[{"count":0,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb\/2186\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/media\/16424"}],"wp:attachment":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/media?parent=2186"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/tags?post=2186"},{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb_category?post=2186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}