{"id":1071,"date":"2021-08-02T07:13:45","date_gmt":"2021-08-01T23:13:45","guid":{"rendered":"http:\/\/www.dxQerp.com\/?p=1071"},"modified":"2021-09-03T08:10:01","modified_gmt":"2021-09-03T00:10:01","slug":"how-to-install-and-configure-apache-on-centos-8","status":"publish","type":"post","link":"http:\/\/www.dxQerp.com\/?p=1071","title":{"rendered":"How to Install and Configure Apache on CentOS 8"},"content":{"rendered":"<h3>\u4e8b\u524d \u6e96\u5099<\/h3>\r\n<h4><!-- \/wp:post-content --><\/h4>\r\n<!-- wp:code -->\r\n<pre class=\"wp-block-code\"><code>dnf install dnf-utils http:\/\/rpms.remirepo.net\/enterprise\/remi-release-8.rpm<\/code><\/pre>\r\n<h4><!-- \/wp:code --><\/h4>\r\n<!-- wp:heading {\"level\":4} -->\r\n<h4>Step 1\u00a0 \u00a0Apache \u5b89\u88dd \u8207 \u521d\u6b65\u8a2d\u5b9a<\/h4>\r\n<h4><!-- \/wp:heading --><\/h4>\r\n<!-- wp:code -->\r\n<pre class=\"wp-block-code\"><code>dnf install httpd      # \u5b89\u88dd Apache (\u7db2\u8def\u9023\u7dda) \u6307\u4ee4\u5b89\u88dd Apache \u3002\r\n                       # \u4e5f\u5b89\u88dd\u5176\u4ed6\u5fc5\u9700\u7684\u8edf\u4ef6\u5305 \u7b49\u5f85 \u5b89\u88dd\u5b8c\u6210 \u770b\u770b \u591a\u4e86\u54ea\u4e9b\u6771\u897f ?<\/code><\/pre>\r\n<h4><!-- \/wp:code --><\/h4>\r\n<!-- wp:paragraph \/-->\r\n\r\n<!-- wp:heading {\"level\":4} -->\r\n<h4>Step 2\u00a0 \u00a0\u7ba1\u7406 Apache \u670d\u52d9<\/h4>\r\n<h4><!-- \/wp:heading --><\/h4>\r\n<!-- wp:code -->\r\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 httpd\r\n<span style=\"color: #800000;\">systemctl stop httpd <\/span>   # \u95dc\u9589 Apachche\r\n<span style=\"color: #800000;\">systemctl restart httpd<\/span> # \u91cd\u555f Apache\r\n<span style=\"color: #800000;\">systemctl status hte\r\nsystemctl start httpd   # \u958b\u555f Apatpd  <span style=\"color: #000000;\"># Apache<\/span><\/span> \u7576\u4e0b\u72c0\u6cc1\r\n<span style=\"color: #800000;\">systemctl reload httpd<\/span>  # \u91cd\u65b0\u8f09\u5165 \u76f8\u95dc\u53c3\u6578\r\n<\/code><\/pre>\r\n<h4><!-- \/wp:code --><\/h4>\r\n<!-- wp:paragraph \/-->\r\n\r\n<!-- wp:heading {\"level\":4} -->\r\n<h4>Step 3\u00a0 \u00a0firewall-cmd\u770b\u770b \u9632\u706b\u7246<\/h4>\r\n<h4><!-- \/wp:heading --><\/h4>\r\n<!-- wp:code -->\r\n<pre class=\"wp-block-code\"><code><span style=\"color: #800000;\">firewall-cmd\u00a0 --permanent --zone=public --add-service=http<\/span>    # \u6253\u958b port(80)\r\n<span style=\"color: #800000;\">firewall-cmd\u00a0 --permanent --zone=public --add-service=https <\/span>  # \u6253\u958b port(443)\r\n<span style=\"color: #800000;\">firewall-cmd\u00a0 --reload<\/span>\u00a0 \u00a0 \u00a0  # \u9632\u706b\u7246\u898f\u5247,\u91cd\u65b0\u8f09\u5165.\r\n<span style=\"color: #800000;\">firewall-cmd\u00a0 --list-services<\/span>\u00a0 # \u67e5\u770b \u9632\u706b\u7246 \u662f\u5426\u958b\u555f http, httpd.\r\n<\/code><\/pre>\r\n<h4><!-- \/wp:code --><\/h4>\r\n<!-- wp:paragraph \/-->\r\n\r\n<!-- wp:heading {\"level\":4} -->\r\n<h4>Step 4\u00a0 \u00a0\u6e2c\u8a66 Apache \u8a2d\u7f6e<\/h4>\r\n<h4><!-- \/wp:heading --><\/h4>\r\n<!-- wp:code -->\r\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\r\n<\/code><\/pre>\r\n<h4><!-- \/wp:code --><\/h4>\r\n<!-- wp:paragraph -->\r\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>\r\n<h4><!-- \/wp:paragraph --><\/h4>\r\n<!-- wp:preformatted -->\r\n<pre class=\"wp-block-preformatted\">http:\/\/127.0.0.1\r\nhttp:\/\/localhost\r\nhttp:\/\/mail.dxqerp.com<\/pre>\r\n<h4><!-- \/wp:preformatted --><\/h4>\r\n<!-- wp:paragraph -->\r\n<p>\u61c9\u8a72 \u51fa\u73fe Apache \u7684\u9810\u8a2d\u756b\u9762 (<em><span style=\"color: #0000ff;\">HTTP Server Test Page<\/span><\/em>)<\/p>\r\n<h4><!-- \/wp:paragraph --><\/h4>\r\n<!-- wp:paragraph \/-->\r\n\r\n<!-- wp:heading {\"level\":4} -->\r\n<h4>Step 5\u00a0 \u00a0\u6e2c\u8a66 \u81ea\u5df1\u7684 \u6e2c\u8a66\u756b\u9762<\/h4>\r\n<h4><!-- \/wp:heading --><\/h4>\r\n<!-- wp:code -->\r\n<pre class=\"wp-block-code\"><code><span style=\"color: #800000;\">echo \" Hi \u5929\u5357\u8a0a\u606f\u79d1\u6280 \"\u00a0 &gt; \/var\/www\/html\/index.html<\/span><\/code><\/pre>\r\n<h4><!-- \/wp:code --><\/h4>\r\n<!-- wp:preformatted -->\r\n<pre class=\"wp-block-preformatted\">http:\/\/127.0.0.1\r\nhttp:\/\/localhost\r\nhttp:\/\/mail.dxqerp.com\r\n\r\n<\/pre>\r\n<h4><!-- \/wp:preformatted --><\/h4>\r\n<!-- wp:heading {\"level\":4} -->\r\n<h4>Step 6\u00a0 \u00a0\u865b\u64ec\u4e3b\u6a5f (first.com ) \u5efa\u7acb port 80<\/h4>\r\n<h4><!-- \/wp:heading --><\/h4>\r\n<!-- wp:paragraph -->\r\n<p><strong># \u5efa\u7acb mail.dxqerp.com\u00a0 (\u4e3b\u8981 \u865b\u64ec\u4e3b\u6a5f)<\/strong><\/p>\r\n<h4><!-- \/wp:paragraph --><\/h4>\r\n<!-- wp:code -->\r\n<pre class=\"wp-block-code\"><code>&lt;VirtualHost 192.168.17.9:80&gt;\r\n  ServerAdmin admin@first.com\r\n  DocumentRoot \/var\/www\/html\r\n  ServerName mail.dxqerp.com\r\n  ServerAlias mail.dxqerp.com\r\n  &lt;Directory \/var\/www\/html&gt;\r\n        #Allowoverride all uncomment if required\r\n  &lt;\/Directory&gt;\r\n  ErrorLog logs\/dxqerp.com_error.log\r\n  CustomLog logs\/dxqerp.com_access.log combined\r\n&lt;\/VirtualHost&gt;<\/code><\/pre>\r\n<h4><!-- \/wp:code --><\/h4>\r\n<!-- wp:paragraph -->\r\n<p><strong># \u5efa\u7acb first.com \u865b\u64ec\u4e3b\u6a5f (\u7b2c\u4e8c\u500b\u865b\u64ec\u4e3b\u6a5f)<\/strong><\/p>\r\n<h4><!-- \/wp:paragraph --><\/h4>\r\n<!-- wp:code -->\r\n<pre class=\"wp-block-code\"><code>mkdir -p \/var\/www\/first.com\r\necho \" Hi   www.first.com  \u865b\u64ec\u4e3b\u6a5f \" &gt; \/var\/www\/first.com\/index.html   # \u865b\u64ec\u6a5f \u7684 index.html\r\nvim \/etc\/httpd\/conf.d\/first.com.conf                                    # \u5efa\u7acb\u865b\u64ec\u4e3b\u6a5f \u74b0\u5883\u8a2d\u5b9a \u6a94\r\n\r\n&lt;VirtualHost 192.168.17.8:80&gt;\r\n   ServerAdmin admin@first.com\r\n   DocumentRoot \/var\/www\/first.com\r\n   ServerName www.first.com\r\n   ServerAlias www.first.com\r\n   &lt;Directory \/var\/www\/first.com&gt;\r\n        #Allowoverride all, Uncomment if required\r\n   &lt;\/Directory&gt;\r\n   ErrorLog logs\/first.com_error.log\r\n   CustomLog logs\/first.com_access.log combined\r\n&lt;\/VirtualHost&gt;<\/code><\/pre>\r\n<h4><!-- \/wp:code --><\/h4>\r\n<!-- wp:paragraph -->\r\n<p><strong># \u5efa\u7acb Second.com \u865b\u64ec\u4e3b\u6a5f (\u7b2c\u4e09\u500b\u865b\u64ec\u4e3b\u6a5f)<\/strong><\/p>\r\n<h4><!-- \/wp:paragraph --><\/h4>\r\n<!-- wp:code -->\r\n<pre class=\"wp-block-code\"><code>&lt;VirtualHost 192.168.17.9:80 &gt;\r\n   DocumentRoot \/var\/www\/second.com\r\n   ServerName www.second.com\r\n   ServerAlias www.second.com\r\n   &lt;Directory \/var\/www\/second.com&gt;\r\n     Allowoverride all ###Uncomment if required\r\n   &lt;\/Directory&gt;\r\n   ErrorLog logs\/second.com_error.log\r\n   CustomLog logs\/second.com_access.log combined\r\n&lt;\/VirtualHost&gt;<\/code><\/pre>\r\n<h4><!-- \/wp:code --><\/h4>\r\n<!-- wp:heading {\"level\":4} -->\r\n<h4>Step 7\u00a0 \u00a0\u5b89\u5168\u7684 Apache \u670d\u52d9\u5668<\/h4>\r\n<h4><!-- \/wp:heading --><\/h4>\r\n<!-- wp:paragraph -->\r\n<p>\u5b89\u5168\u662f\u8a17\u7ba1\u6700\u91cd\u8981\u7684\u90e8\u5206\u3002 \u7de8\u8f2fApache\u4e3b\u914d\u7f6e\u6587\u4ef6<\/p>\r\n<h4><!-- \/wp:paragraph --><\/h4>\r\n<!-- wp:preformatted -->\r\n<pre class=\"wp-block-preformatted\"><span style=\"color: #800000;\">vim \/etc\/httpd\/conf\/httpd.conf<\/span>\u00a0# <strong>\u5728\u6587\u4ef6\u672b\u5c3e\u6dfb\u52a0\u4ee5\u4e0b\u503c<\/strong>.\r\n<span style=\"color: #800000;\">ServerTokens Prod<\/span>  \u00a0 \u00a0         # \u4e0d\u986f\u793a Apache \u7248\u672c\u865f.\r\n<span style=\"color: #800000;\">ServerSignature Off<\/span>  \u00a0         # \u7576\u67e5\u8a62\u7684\u7db2\u9801\u4e0d\u5b58\u5728, \u4e0d\u986f\u793a \u76f8\u95dc\u7684\u8a0a\u606f.\r\n<span style=\"color: #800000;\">TraceEnable Off<\/span>  \u00a0 \u00a0 \u00a0 \u00a0       # \u907f\u514d Trace \u65b9\u6cd5 \u7684\u653b\u64ca.<\/pre>\r\n<h4><!-- \/wp:preformatted --><\/h4>\r\n<!-- wp:heading {\"level\":3} -->\r\n<h4>THE END<\/h4>\r\n<h4><!-- \/wp:heading --><\/h4>\r\n<!-- wp:paragraph -->\r\n<h4>\u53c3\u8003<\/h4>\r\n<p><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><\/p>\r\n<p><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>","protected":false},"excerpt":{"rendered":"<p>\u4e8b\u524d \u6e96\u5099 dnf install dnf-utils http:\/\/rpms.remirepo.net\/en [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[29],"tags":[],"class_list":["post-1071","post","type-post","status-publish","format-standard","hentry","category-aapache"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"http:\/\/www.dxQerp.com\/index.php?rest_route=\/wp\/v2\/posts\/1071","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.dxQerp.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.dxQerp.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.dxQerp.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.dxQerp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1071"}],"version-history":[{"count":10,"href":"http:\/\/www.dxQerp.com\/index.php?rest_route=\/wp\/v2\/posts\/1071\/revisions"}],"predecessor-version":[{"id":1092,"href":"http:\/\/www.dxQerp.com\/index.php?rest_route=\/wp\/v2\/posts\/1071\/revisions\/1092"}],"wp:attachment":[{"href":"http:\/\/www.dxQerp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1071"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.dxQerp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1071"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.dxQerp.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1071"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}