{"id":2811,"date":"2019-10-21T15:11:26","date_gmt":"2019-10-21T08:11:26","guid":{"rendered":"https:\/\/tino.vn\/?post_type=ht_kb&#038;p=2811"},"modified":"2019-10-24T15:59:51","modified_gmt":"2019-10-24T08:59:51","slug":"__trashed","status":"publish","type":"ht_kb","link":"https:\/\/tino.vn\/blog\/docs\/__trashed\/","title":{"rendered":"H\u01b0\u1edbng d\u1eabn c\u00e0i \u0111\u1eb7t LAMP tr\u00ean CentOS 7"},"content":{"rendered":"<div class=\"wp-block-media-text alignwide\">\n<figure class=\"wp-block-media-text__media\"><\/figure>\n<div class=\"wp-block-media-text__content\">\n<p>LAMP l\u00e0 m\u1ed9t h\u1ec7 th\u1ed1ng c\u00e1c ph\u1ea7n m\u1ec1m \u0111\u1ec3 t\u1ea1o d\u1ef1ng m\u00f4i tr\u01b0\u1eddng m\u00e1y ch\u1ee7 web \u0111\u01b0\u1ee3c vi\u1ebft b\u1eb1ng PHP. B\u00e0i vi\u1ebft n\u00e0y s\u1ebd gi\u00fap b\u1ea1n t\u00ecm hi\u1ec3u c\u0169ng nh\u01b0 l\u00e0 h\u01b0\u1edbng d\u1eabn c\u00e0i \u0111\u1eb7t LAMP tr\u00ean m\u00e1y CentOS.<\/p>\n<\/div>\n<\/div>\n<h2 id=\"1._T\u1ed5ng_quan\">1. T\u1ed5ng quan<\/h2>\n<p>LAMP l\u00e0 m\u1ed9t h\u1ec7 th\u1ed1ng c\u00e1c ph\u1ea7n m\u1ec1m \u0111\u1ec3 t\u1ea1o d\u1ef1ng m\u00f4i tr\u01b0\u1eddng m\u00e1y ch\u1ee7 web c\u00f3 kh\u1ea3 n\u0103ng ch\u1ee9a v\u00e0 ph\u00e2n ph\u1ed1i c\u00e1c trang web \u0111\u1ed9ng \u0111\u01b0\u1ee3c vi\u1ebft b\u1eb1ng PHP.<\/p>\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2019\/10\/lamp01.png\" alt=\"image\" title=\"\"><\/figure>\n<p>LAMP bao g\u1ed3m:<\/p>\n<ul>\n<li>Linux: l\u00e0 h\u1ec7 \u0111i\u1ec1u h\u00e0nh, c\u0169ng l\u00e0 ph\u1ea7n m\u1ec1m d\u00f9ng \u0111\u1ec3 \u0111i\u1ec1u ph\u1ed1i v\u00e0 qu\u1ea3n l\u00ed c\u00e1c t\u00e0i nguy\u00ean c\u1ee7a h\u1ec7 th\u1ed1ng.<\/li>\n<li>Apache: l\u00e0 ph\u1ea7n m\u1ec1m m\u00e1y ch\u1ee7 web, c\u00f3 th\u1ec3 th\u1ef1c hi\u1ec7n c\u00e1c request \u0111\u01b0\u1ee3c g\u1ecdi t\u1edbi m\u00e1y ch\u1ee7 th\u00f4ng qua giao th\u1ee9c HTTP<\/li>\n<li>Mysql\/Mariadb: l\u00e0 h\u1ec7 qu\u1ea3n tr\u1ecb c\u01a1 s\u1edf d\u1eef li\u1ec7u gi\u00fap l\u01b0u tr\u1eef v\u00e0 truy xu\u1ea5t d\u1eef li\u1ec7u. C\u1ea3 2 h\u1ec7 qu\u1ea3n tr\u1ecb c\u01a1 s\u1edf d\u1eef li\u1ec7u n\u00e0y \u0111\u1ec1u kh\u00e1 t\u01b0\u01a1ng \u0111\u1ed3ng v\u1edbi nhau (c\u00f3 th\u1ec3 t\u00ecm hi\u1ec3u th\u00eam t\u1ea1i\u00a0\u0111\u00e2y)<\/li>\n<li>PHP: L\u00e0 ng\u00f4n ng\u1eef l\u1eadp tr\u00ecnh cho k\u1ecbch b\u1ea3n ho\u1ea1t \u0111\u1ed9ng c\u1ee7a m\u00e1y ch\u1ee7.<\/li>\n<\/ul>\n<h2 id=\"\"><\/h2>\n<h2 id=\"2._Ti\u1ebfn_h\u00e0nh_c\u00e0i_\u0111\u1eb7t\">2. Ti\u1ebfn h\u00e0nh c\u00e0i \u0111\u1eb7t<\/h2>\n<h3 id=\"\"><\/h3>\n<h3 id=\"2.1._C\u00e0i_\u0111\u1eb7t_linux\">2.1. C\u00e0i \u0111\u1eb7t linux<\/h3>\n<p>\u0110\u1ed1i v\u1edbi vi\u1ec7c c\u00e0i \u0111\u1eb7t h\u1ec7 \u0111i\u1ec1u h\u00e0nh, b\u1ea1n c\u00f3 th\u1ec3 hi\u1ec7n tr\u00ean nhi\u1ec1u b\u1ea3n ph\u00e2n ph\u1ed1i kh\u00e1c nhau c\u1ee7a linux nh\u01b0 Debian, Redhat, Ubuntu\u2026 Trong b\u00e0i n\u00e0y, m\u00ecnh s\u1eed d\u1ee5ng h\u1ec7 \u0111i\u1ec1u h\u00e0nh CentOS 7.<\/p>\n<h3 id=\"\"><\/h3>\n<h3 id=\"2.2._C\u00e0i_\u0111\u1eb7t_Apache\">2.2. C\u00e0i \u0111\u1eb7t Apache<\/h3>\n<p>\u0110\u1ec3 c\u00e0i \u0111\u1eb7t, tr\u00ean c\u1eeda s\u1ed5 terminal g\u00f5 l\u1ec7nh:<\/p>\n<pre class=\"wp-block-code\"><code>sudo yum -y install httpd\r\n<\/code><\/pre>\n<p>C\u00e0i xong, ti\u1ebfn h\u00e0nh kh\u1edfi \u0111\u1ed9ng l\u1ea1i service:<\/p>\n<pre class=\"wp-block-code\"><code>systemctl start httpd\r\nsystemctl enable httpd\r\n<\/code><\/pre>\n<p>B\u1ea1n c\u00f3 th\u1ec3 check l\u1ea1i trang th\u00e1i ho\u1ea1t \u0111\u1ed9ng c\u1ee7a service b\u1eb1ng c\u00e1ch g\u00f5:<\/p>\n<pre class=\"wp-block-code\"><code>systemctl status httpd\r\n<\/code><\/pre>\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2019\/10\/lamp02.png\" alt=\"image\" title=\"\"><\/figure>\n<p>B\u1ea1n c\u0169ng c\u00f3 th\u1ec3 ki\u1ec3m tra tr\u1ea1ng th\u00e1i tr\u00ean tr\u00ecnh duy\u1ec7t b\u1eb1ng c\u00e1ch g\u00f5 tr\u00ean thanh url \u0111\u1ecba ch\u1ec9 sau:<\/p>\n<pre class=\"wp-block-code\"><code>&lt;\u0111\u1ecba ch\u1ec9 ip server&gt;\r\n<\/code><\/pre>\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2019\/10\/lamp03.png\" alt=\"image\" title=\"\"><\/figure>\n<p>N\u1ebfu b\u1ea1n s\u1eed d\u1ee5ng h\u1ec7 \u0111i\u1ec1u h\u00e0nh tr\u00ean m\u00e1y \u1ea3o, b\u1ea1n c\u00f3 th\u1ec3 t\u1eaft firewall \u0111\u1ec3 c\u00f3 th\u1ec3 truy c\u1eadp tr\u00ean browser c\u1ee7a m\u00e1y th\u1ef1c:<\/p>\n<pre class=\"wp-block-code\"><code>systemctl stop firewalld\r\n<\/code><\/pre>\n<p>Sau \u0111\u00f3, g\u00f5 \u0111\u1ecba ch\u1ec9 ip m\u00e1y \u1ea3o tr\u00ean thanh url c\u0169ng s\u1ebd cho ra k\u1ebft qu\u1ea3 t\u01b0\u01a1ng t\u1ef1.<\/p>\n<h3 id=\"\"><\/h3>\n<h3 id=\"2.3._C\u00e0i_\u0111\u1eb7t_h\u1ec7_qu\u1ea3n_l\u00ed_c\u01a1_s\u1edf_d\u1eef_li\u1ec7u\">2.3. C\u00e0i \u0111\u1eb7t h\u1ec7 qu\u1ea3n l\u00ed c\u01a1 s\u1edf d\u1eef li\u1ec7u<\/h3>\n<p>Tr\u00ean th\u1ef1c t\u1ebf v\u1edbi LAMP, b\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng mysql ho\u1eb7c mariadb \u0111\u1ec1u \u0111\u01b0\u1ee3c, b\u00e0i n\u00e0y m\u00ecnh s\u1ebd h\u01b0\u1edbng d\u1eabn v\u1edbi mariadb.<\/p>\n<p>Tr\u00ean c\u1eeda s\u1ed5 terminal, ti\u1ebfn h\u00e0nh c\u00e0i \u0111\u1eb7t mariadb:<\/p>\n<pre class=\"wp-block-code\"><code>sudo yum -y install mariadb mariadb-server\r\n<\/code><\/pre>\n<p>Ti\u1ebfn h\u00e0nh kh\u1edfi \u0111\u1ed9ng mariadb service:<\/p>\n<pre class=\"wp-block-code\"><code>systemctl start mariadb\r\n<\/code><\/pre>\n<p>C\u00e0i l\u1ea1i m\u1eadt kh\u1ea9u m\u1eadt kh\u1ea9u cho quy\u1ec1n root c\u1ee7a c\u01a1 s\u1edf d\u1eef li\u1ec7u:<\/p>\n<pre class=\"wp-block-code\"><code>sudo mysql_secure_installation\r\n<\/code><\/pre>\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2019\/10\/lamp04.png\" alt=\"image\" title=\"\"><\/figure>\n<p>\u1ede b\u01b0\u1edbc n\u00e0y ta s\u1ebd thi\u1ebft l\u1eadp m\u1ed9t s\u1ed1 c\u1ea5u h\u00ecnh nh\u01b0 sau:<\/p>\n<pre class=\"wp-block-code\"><code>Enter currret password for root (enter for none):\r\n<\/code><\/pre>\n<p>B\u01b0\u1edbc n\u00e0y y\u00eau c\u1ea7u b\u1ea1n nh\u1eadp m\u1eadt kh\u1ea9u g\u1ea7n \u0111\u00e2y cho root. N\u1ebfu b\u1ea1n m\u1edbi c\u00e0i l\u1ea7n \u0111\u1ea7u th\u00ec nh\u1ea5n Enter \u0111\u1ec3 b\u1ecf qua.<\/p>\n<pre class=\"wp-block-code\"><code>Set root password? (Y\/n)\r\n<\/code><\/pre>\n<p>N\u1ebfu b\u1ea1n c\u00e0i l\u1ea7n \u0111\u1ea7u, h\u1ec7 th\u1ed1ng s\u1ebd h\u1ecfi b\u1ea1n mu\u1ed1n c\u00e0i password cho quy\u1ec1n root kh\u00f4ng. B\u1ea1n g\u00f5\u00a0<strong>Y -&gt; Enter<\/strong>, sau \u0111\u00f3 nh\u1eadp m\u1eadt kh\u1ea9u v\u00e0 x\u00e1c th\u1ef1c m\u1eadt kh\u1ea9u.<\/p>\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2019\/10\/lamp05.png\" alt=\"image\" title=\"\"><\/figure>\n<p>V\u1edbi nh\u1eefng m\u00e1y m\u1edbi c\u00e0i mariadb l\u1ea7n \u0111\u1ea7u, h\u1ec7 th\u1ed1ng y\u00eau c\u1ea7u th\u00eam m\u1ed9t s\u1ed1 thi\u1ebft l\u1eadp nh\u01b0 sau:<\/p>\n<ul>\n<li>Xo\u00e1 b\u1ecf c\u00e1c user kh\u00e1c.<\/li>\n<li>Kh\u00f4ng cho ph\u00e9p root \u0111\u0103ng nh\u1eadp t\u1eeb xa.<\/li>\n<li>Xo\u00e1 b\u1ecf databases test.<\/li>\n<li>Kh\u1edfi ch\u1ea1y l\u1ea1i b\u1ea3ng Privilege (b\u1ea3ng ph\u00e2n quy\u1ec1n).<\/li>\n<\/ul>\n<p>B\u1ea1n ch\u1ec9 c\u1ea7n g\u00f5\u00a0<strong>Y<\/strong>\u00a0cho nh\u1eefng y\u00eau c\u1ea7u \u0111\u00f3.<\/p>\n<p>Sau khi thi\u1ebft l\u1eadp xong, k\u00edch ho\u1ea1t mariadb \u0111\u1ec3 kh\u1edfi \u0111\u1ed9ng c\u00f9ng h\u1ec7 th\u1ed1ng:<\/p>\n<pre class=\"wp-block-code\"><code>systemctl enable mariadb\r\n<\/code><\/pre>\n<h3 id=\"\"><\/h3>\n<h3 id=\"2.3._C\u00e0i_\u0111\u1eb7t_php\">2.3. C\u00e0i \u0111\u1eb7t php<\/h3>\n<p>Phi\u00ean b\u1ea3n c\u00f3 s\u1eb5n trong repo c\u1ee7a CentOS \u0111ang l\u00e0 5.4. Phi\u00ean b\u1ea3n n\u00e0y kh\u00e1 c\u0169 v\u00e0 s\u1ebd khi\u1ebfn b\u1ea1n g\u1eb7p m\u1ed9t s\u1ed1 v\u1ea5n \u0111\u1ec1 x\u1ea3y ra khi ti\u1ebfn h\u00e0nh c\u00e0i \u0111\u1eb7t wordpress. V\u00ec v\u1eady b\u1ea1n c\u1ea7n ph\u1ea3i c\u00e0i \u0111\u1eb7t phi\u00ean b\u1ea3n 7x \u0111\u1ec3 kh\u1eafc ph\u1ee5c. B\u1ea1n c\u1ea7n ti\u1ebfn h\u00e0nh th\u00eam kho v\u00e0o Remi CentOS:<\/p>\n<pre class=\"wp-block-code\"><code>rpm -Uvh http:\/\/rpms.remirepo.net\/enterprise\/remi-release-7.rpm\r\n<\/code><\/pre>\n<p>C\u00e0i yum-utils v\u00ec ch\u00fang ta c\u1ea7n ti\u1ec7n \u00edch yum-config-manager \u0111\u1ec3 c\u00e0i \u0111\u1eb7t:<\/p>\n<pre class=\"wp-block-code\"><code>yum -y install yum-utils\r\n<\/code><\/pre>\n<p>Ti\u1ebfn h\u00e0nh c\u00e0i \u0111\u1eb7t php. \u1ede \u0111\u00e2y ta c\u1ea7n l\u01b0u \u00fd v\u1ec1 phi\u00ean b\u1ea3n c\u00e0i \u0111\u1eb7t nh\u01b0 sau:<\/p>\n<ul>\n<li>B\u1ea3n 7.0:<\/li>\n<\/ul>\n<pre class=\"wp-block-code\"><code>yum-config-manager --enable remi-php70\r\nyum -y install php php-opcache php-mysql\r\n<\/code><\/pre>\n<ul>\n<li>B\u1ea3n 7.1:<\/li>\n<\/ul>\n<pre class=\"wp-block-code\"><code>yum-config-manager --enable remi-php71\r\nyum -y install php php-opcache php-mysql\r\n<\/code><\/pre>\n<ul>\n<li>B\u1ea3n 7.2:<\/li>\n<\/ul>\n<pre class=\"wp-block-code\"><code>yum-config-manager --enable remi-php72\r\nyum -y install php php-opcache php-mysql\r\n<\/code><\/pre>\n<ul>\n<li>B\u1ea3n 7.3:<\/li>\n<\/ul>\n<pre class=\"wp-block-code\"><code>yum-config-manager --enable remi-php73\r\nyum -y install php php-opcache php-mysql\r\n<\/code><\/pre>\n<p>Trong b\u00e0i n\u00e0y, m\u00ecnh c\u00e0i phi\u00ean b\u1ea3n 7.2<\/p>\n<p>Sau khi c\u00e0i \u0111\u1eb7t xong, th\u1ef1c hi\u1ec7n restart l\u1ea1i apache:<\/p>\n<pre class=\"wp-block-code\"><code>systemctl restart httpd\r\n<\/code><\/pre>\n<p>Ti\u1ebfn h\u00e0nh ki\u1ec3m tra k\u1ebft qu\u1ea3. Ta th\u00eam file sau:<\/p>\n<pre class=\"wp-block-code\"><code>echo \"&lt;?php phpinfo();?&gt;\" &gt; \/var\/www\/html\/info.php\r\n<\/code><\/pre>\n<p>Sau \u0111\u00f3 restart l\u1ea1i apache:<\/p>\n<pre class=\"wp-block-code\"><code>systemctl restart httpd\r\n<\/code><\/pre>\n<p>V\u00e0o tr\u00ecnh duy\u1ec7t, g\u00f5 tr\u00ean thanh url \u0111\u1ecba ch\u1ec9 sau:<\/p>\n<pre class=\"wp-block-code\"><code>&lt;\u0111\u1ecba ch\u1ec9 ip&gt;\/info.php\r\n<\/code><\/pre>\n<p>Khi m\u00e0n h\u00ecnh n\u00e0y xu\u1ea5t hi\u1ec7n, b\u1ea1n \u0111\u00e3 th\u1ef1c hi\u1ec7n th\u00e0nh c\u00f4ng!<\/p>\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2019\/10\/lamp06.png\" alt=\"image\" title=\"\"><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>LAMP l\u00e0 m\u1ed9t h\u1ec7 th\u1ed1ng c\u00e1c ph\u1ea7n m\u1ec1m \u0111\u1ec3 t\u1ea1o d\u1ef1ng m\u00f4i tr\u01b0\u1eddng m\u00e1y ch\u1ee7 web \u0111\u01b0\u1ee3c vi\u1ebft b\u1eb1ng PHP. B\u00e0i vi\u1ebft n\u00e0y s\u1ebd gi\u00fap b\u1ea1n t\u00ecm hi\u1ec3u c\u0169ng nh\u01b0 l\u00e0 h\u01b0\u1edbng d\u1eabn c\u00e0i \u0111\u1eb7t LAMP tr\u00ean m\u00e1y CentOS. 1. T\u1ed5ng quan LAMP l\u00e0 m\u1ed9t h\u1ec7 th\u1ed1ng c\u00e1c ph\u1ea7n m\u1ec1m \u0111\u1ec3 t\u1ea1o d\u1ef1ng m\u00f4i tr\u01b0\u1eddng [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":16424,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"tags":[],"ht_kb_category":[17],"class_list":["post-2811","ht_kb","type-ht_kb","status-publish","format-standard","has-post-thumbnail","hentry","ht_kb_category-huong-dan-ve-cloud-vps"],"_links":{"self":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb\/2811","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\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/comments?post=2811"}],"version-history":[{"count":0,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb\/2811\/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=2811"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/tags?post=2811"},{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb_category?post=2811"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}