{"id":20,"date":"2023-08-30T15:22:13","date_gmt":"2023-08-30T15:22:13","guid":{"rendered":"https:\/\/cavin.rivaxstudio.com\/main\/?p=20"},"modified":"2023-08-30T15:22:13","modified_gmt":"2023-08-30T15:22:13","slug":"cai-dat-lamp-linux-apache-mysql-php-tren-centos","status":"publish","type":"post","link":"https:\/\/cuongnguyen.bat.io.vn\/index.php\/2023\/08\/30\/cai-dat-lamp-linux-apache-mysql-php-tren-centos\/","title":{"rendered":"C\u00e0i \u0111\u1eb7t LAMP (Linux, Apache, MySQL, PHP) tr\u00ean CentOS"},"content":{"rendered":"\n<p>\u0110\u1ea7u ti\u00ean b\u1ea1n c\u1ea7n chu\u1ea9n b\u1ecb m\u1ed9t server CentOS m\u1edbi tinh ch\u01b0a c\u00e0i g\u00ec c\u1ea3, \u1edf \u0111\u00e2y m\u00ecnh d\u00f9ng CentOS 6.4 64bit.<span id=\"more-1990\"><\/span><\/p>\n<h3>1. C\u00e0i \u0111\u1eb7t Apache<\/h3>\n<pre>yum install httpd<\/pre>\n<p>\u0110\u01b0\u1eddng d\u1eabn file c\u1ea5u h\u00ecnh Apache:<\/p>\n<pre>\/etc\/httpd\/conf\/httpd.conf<\/pre>\n<p><strong>Kh\u1edfi \u0111\u1ed9ng Apache<\/strong><\/p>\n<pre>service httpd start<\/pre>\n<p>Test th\u1eed b\u1eb1ng c\u00e1ch truy c\u1eadp v\u00e0o http:\/\/&lt;youraddress&gt; b\u1ea1n s\u1ebd th\u1ea5y th\u00f4ng b\u00e1o \u201cApache 2 Test Page\u201d<\/p>\n<p><em>L\u01b0u \u00fd<\/em>: n\u1ebfu s\u1eed d\u1ee5ng VPS \u1edf\u00a0<a href=\"https:\/\/hocvps.com\/vps\/vultr\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Vultr<\/a>, m\u1eb7c \u0111\u1ecbnh port 80 s\u1ebd b\u1ecb block, khi truy c\u1eadp v\u00e0o IP s\u1ebd b\u1ecb b\u00e1o l\u1ed7i\u00a0ERR_CONNECTION_REFUSED. B\u1ea1n h\u00e3y th\u1ef1c hi\u1ec7n th\u00eam thao t\u00e1c m\u1edf port nh\u01b0 sau:<\/p>\n<pre>\/sbin\/iptables -I INPUT -p tcp --dport 80 -j ACCEPT\n\/etc\/rc.d\/init.d\/iptables save<\/pre>\n<p><strong>C\u1ea5u h\u00ecnh\u00a0Apache Virtual Hosts<\/strong><\/p>\n<p>\u2013 T\u1ea1o m\u1ed9t file c\u1ea5u h\u00ecnh \u1edf th\u01b0 m\u1ee5c\u00a0<code>\/etc\/httpd\/conf.d<\/code>, \u0111\u1eb7t t\u00ean v\u00ed d\u1ee5\u00a0<code>example.com.conf<\/code>\u00a0(thay b\u1eb1ng domain c\u1ee7a b\u1ea1n)<\/p>\n<p>N\u1ed9i dung file\u00a0<code>\/etc\/httpd\/conf.d\/example.com.conf<\/code><\/p>\n<pre>NameVirtualHost *:80\n\n&lt;VirtualHost *:80&gt; \n     ServerAdmin webmaster@example.com\n     ServerName example.com\n     ServerAlias www.example.com\n     DocumentRoot \/var\/www\/example.com\/public_html\/\n     ErrorLog \/var\/www\/example.com\/logs\/error.log \n     CustomLog \/var\/www\/example.com\/logs\/access.log combined\n&lt;\/VirtualHost&gt;<\/pre>\n<p>\u2013 T\u1ea1o th\u01b0 m\u1ee5c cho website<\/p>\n<pre>mkdir -p \/var\/www\/example.com\/public_html\nmkdir \/var\/www\/example.com\/logs<\/pre>\n<p>\u2013 N\u1ebfu mu\u1ed1n th\u00eam website, b\u1ea1n ch\u1ec9 c\u1ea7n t\u1ea1o th\u00eam m\u1ed9t file .conf kh\u00e1c v\u00e0 reload l\u1ea1i Apache v\u1edbi l\u1ec7nh:\u00a0<code>service httpd reload<\/code><\/p>\n<h3>2. C\u00e0i \u0111\u1eb7t MySQL<\/h3>\n<pre>yum install mysql-server\nservice mysqld start<\/pre>\n<p>Ti\u1ebfn h\u00e0nh c\u00e0i \u0111\u1eb7t MySQL b\u1eb1ng l\u1ec7nh<\/p>\n<pre>\/usr\/bin\/mysql_secure_installation<\/pre>\n<p>Do m\u1edbi c\u00e0i \u0111\u1eb7t n\u00ean n\u1ebfu b\u1ecb h\u1ecfi password b\u1ea1n nh\u1ea5n Enter<\/p>\n<pre>Enter current password for root (enter for none): \nOK, successfully used password, moving on...<\/pre>\n<p>Sau \u0111\u00f3 c\u1ea7n \u0111\u1eb7t root password b\u1eb1ng c\u00e1ch ch\u1ecdn y<\/p>\n<p>Ti\u1ebfp theo b\u1ea1n s\u1ebd ph\u1ea3i tr\u1ea3 l\u1eddi m\u1ed9t lo\u1ea1t c\u00e1c c\u00e2u h\u1ecfi, t\u1ed1t nh\u1ea5t c\u1ee9 ch\u1ecdn y<\/p>\n<pre>By default, a MySQL installation has an anonymous user, allowing anyone\nto log into MySQL without having to have a user account created for\nthem.  This is intended only for testing, and to make the installation\ngo a bit smoother.  You should remove them before moving into a\nproduction environment.\n\nRemove anonymous users? [Y\/n] y                                            \n ... Success!\n\nNormally, root should only be allowed to connect from 'localhost'.  This\nensures that someone cannot guess at the root password from the network.\n\nDisallow root login remotely? [Y\/n] y\n... Success!\n\nBy default, MySQL comes with a database named 'test' that anyone can\naccess.  This is also intended only for testing, and should be removed\nbefore moving into a production environment.\n\nRemove test database and access to it? [Y\/n] y\n - Dropping test database...\n ... Success!\n - Removing privileges on test database...\n ... Success!\n\nReloading the privilege tables will ensure that all changes made so far\nwill take effect immediately.\n\nReload privilege tables now? [Y\/n] y\n ... Success!\n\nCleaning up...\n\nAll done!  If you've completed all of the above steps, your MySQL\ninstallation should now be secure.\n\nThanks for using MySQL!<\/pre>\n<h3>3. C\u00e0i \u0111\u1eb7t PHP<\/h3>\n<pre>yum install php php-mysql<\/pre>\n<p><strong>PHP Modules<\/strong><\/p>\n<p>PHP c\u00f3 r\u1ea5t nhi\u1ec1u th\u01b0 vi\u1ec7n module kh\u00e1c nhau, b\u1ea1n c\u00f3 th\u1ec3 xem b\u1eb1ng c\u00e1ch g\u00f5 l\u1ec7nh sau<\/p>\n<pre>yum search php-<\/pre>\n<pre>php-bcmath.x86_64 : A module for PHP applications for using the bcmath library\nphp-cli.x86_64 : Command-line interface for PHP\nphp-common.x86_64 : Common files for PHP\nphp-dba.x86_64 : A database abstraction layer module for PHP applications\nphp-devel.x86_64 : Files needed for building PHP extensions\nphp-embedded.x86_64 : PHP library for embedding in applications\nphp-enchant.x86_64 : Human Language and Character Encoding Support\nphp-gd.x86_64 : A module for PHP applications for using the gd graphics library\nphp-imap.x86_64 : A module for PHP applications that use IMAP<\/pre>\n<p>\u0110\u1ec3 c\u00e0i module n\u00e0o d\u00f9ng l\u1ec7nh sau<\/p>\n<pre>yum install <i>name of the module<\/i><\/pre>\n<h3>4. T\u1ef1 \u0111\u1ed9ng ch\u1ea1y service khi reboot<\/h3>\n<pre>chkconfig httpd on\nchkconfig mysqld on<\/pre>\n<p>Restart Apache<\/p>\n<pre>service httpd restart<\/pre>\n<p>OK v\u1eady l\u00e0 qu\u00e1 tr\u00ecnh c\u00e0i \u0111\u1eb7t\u00a0LAMP tr\u00ean CentOS v\u1eady l\u00e0 xong.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0110\u1ea7u ti\u00ean b\u1ea1n c\u1ea7n chu\u1ea9n b\u1ecb m\u1ed9t server CentOS m\u1edbi tinh ch\u01b0a c\u00e0i g\u00ec c\u1ea3, \u1edf \u0111\u00e2y m\u00ecnh d\u00f9ng CentOS 6.4 64bit. 1. C\u00e0i \u0111\u1eb7t Apache yum install httpd \u0110\u01b0\u1eddng d\u1eabn file c\u1ea5u h\u00ecnh Apache: \/etc\/httpd\/conf\/httpd.conf Kh\u1edfi \u0111\u1ed9ng Apache service httpd start Test th\u1eed b\u1eb1ng c\u00e1ch truy c\u1eadp v\u00e0o http:\/\/&lt;youraddress&gt; b\u1ea1n s\u1ebd th\u1ea5y th\u00f4ng b\u00e1o [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":896,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[24,29,33,34],"class_list":["post-20","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vps","tag-illustration","tag-lifestyle","tag-photoshop","tag-science"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/cuongnguyen.bat.io.vn\/index.php\/wp-json\/wp\/v2\/posts\/20","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cuongnguyen.bat.io.vn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cuongnguyen.bat.io.vn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cuongnguyen.bat.io.vn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cuongnguyen.bat.io.vn\/index.php\/wp-json\/wp\/v2\/comments?post=20"}],"version-history":[{"count":0,"href":"https:\/\/cuongnguyen.bat.io.vn\/index.php\/wp-json\/wp\/v2\/posts\/20\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cuongnguyen.bat.io.vn\/index.php\/wp-json\/wp\/v2\/media\/896"}],"wp:attachment":[{"href":"https:\/\/cuongnguyen.bat.io.vn\/index.php\/wp-json\/wp\/v2\/media?parent=20"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cuongnguyen.bat.io.vn\/index.php\/wp-json\/wp\/v2\/categories?post=20"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cuongnguyen.bat.io.vn\/index.php\/wp-json\/wp\/v2\/tags?post=20"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}