{"id":220,"date":"2008-02-01T12:09:00","date_gmt":"2008-02-01T12:09:00","guid":{"rendered":"https:\/\/blog.chaiyakul.com\/?p=220"},"modified":"2025-05-18T12:10:20","modified_gmt":"2025-05-18T12:10:20","slug":"subdomain-centos-apache","status":"publish","type":"post","link":"https:\/\/blog.chaiyakul.com\/index.php\/2008\/02\/01\/subdomain-centos-apache\/","title":{"rendered":"\u0e01\u0e32\u0e23\u0e17\u0e33 Subdomain \u0e43\u0e19 CentOS (\u0e43\u0e0a\u0e49 Apache \u0e40\u0e1b\u0e47\u0e19 Web Server)"},"content":{"rendered":"\n<p>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07: \u0e15\u0e49\u0e2d\u0e07\u0e01\u0e32\u0e23\u0e43\u0e2b\u0e49 <code>sub.example.com<\/code> \u0e43\u0e0a\u0e49\u0e07\u0e32\u0e19\u0e44\u0e14\u0e49<\/p>\n\n\n\n<p>1. \u0e15\u0e31\u0e49\u0e07\u0e04\u0e48\u0e32\u0e23\u0e30\u0e1a\u0e1a DNS<\/p>\n\n\n\n<p>\u0e44\u0e1b\u0e22\u0e31\u0e07 <strong>DNS Provider<\/strong> \u0e02\u0e2d\u0e07 domain <code>example.com<\/code> \u0e41\u0e25\u0e49\u0e27\u0e40\u0e1e\u0e34\u0e48\u0e21 <strong>A Record<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Name<\/strong>: <code>sub<\/code><\/li>\n\n\n\n<li><strong>Type<\/strong>: <code>A<\/code><\/li>\n\n\n\n<li><strong>Value<\/strong>: IP Address \u0e02\u0e2d\u0e07 CentOS Server<\/li>\n\n\n\n<li><strong>TTL<\/strong>: \u0e15\u0e32\u0e21\u0e15\u0e49\u0e2d\u0e07\u0e01\u0e32\u0e23 (\u0e40\u0e0a\u0e48\u0e19 3600)<\/li>\n<\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\u0e16\u0e49\u0e32 DNS \u0e15\u0e31\u0e49\u0e07\u0e44\u0e27\u0e49\u0e16\u0e39\u0e01\u0e15\u0e49\u0e2d\u0e07\u0e41\u0e25\u0e49\u0e27 \u0e43\u0e2b\u0e49\u0e02\u0e49\u0e32\u0e21\u0e02\u0e31\u0e49\u0e19\u0e15\u0e2d\u0e19\u0e19\u0e35\u0e49<\/p>\n<\/blockquote>\n\n\n\n<p>2. \u0e2a\u0e23\u0e49\u0e32\u0e07 Directory \u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a Subdomain<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo mkdir -p \/var\/www\/sub.example.com\/public_html\nsudo chown -R $USER:$USER \/var\/www\/sub.example.com\/public_html\n<\/pre><\/div>\n\n\n<p>\u0e2a\u0e23\u0e49\u0e32\u0e07\u0e44\u0e1f\u0e25\u0e4c index:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\necho &quot;&amp;lt;h1&gt;Hello from subdomain&amp;lt;\/h1&gt;&quot; &gt; \/var\/www\/sub.example.com\/public_html\/index.html\n<\/pre><\/div>\n\n\n<p>3. \u0e2a\u0e23\u0e49\u0e32\u0e07 Virtual Host \u0e43\u0e19 Apache<\/p>\n\n\n\n<p>\u0e2a\u0e23\u0e49\u0e32\u0e07\u0e44\u0e1f\u0e25\u0e4c config:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo nano \/etc\/httpd\/conf.d\/sub.example.com.conf\n<\/pre><\/div>\n\n\n<p>\u0e43\u0e2a\u0e48\u0e40\u0e19\u0e37\u0e49\u0e2d\u0e2b\u0e32\u0e1b\u0e23\u0e30\u0e21\u0e32\u0e13\u0e19\u0e35\u0e49:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;VirtualHost *:80&gt;\n    ServerName sub.example.com\n    DocumentRoot \/var\/www\/sub.example.com\/public_html\n\n    ErrorLog \/var\/log\/httpd\/sub.example.com_error.log\n    CustomLog \/var\/log\/httpd\/sub.example.com_access.log combined\n&amp;lt;\/VirtualHost&gt;\n<\/pre><\/div>\n\n\n<p>4. \u0e15\u0e23\u0e27\u0e08\u0e2a\u0e2d\u0e1a Config \u0e41\u0e25\u0e30 Restart Apache<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo apachectl configtest\nsudo systemctl restart httpd\n<\/pre><\/div>\n\n\n<p>5. \u0e17\u0e14\u0e2a\u0e2d\u0e1a<\/p>\n\n\n\n<p>\u0e40\u0e1b\u0e34\u0e14\u0e40\u0e1a\u0e23\u0e32\u0e27\u0e4c\u0e40\u0e0b\u0e2d\u0e23\u0e4c\u0e41\u0e25\u0e49\u0e27\u0e40\u0e02\u0e49\u0e32\u0e17\u0e35\u0e48:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nhttp:\/\/sub.example.com\n<\/pre><\/div>\n\n\n<p>\u0e2b\u0e21\u0e32\u0e22\u0e40\u0e2b\u0e15\u0e38:<\/p>\n\n\n\n<p>\u0e15\u0e49\u0e2d\u0e07\u0e41\u0e19\u0e48\u0e43\u0e08\u0e27\u0e48\u0e32 <strong>firewall (firewalld)<\/strong> \u0e40\u0e1b\u0e34\u0e14\u0e1e\u0e2d\u0e23\u0e4c\u0e15 80\/443<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07: \u0e15\u0e49\u0e2d\u0e07\u0e01\u0e32\u0e23\u0e43\u0e2b\u0e49 sub.example.com \u0e43\u0e0a\u0e49\u0e07\u0e32\u0e19\u0e44\u0e14\u0e49 1. \u0e15\u0e31\u0e49\u0e07\u0e04 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_editorskit_title_hidden":false,"_editorskit_reading_time":0,"_editorskit_is_block_options_detached":false,"_editorskit_block_options_position":"{}","footnotes":""},"categories":[105,9],"tags":[],"class_list":["post-220","post","type-post","status-publish","format-standard","hentry","category-centos","category-linux"],"_links":{"self":[{"href":"https:\/\/blog.chaiyakul.com\/index.php\/wp-json\/wp\/v2\/posts\/220","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.chaiyakul.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.chaiyakul.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.chaiyakul.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.chaiyakul.com\/index.php\/wp-json\/wp\/v2\/comments?post=220"}],"version-history":[{"count":2,"href":"https:\/\/blog.chaiyakul.com\/index.php\/wp-json\/wp\/v2\/posts\/220\/revisions"}],"predecessor-version":[{"id":222,"href":"https:\/\/blog.chaiyakul.com\/index.php\/wp-json\/wp\/v2\/posts\/220\/revisions\/222"}],"wp:attachment":[{"href":"https:\/\/blog.chaiyakul.com\/index.php\/wp-json\/wp\/v2\/media?parent=220"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.chaiyakul.com\/index.php\/wp-json\/wp\/v2\/categories?post=220"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.chaiyakul.com\/index.php\/wp-json\/wp\/v2\/tags?post=220"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}