{"id":2524,"date":"2019-10-09T14:05:50","date_gmt":"2019-10-09T07:05:50","guid":{"rendered":"https:\/\/tino.vn\/?post_type=ht_kb&#038;p=2524"},"modified":"2020-02-17T11:30:54","modified_gmt":"2020-02-17T04:30:54","slug":"huong-dan-cai-dat-lamp-stack-tren-centos-8","status":"publish","type":"ht_kb","link":"https:\/\/tino.vn\/blog\/docs\/huong-dan-cai-dat-lamp-stack-tren-centos-8\/","title":{"rendered":"H\u01b0\u1edbng d\u1eabn c\u00e0i \u0111\u1eb7t LAMP Stack tr\u00ean CentOS 8"},"content":{"rendered":"<div class=\"post-content\">\n<p>LAMP Stack l\u00e0 vi\u1ebft t\u1eaft c\u1ee7a Linux, Apache, MariaDB v\u00e0 PHP. N\u00f3 \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng r\u1ed9ng r\u00e3i nh\u1ea5t \u0111\u1ec3 l\u01b0u tr\u1eef c\u00e1c website, blog, vv ..<\/p>\n<p><span id=\"more-2453\"><\/span>D\u01b0\u1edbi \u0111\u00e2y l\u00e0 h\u01b0\u1edbng d\u1eabn nh\u1ecf v\u1ec1 c\u00e0i \u0111\u1eb7t v\u00e0 \u0111\u1ecbnh c\u1ea5u h\u00ecnh LAMP Stack v\u1edbi b\u1ea3n ph\u00e1t h\u00e0nh m\u1edbi nh\u1ea5t c\u1ee7a CentOS 8.<\/p>\n<h2 id=\"C\u00e0i_\u0111\u1eb7t_Apache_Web_Server\">C\u00e0i \u0111\u1eb7t Apache Web Server<\/h2>\n<ul>\n<li>T\u00ean g\u00f3i c\u1ee7a Apache l\u00e0\u00a0<strong>httpd<\/strong>. S\u1eed d\u1ee5ng tr\u00ecnh qu\u1ea3n l\u00fd g\u00f3i\u00a0<strong>yum<\/strong>\u00a0\u0111\u1ec3 c\u00e0i \u0111\u1eb7t<\/li>\n<\/ul>\n<pre class=\"wp-block-code\"><code># yum install -y httpd<\/code><\/pre>\n<ul>\n<li>Start d\u1ecbch v\u1ee5 Apache s\u1eed d\u1ee5ng l\u1ec7nh\u00a0<strong>systemctl<\/strong><\/li>\n<\/ul>\n<pre class=\"wp-block-code\"><code># systemctl start httpd<\/code><\/pre>\n<ul>\n<li>C\u1ea5u h\u00ecnh cho ph\u00e9p Apache \u0111\u01b0\u1ee3c kh\u1edfi \u0111\u1ed9ng c\u00f9ng h\u1ec7 th\u1ed1ng<\/li>\n<\/ul>\n<pre class=\"wp-block-code\"><code># systemctl enable httpd<\/code><\/pre>\n<ul>\n<li>Ki\u1ec3m tra tr\u1ea1ng th\u00e1i d\u1ecbch v\u1ee5 Apache s\u1eed d\u1ee5ng l\u1ec7nh d\u01b0\u1edbi<\/li>\n<\/ul>\n<pre class=\"wp-block-code\"><code># systemctl status httpd<\/code><\/pre>\n<ul>\n<li>Ki\u1ec3m tra port m\u1eb7c \u0111\u1ecbnh c\u1ee7a Apache<\/li>\n<\/ul>\n<pre class=\"wp-block-code\"><code># ss -plnt | grep httpd<\/code><\/pre>\n<p><strong>OUPUT<\/strong><\/p>\n<pre class=\"wp-block-code\"><code>LISTEN   0         128                       *:80                     *:*        users:((\"httpd\",pid=9339,fd=4),(\"httpd\",pid=9338,fd=4),(\"httpd\",pid=9337,fd=4),(\"httpd\",pid=9335,fd=4))<\/code><\/pre>\n<p>Theo \u0111\u00f3 port m\u1eb7c \u0111\u1ecbnh Apache s\u1eed d\u1ee5ng l\u00e0 port 80.<\/p>\n<ul>\n<li>C\u1ea5u h\u00ecnh firewall<\/li>\n<\/ul>\n<p>Theo m\u1eb7c \u0111\u1ecbnh, firewall ch\u1eb7n c\u00e1c k\u1ebft n\u1ed1i HTTP \u0111\u1ebfn t\u1eeb c\u00e1c m\u00e1y b\u00ean ngo\u00e0i.\u00a0V\u00ec v\u1eady, \u0111\u1ec3 ki\u1ec3m tra ho\u1eb7c s\u1eed d\u1ee5ng Apache web server, ch\u00fang ta c\u1ea7n c\u1ea5u h\u00ecnh firewall \u0111\u1ec3 cho ph\u00e9p c\u00e1c y\u00eau c\u1ea7u HTTP t\u1eeb c\u00e1c m\u00e1y b\u00ean ngo\u00e0i.<\/p>\n<pre class=\"wp-block-code\"><code># firewall-cmd --permanent --add-port=80\/tcp\r\n# firewall-cmd --reload<\/code><\/pre>\n<ul>\n<li>Ki\u1ec3m tra ho\u1ea1t \u0111\u1ed9ng c\u1ee7a Apache<\/li>\n<\/ul>\n<p>M\u1edf tr\u00ecnh duy\u1ec7t c\u1ee7a b\u1ea1n, nh\u1eadp v\u00e0o thanh t\u00ecm ki\u1ebfm \u0111\u1ecba ch\u1ec9 IP c\u1ee7a server. B\u1ea1n s\u1ebd nh\u1eadn \u0111\u01b0\u1ee3c k\u1ebft qu\u1ea3 l\u00e0 trang th\u1eed nghi\u1ec7m c\u1ee7a Apache. Trang th\u1eed nghi\u1ec7m n\u00e0y x\u00e1c nh\u1eadn r\u1eb1ng Apache \u0111ang ho\u1ea1t \u0111\u1ed9ng t\u1ed1t.<\/p>\n<figure class=\"wp-block-image\"><img decoding=\"async\" class=\"wp-image-2457\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2019\/10\/apache-1024x550.png\" sizes=\"(max-width: 1024px) 100vw, 1024px\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2019\/10\/apache-1024x550.png 1024w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2019\/10\/apache-300x161.png 300w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2019\/10\/apache-768x413.png 768w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2019\/10\/apache-676x363.png 676w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2019\/10\/apache.png 1297w\" alt=\"\" title=\"\"><\/figure>\n<p>Document root m\u1eb7c \u0111\u1ecbnh c\u1ee7a Apache l\u00e0 \/var\/www\/html, t\u1ec7p c\u1ea5u h\u00ecnh ch\u00ednh l\u00e0 \/etc\/httpd\/conf\/httpd.conf. C\u00e1c c\u1ea5u h\u00ecnh b\u1ed5 sung cho Apache web server \u0111\u01b0\u1ee3c l\u01b0u tr\u1eef trong th\u01b0 m\u1ee5c \/etc\/httpd\/conf.d<\/p>\n<h2 id=\"C\u00e0i_\u0111\u1eb7t_MariaDB\">C\u00e0i \u0111\u1eb7t MariaDB<\/h2>\n<p>H\u01b0\u1edbng d\u1eabn n\u00e0y s\u1ebd h\u01b0\u1edbng d\u1eabn b\u1ea1n c\u00e0i \u0111\u1eb7t MariaDB t\u1eeb kho l\u01b0u tr\u1eef c\u1ee7a h\u1ec7 \u0111i\u1ec1u h\u00e0nh. B\u1ea1n c\u0169ng c\u00f3 th\u1ec3 c\u00e0i \u0111\u1eb7t MariaDB t\u1eeb kho l\u01b0u tr\u1eef c\u1ee7a c\u1ed9ng \u0111\u1ed3ng MariaDB.<\/p>\n<p><em>READ: C\u00e0i \u0111\u1eb7t MariaDB 10.4.8 tr\u00ean CentOS 8<\/em><\/p>\n<ul>\n<li>S\u1eed d\u1ee5ng c\u00e2u l\u1ec7nh d\u01b0\u1edbi \u0111\u00e2y \u0111\u1ec3 c\u00e0i \u0111\u1eb7t<\/li>\n<\/ul>\n<pre class=\"wp-block-code\"><code># yum install -y mariadb mariadb-server<\/code><\/pre>\n<ul>\n<li>Start d\u1ecbch v\u1ee5 MariaDB Server v\u1edbi c\u00e2u l\u1ec7nh systemctl<\/li>\n<\/ul>\n<pre class=\"wp-block-code\"><code># systemctl start mariadb<\/code><\/pre>\n<ul>\n<li>C\u1ea5u h\u00ecnh cho ph\u00e9p d\u1ecbch v\u1ee5 MariaDB Server kh\u1edfi \u0111\u1ed9ng c\u00f9ng h\u1ec7 th\u1ed1ng<\/li>\n<\/ul>\n<pre class=\"wp-block-code\"><code># systemctl enable mariadb<\/code><\/pre>\n<ul>\n<li>Ki\u1ec3m tra tr\u1ea1ng th\u00e1i d\u1ecbch v\u1ee5 MariaDB Server<\/li>\n<\/ul>\n<pre class=\"wp-block-code\"><code># systemctl status mariadb<\/code><\/pre>\n<p><strong>OUTPUT<\/strong><\/p>\n<figure class=\"wp-block-image\"><img decoding=\"async\" class=\"wp-image-2458\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2019\/10\/mariadb-1024x290.png\" sizes=\"(max-width: 1024px) 100vw, 1024px\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2019\/10\/mariadb-1024x290.png 1024w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2019\/10\/mariadb-300x85.png 300w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2019\/10\/mariadb-768x218.png 768w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2019\/10\/mariadb-676x192.png 676w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2019\/10\/mariadb.png 1326w\" alt=\"\" title=\"\"><figcaption>Install LAMP Stack on CentOS 8 \u2013 MariaDB Server Status<\/figcaption><\/figure>\n<h3 id=\"Secure_MariaDB\">Secure MariaDB<\/h3>\n<p>C\u00e2u l\u1ec7nh s\u1eed d\u1ee5ng<\/p>\n<pre class=\"wp-block-code\"><code># mysql_secure_installation<\/code><\/pre>\n<p>L\u1ec7nh n\u00e0y cho ph\u00e9p b\u1ea1n c\u1ea3i thi\u1ec7n b\u1ea3o m\u1eadt c\u00e0i \u0111\u1eb7t MariaDB theo c\u00e1c c\u00e1ch sau:<\/p>\n<ul>\n<li>\u0110\u1eb7t m\u1eadt kh\u1ea9u cho\u00a0t\u00e0i kho\u1ea3n\u00a0root\u00a0.<\/li>\n<li>X\u00f3a\u00a0t\u00e0i kho\u1ea3n\u00a0root\u00a0c\u00f3 th\u1ec3 truy c\u1eadp t\u1eeb b\u00ean ngo\u00e0i localhost.<\/li>\n<li>X\u00f3a t\u00e0i kho\u1ea3n ng\u01b0\u1eddi d\u00f9ng \u1ea9n danh.<\/li>\n<li>X\u00f3a\u00a0c\u01a1 s\u1edf d\u1eef li\u1ec7u\u00a0test\u00a0(theo m\u1eb7c \u0111\u1ecbnh c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c truy c\u1eadp b\u1edfi t\u1ea5t c\u1ea3 ng\u01b0\u1eddi d\u00f9ng, ngay c\u1ea3 ng\u01b0\u1eddi d\u00f9ng \u1ea9n danh) v\u00e0 c\u00e1c \u0111\u1eb7c quy\u1ec1n cho ph\u00e9p m\u1ecdi ng\u01b0\u1eddi truy c\u1eadp c\u01a1 s\u1edf d\u1eef li\u1ec7u c\u00f3 t\u00ean b\u1eaft \u0111\u1ea7u b\u1eb1ng\u00a0test_.<\/li>\n<\/ul>\n<p><strong>OUTPUT<\/strong><\/p>\n<figure class=\"wp-block-image\"><img decoding=\"async\" class=\"wp-image-2459\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2019\/10\/Install-LAMP-Stack-on-RHEl-8-Secure-MariaDB-Installation-753x1024.jpg\" sizes=\"(max-width: 738px) 100vw, 738px\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2019\/10\/Install-LAMP-Stack-on-RHEl-8-Secure-MariaDB-Installation-753x1024.jpg 738w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2019\/10\/1_Install-LAMP-Stack-on-RHEl-8-Secure-MariaDB-Installation-753x1024-244x300.jpg 244w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2019\/10\/Install-LAMP-Stack-on-RHEl-8-Secure-MariaDB-Installation-753x1024-676x832.jpg 676w\" alt=\"\" title=\"\"><figcaption>Install LAMP Stack on CentOS 8 \u2013 Secure MariaDB Installation<\/figcaption><\/figure>\n<h2 id=\"C\u00e0i_\u0111\u1eb7t_PHP\">C\u00e0i \u0111\u1eb7t PHP<\/h2>\n<p>Theo m\u1eb7c \u0111\u1ecbnh Apahe Web Server ch\u1ec9 h\u1ed7 tr\u1ee3 ng\u00f4n ng\u1eef HTML. \u0110\u1ec3 c\u00f3 h\u1ed7 tr\u1ee3 PHP ch\u00fang ta s\u1ebd ph\u1ea3i c\u00e0i \u0111\u1eb7t g\u00f3i PHP.<\/p>\n<p>CentOS 8 m\u1eb7c \u0111\u1ecbn s\u1eed d\u1ee5ng PHP v7.2. Trong tr\u01b0\u1eddng h\u1ee3p b\u1ea1n mu\u1ed1n s\u1eed d\u1ee5ng PHP v7.3 b\u1ea1n c\u00f3 th\u1ec3 l\u00e0m theo h\u01b0\u1edbng d\u1eabn sau \u0111\u00e2y<\/p>\n<p><em>READ: H\u01b0\u1edbng d\u1eabn c\u00e0i \u0111\u1eb7t PHP v7.3 tr\u00ean CentOS 8<\/em><\/p>\n<ul>\n<li>C\u00e2u l\u1ec7nh c\u00e0i \u0111\u1eb7t PHP<\/li>\n<\/ul>\n<pre class=\"wp-block-code\"><code># yum install -y php php-mysqlnd<\/code><\/pre>\n<ul>\n<li>Restart l\u1ea1i d\u1ecbch v\u1ee5 Apache Web Server \u0111\u1ec3 x\u00e1c nh\u1eadn s\u1eed d\u1ee5ng PHP<\/li>\n<\/ul>\n<pre class=\"wp-block-code\"><code># systemctl restart httpd<\/code><\/pre>\n<h2 id=\"Test_LAMP_Stack\">Test LAMP Stack<\/h2>\n<p>\u0110\u1ec3 ki\u1ec3m tra PHP, t\u1ea1o m\u1ed9t t\u1ec7p info.php trong th\u01b0 m\u1ee5c m\u1eb7c \u0111\u1ecbnh c\u1ee7a Apache<\/p>\n<pre class=\"wp-block-code\"><code># echo \"&lt;?php phpinfo()?&gt;\" &gt; \/var\/www\/html\/info.php<\/code><\/pre>\n<p>Sau \u0111\u00f3 s\u1eed d\u1ee5ng tr\u00ecnh duy\u1ec7t c\u1ee7a b\u1ea1n nh\u1eadp v\u00e0o thanh t\u00ecm ki\u1ebfm \u0111\u1ecba ch\u1ec9 sau, thay th\u1ebf 192.168.136.100 b\u1eb1ng \u0111\u1ecba ch\u1ec9 IP Server c\u1ee7a b\u1ea1n.<\/p>\n<pre class=\"wp-block-code\"><code>http:\/\/192.168.136.100\/info.php<\/code><\/pre>\n<p>Khi \u0111\u00f3 trang c\u1ee7a b\u1ea1n s\u1ebd tr\u00f4ng nh\u01b0 n\u00e0y. B\u1ea1n c\u00f3 th\u1ebb nh\u00ecn th\u1ea5y th\u00f4ng tin v\u1ec1 phi\u00ean b\u1ea3n PHP \u0111\u00e3 \u0111\u01b0\u1ee3c c\u00e0i \u0111\u1eb7t, chi ti\u1ebft c\u00e1c ti\u1ec7n \u00edch m\u1edf r\u1ed9ng, vv..<\/p>\n<figure class=\"wp-block-image\"><img decoding=\"async\" class=\"wp-image-2460\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2019\/10\/php.png\" sizes=\"(max-width: 955px) 100vw, 955px\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2019\/10\/php.png 955w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2019\/10\/1_php-300x220.png 300w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2019\/10\/1_php-768x562.png 768w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2019\/10\/php-676x495.png 676w\" alt=\"\" title=\"\"><\/figure>\n<p>Cu\u1ed9n xu\u1ed1ng tr\u00ecnh duy\u1ec7t \u0111\u1ec3 ki\u1ec3m tra h\u1ed7 tr\u1ee3 cho\u00a0MariaDB\u00a0.\u00a0B\u1ea1n s\u1ebd nh\u1eadn \u0111\u01b0\u1ee3c m\u00e0n h\u00ecnh nh\u01b0 d\u01b0\u1edbi \u0111\u00e2y.<\/p>\n<figure class=\"wp-block-image\"><img decoding=\"async\" class=\"wp-image-2461\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2019\/10\/php2.png\" sizes=\"(max-width: 1000px) 100vw, 1000px\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2019\/10\/php2.png 1000w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2019\/10\/1_php2-300x203.png 300w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2019\/10\/1_php2-768x519.png 768w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2019\/10\/php2-676x457.png 676w\" alt=\"\" title=\"\"><\/figure>\n<p>Ch\u00fac c\u00e1c b\u1ea1n th\u00e0nh c\u00f4ng!<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>LAMP Stack l\u00e0 vi\u1ebft t\u1eaft c\u1ee7a Linux, Apache, MariaDB v\u00e0 PHP. N\u00f3 \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng r\u1ed9ng r\u00e3i nh\u1ea5t \u0111\u1ec3 l\u01b0u tr\u1eef c\u00e1c website, blog, vv .. D\u01b0\u1edbi \u0111\u00e2y l\u00e0 h\u01b0\u1edbng d\u1eabn nh\u1ecf v\u1ec1 c\u00e0i \u0111\u1eb7t v\u00e0 \u0111\u1ecbnh c\u1ea5u h\u00ecnh LAMP Stack v\u1edbi b\u1ea3n ph\u00e1t h\u00e0nh m\u1edbi nh\u1ea5t c\u1ee7a CentOS 8. C\u00e0i \u0111\u1eb7t Apache Web Server [&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":[29,17],"class_list":["post-2524","ht_kb","type-ht_kb","status-publish","format-standard","has-post-thumbnail","hentry","ht_kb_category-cau-hoi-thuong-gap","ht_kb_category-huong-dan-ve-cloud-vps"],"_links":{"self":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb\/2524","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=2524"}],"version-history":[{"count":0,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb\/2524\/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=2524"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/tags?post=2524"},{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb_category?post=2524"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}