{"id":1079,"date":"2021-07-31T15:19:45","date_gmt":"2021-07-31T07:19:45","guid":{"rendered":"https:\/\/www.dxQerp.cn\/?p=1079"},"modified":"2021-09-06T07:04:59","modified_gmt":"2021-09-05T23:04:59","slug":"how-to-install-and-configure-apache-on-centos-8","status":"publish","type":"post","link":"http:\/\/www.dxQerp.cn\/?p=1079","title":{"rendered":"Apache \u5982\u4f55\u5b89\u88dd\u8207\u8a2d\u5b9a  \u5728 CentOS 8"},"content":{"rendered":"\n<h3>\u4e8b\u524d \u6e96\u5099<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>dnf install dnf-utils http:\/\/rpms.remirepo.net\/enterprise\/remi-release-8.rpm  # \u9023\u7d50\u5230 remi \u7a0b\u5f0f\u5eab<\/code><\/pre>\n\n\n\n<p>Step 1\u00a0 \u00a0Apache \u5b89\u88dd \u8207 \u521d\u6b65\u8a2d\u5b9a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dnf install httpd      # \u6307\u4ee4 \u5b89\u88dd Apache \u3002(\u7db2\u8def\u9023\u7dda)\n                       # \u5b89\u88dd \u5176\u4ed6\u5fc5\u9700\u7684\u8edf\u4ef6\u5305 \n                       # \u7b49\u5f85 \u5b89\u88dd\u5b8c\u6210 \u770b\u770b \u591a\u4e86\u54ea\u4e9b\u6771\u897f ?<\/code><\/pre>\n\n\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:heading {\"level\":4} --><\/p>\n<h4>Step 2&nbsp; &nbsp;\u7ba1\u7406 Apache \u670d\u52d9<\/h4>\n<p><!-- \/wp:heading --><\/p>\n<p><!-- wp:code --><\/p>\n<pre class=\"wp-block-code\"><code><span style=\"color: #800000;\">systemctl enable httpd<\/span>  # \u96fb\u8166\u91cd\u555f\u6642,\u6703\u81ea\u52d5\u958b\u555f Apache\n<span style=\"color: #800000;\">systemctl stop httpd <\/span>   # \u95dc\u9589 Apache\n<span style=\"color: #800000;\">systemctl restart httpd<\/span> # \u91cd\u555f Apache\n<span style=\"color: #800000;\">systemctl status httpd <\/span> # Apache \u7576\u4e0b\u72c0\u6cc1\n<span style=\"color: #800000;\">systemctl start httpd<\/span>   # \u958b\u555f Apache\n<span style=\"color: #800000;\">systemctl reload httpd<\/span>  # \u91cd\u65b0\u8f09\u5165 \u76f8\u95dc\u53c3\u6578\n<\/code><\/pre>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:heading {\"level\":4} --><\/p>\n<h4>Step 3&nbsp; &nbsp;firewall-cmd\u770b\u770b \u9632\u706b\u7246<\/h4>\n<p><!-- \/wp:heading --><\/p>\n<p><!-- wp:code --><\/p>\n<pre class=\"wp-block-code\"><code><span style=\"color: #800000;\">firewall-cmd&nbsp; --permanent --zone=public --add-service=http<\/span>&nbsp;  # \u6253\u958b port(80)\n<span style=\"color: #800000;\">firewall-cmd&nbsp; --permanent --zone=public --add-service=https<\/span>   # \u6253\u958b port(443)\n<span style=\"color: #800000;\">firewall-cmd&nbsp; --reload<\/span>&nbsp; &nbsp; &nbsp;  # \u9632\u706b\u7246\u898f\u5247,\u91cd\u65b0\u8f09\u5165.\n<span style=\"color: #800000;\">firewall-cmd&nbsp; --list-services<\/span>  # \u67e5\u770b \u9632\u706b\u7246 \u662f\u5426\u958b\u555f http, https.\n<\/code><\/pre>\n<p><!-- \/wp:code --><\/p>\n<p><!-- wp:paragraph --><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:heading {\"level\":4} --><\/p>\n<h4>Step 4&nbsp; &nbsp;\u6e2c\u8a66 Apache \u8a2d\u7f6e<\/h4>\n<p><!-- \/wp:heading --><\/p>\n<p><!-- wp:code --><\/p>\n<pre class=\"wp-block-code\"><code><span style=\"color: #800000;\">httpd -v<\/span>   # \u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u5df2\u5b89\u88dd\u7684 Apache \u7248\u672c\u8a73\u7d30\u4fe1\u606f\u3002\n<\/code><\/pre>\n<p><!-- \/wp:code --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>\u73fe\u5728\u4f7f\u7528 <strong>Firefox<\/strong> \u700f\u89bd\u5668 \u8a2a\u554f \u670d\u52d9\u5668\u7684 <strong>IP \u5730\u5740<\/strong>\u6216\u6307\u5411\u670d\u52d9\u5668 IP \u7684\u57df\u540d\u3002<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:preformatted --><\/p>\n<pre class=\"wp-block-preformatted\">http:\/\/127.0.0.1\nhttp:\/\/localhost\nhttp:\/\/mail.dxqerp.com<\/pre>\n<p><!-- \/wp:preformatted --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>\u61c9\u8a72 \u51fa\u73fe Apache \u7684\u9810\u8a2d\u756b\u9762 (<em><span style=\"color: #0000ff;\">HTTP Server Test Page<\/span><\/em>)<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:paragraph --><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:heading {\"level\":4} --><\/p>\n<h4>Step 5&nbsp; &nbsp;\u6e2c\u8a66 \u81ea\u5df1\u7684 \u6e2c\u8a66\u756b\u9762<\/h4>\n<p><!-- \/wp:heading --><\/p>\n<p><!-- wp:code --><\/p>\n<pre class=\"wp-block-code\"><code><span style=\"color: #800000;\">echo \" Hi \u5929\u5357\u8a0a\u606f\u79d1\u6280 \"&nbsp; &gt; \/var\/www\/html\/index.html<\/span><\/code><\/pre>\n<p><!-- \/wp:code --><\/p>\n<p><!-- wp:preformatted --><\/p>\n<pre class=\"wp-block-preformatted\">http:\/\/127.0.0.1<br>http:\/\/localhost<br>http:\/\/mail.dxqerp.com<\/pre>\n<p><!-- \/wp:preformatted --><\/p>\n<p><!-- wp:heading {\"level\":4} --><\/p>\n<h4>Step 6&nbsp; &nbsp;\u865b\u64ec\u4e3b\u6a5f (mail.dxqerp.com ) \u5efa\u7acb port 80<\/h4>\n<p><!-- \/wp:heading --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p><strong># \u5efa\u7acb mail.dxqerp.com&nbsp; (\u4e3b\u8981 \u865b\u64ec\u4e3b\u6a5f)<\/strong><\/p>\n<p><code>vim \/etc\/httpd\/conf.d\/AAA.conf                                    # \u5efa\u7acb \u865b\u64ec\u4e3b\u6a5f \u74b0\u5883\u8a2d\u5b9a \u6a94<\/code><\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:code --><\/p>\n<pre class=\"wp-block-code\"><code>&lt;VirtualHost 192.168.17.9:80&gt;\n  ServerAdmin qq@mail.dxqerp.com\n  DocumentRoot \/var\/www\/html\n  ServerName mail.dxqerp.com\n  ServerAlias mail.dxqerp.com\n  &lt;Directory \/var\/www\/html&gt;\n        #Allowoverride all uncomment if required\n  &lt;\/Directory&gt;\n  ErrorLog logs\/dxqerp.com_error.log\n  CustomLog logs\/dxqerp.com_access.log combined\n&lt;\/VirtualHost&gt;<\/code><\/pre>\n<p><!-- \/wp:code --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p><strong># \u5efa\u7acb first.com \u865b\u64ec\u4e3b\u6a5f (\u7b2c\u4e8c\u500b\u865b\u64ec\u4e3b\u6a5f)<\/strong><\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:code --><\/p>\n<pre class=\"wp-block-code\"><code>mkdir -p \/var\/www\/first.com\necho \" Hi www.first.com \u865b\u64ec\u4e3b\u6a5f \" &gt; \/var\/www\/first.com\/index.html   # \u865b\u64ec\u6a5f \u7684 index.html\nvim \/etc\/httpd\/conf.d\/AAA.conf                                    # \u5efa\u7acb \u865b\u64ec\u4e3b\u6a5f \u74b0\u5883\u8a2d\u5b9a \u6a94\n\n&lt;VirtualHost 192.168.17.9:80&gt;\n   DocumentRoot \/var\/www\/first.com\n   ServerName www.first.com\n   ServerAlias www.first.com\n   &lt;Directory \/var\/www\/first.com&gt;\n        #Allowoverride all, Uncomment if required\n   &lt;\/Directory&gt;\n   ErrorLog logs\/first.com_error.log\n   CustomLog logs\/first.com_access.log combined\n&lt;\/VirtualHost&gt;<\/code><\/pre>\n<p><!-- \/wp:code --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p><strong># \u5efa\u7acb Second.com \u865b\u64ec\u4e3b\u6a5f (\u7b2c\u4e09\u500b\u865b\u64ec\u4e3b\u6a5f)<\/strong><\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:code --><\/p>\n<pre class=\"wp-block-code\"><code>mkdir -p \/var\/www\/second.com\necho \" Hi www.second.com  \u865b\u64ec\u4e3b\u6a5f \" &gt; \/var\/www\/second.com\/index.html   # \u865b\u64ec\u6a5f \u7684 index.htm<br>vim \/etc\/httpd\/conf.d\/AAA.conf # \u5efa\u7acb \u865b\u64ec\u4e3b\u6a5f \u74b0\u5883\u8a2d\u5b9a \u6a94<br><br>&lt;VirtualHost 192.168.17.9:80 &gt;\n   DocumentRoot \/var\/www\/second.com\n   ServerName www.second.com\n   ServerAlias www.second.com\n   &lt;Directory \/var\/www\/second.com&gt;\n     Allowoverride all ###Uncomment if required\n   &lt;\/Directory&gt;\n   ErrorLog logs\/second.com_error.log\n   CustomLog logs\/second.com_access.log combined\n&lt;\/VirtualHost&gt;<\/code><\/pre>\n<p><!-- \/wp:code --><\/p>\n<p><!-- wp:heading {\"level\":4} --><\/p>\n<h4>Step 7&nbsp; &nbsp;\u5b89\u5168\u7684 Apache \u670d\u52d9\u5668<\/h4>\n<p><!-- \/wp:heading --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>\u5b89\u5168\u662f\u8a17\u7ba1\u6700\u91cd\u8981\u7684\u90e8\u5206\u3002 \u7de8\u8f2fApache\u4e3b\u914d\u7f6e\u6587\u4ef6<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:preformatted --><\/p>\n<pre class=\"wp-block-preformatted\"><span style=\"color: #800000;\">vim \/etc\/httpd\/conf\/httpd.conf<\/span>&nbsp;# <strong>\u5728\u6587\u4ef6\u672b\u5c3e\u6dfb\u52a0\u4ee5\u4e0b\u503c<\/strong>.\n<span style=\"color: #800000;\">ServerTokens Prod<\/span>  &nbsp; &nbsp;         # \u4e0d\u986f\u793a Apache \u7248\u672c\u865f.\n<span style=\"color: #800000;\">ServerSignature Off<\/span>  &nbsp;         # \u7576\u67e5\u8a62\u7684\u7db2\u9801\u4e0d\u5b58\u5728, \u4e0d\u986f\u793a \u76f8\u95dc\u7684\u8a0a\u606f.\n<span style=\"color: #800000;\">TraceEnable Off<\/span>  &nbsp; &nbsp; &nbsp; &nbsp;       # \u907f\u514d Trace \u65b9\u6cd5 \u7684\u653b\u64ca.<\/pre>\n<p><!-- \/wp:preformatted --><\/p>\n<p><!-- wp:heading {\"level\":3} --><\/p>\n<h3><strong>THE END&nbsp;<\/strong><\/h3>\n<p><!-- \/wp:heading --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p><strong>\u53c3\u8003<\/strong><br><a href=\"https:\/\/tecadmin.net\/install-apache-centos8\/#:~:text=1%20Install%20Apache%20on%20CentOS%208.%20First%20of,web%20server.%20Here%20are%20the%20multiple%20security-related%20settings.\">https:\/\/tecadmin.net\/install-apache-centos8.<\/a><br><a href=\"https:\/\/wizardforcel.gitbooks.io\/vbird-linux-server-3e\/content\/149.html\">https:\/\/wizardforcel.gitbooks.io\/vbird-linux-server-3e\/content\/149.html<\/a><\/p>\n<p><!-- \/wp:paragraph --><\/p>","protected":false},"excerpt":{"rendered":"<p>\u4e8b\u524d \u6e96\u5099 Step 1\u00a0 \u00a0Apache \u5b89\u88dd \u8207 \u521d\u6b65\u8a2d\u5b9a Step 2&nbsp; &nbsp;\u7ba1\u7406 A [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1175,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[37],"tags":[],"jetpack_featured_media_url":"http:\/\/www.dxQerp.cn\/wp-content\/uploads\/2021\/08\/HTTP-SERVER-TEST-PAGE.png","_links":{"self":[{"href":"http:\/\/www.dxQerp.cn\/index.php?rest_route=\/wp\/v2\/posts\/1079"}],"collection":[{"href":"http:\/\/www.dxQerp.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.dxQerp.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.dxQerp.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.dxQerp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1079"}],"version-history":[{"count":49,"href":"http:\/\/www.dxQerp.cn\/index.php?rest_route=\/wp\/v2\/posts\/1079\/revisions"}],"predecessor-version":[{"id":1505,"href":"http:\/\/www.dxQerp.cn\/index.php?rest_route=\/wp\/v2\/posts\/1079\/revisions\/1505"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.dxQerp.cn\/index.php?rest_route=\/wp\/v2\/media\/1175"}],"wp:attachment":[{"href":"http:\/\/www.dxQerp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1079"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.dxQerp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1079"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.dxQerp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1079"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}