{"id":41840,"date":"2024-10-02T10:52:46","date_gmt":"2024-10-02T02:52:46","guid":{"rendered":"https:\/\/server.hk\/cnblog\/41840\/"},"modified":"2024-10-02T10:52:46","modified_gmt":"2024-10-02T02:52:46","slug":"apache%e6%96%b0%e6%89%8b%e6%95%99%e7%a8%8b%ef%bc%9a%e7%82%ba%e5%85%a7%e7%b6%b2%e9%85%8d%e7%bd%aeapache","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/41840\/","title":{"rendered":"Apache\u65b0\u624b\u6559\u7a0b\uff1a\u70ba\u5167\u7db2\u914d\u7f6eApache"},"content":{"rendered":"<h1 id=\"apache%e6%96%b0%e6%89%8b%e6%95%99%e7%a8%8b%ef%bc%9a%e7%82%ba%e5%85%a7%e7%b6%b2%e9%85%8d%e7%bd%aeapache-qCwjUcgvGt\">Apache\u65b0\u624b\u6559\u7a0b\uff1a\u70ba\u5167\u7db2\u914d\u7f6eApache<\/h1>\n<p>Apache HTTP Server\uff08\u7c21\u7a31Apache\uff09\u662f\u4e00\u6b3e\u958b\u6e90\u7684\u7db2\u9801\u4f3a\u670d\u5668\u8edf\u9ad4\uff0c\u5ee3\u6cdb\u61c9\u7528\u65bc\u5404\u7a2e\u5e73\u53f0\u3002\u7121\u8ad6\u662f\u5c0f\u578b\u7db2\u7ad9\u9084\u662f\u5927\u578b\u4f01\u696d\uff0cApache\u90fd\u80fd\u63d0\u4f9b\u7a69\u5b9a\u7684\u670d\u52d9\u3002\u672c\u6587\u5c07\u6307\u5c0e\u60a8\u5982\u4f55\u5728\u5167\u7db2\u4e2d\u914d\u7f6eApache\uff0c\u8b93\u60a8\u80fd\u5920\u5728\u672c\u5730\u7db2\u8def\u4e0a\u8f15\u9b06\u642d\u5efa\u7db2\u7ad9\u3002<\/p>\n<h2 id=\"%e5%ae%89%e8%a3%9dapache-qCwjUcgvGt\">\u5b89\u88ddApache<\/h2>\n<p>\u5728\u958b\u59cb\u914d\u7f6e\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u5b89\u88ddApache\u3002\u4ee5\u4e0b\u662f\u91dd\u5c0d\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7d71\u7684\u5b89\u88dd\u6b65\u9a5f\uff1a<\/p>\n<h3 id=\"%e5%9c%a8ubuntu%e4%b8%8a%e5%ae%89%e8%a3%9dapache-qCwjUcgvGt\">\u5728Ubuntu\u4e0a\u5b89\u88ddApache<\/h3>\n<pre><code>sudo apt update\nsudo apt install apache2\n<\/code><\/pre>\n<h3 id=\"%e5%9c%a8centos%e4%b8%8a%e5%ae%89%e8%a3%9dapache-qCwjUcgvGt\">\u5728CentOS\u4e0a\u5b89\u88ddApache<\/h3>\n<pre><code>sudo yum update\nsudo yum install httpd\n<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u555f\u52d5Apache\u670d\u52d9\uff1a<\/p>\n<pre><code>sudo systemctl start apache2  # Ubuntu\nsudo systemctl start httpd      # CentOS\n<\/code><\/pre>\n<h2 id=\"%e9%85%8d%e7%bd%aeapache-qCwjUcgvGt\">\u914d\u7f6eApache<\/h2>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u9700\u8981\u9032\u884c\u4e00\u4e9b\u57fa\u672c\u914d\u7f6e\uff0c\u4ee5\u4fbf\u5728\u5167\u7db2\u4e2d\u4f7f\u7528Apache\u3002<\/p>\n<h3 id=\"%e4%bf%ae%e6%94%b9%e9%85%8d%e7%bd%ae%e6%96%87%e4%bb%b6-qCwjUcgvGt\">\u4fee\u6539\u914d\u7f6e\u6587\u4ef6<\/h3>\n<p>Apache\u7684\u4e3b\u8981\u914d\u7f6e\u6587\u4ef6\u901a\u5e38\u4f4d\u65bc\u4ee5\u4e0b\u8def\u5f91\uff1a<\/p>\n<ul>\n<li>Ubuntu: \/etc\/apache2\/apache2.conf<\/li>\n<li>CentOS: \/etc\/httpd\/conf\/httpd.conf<\/li>\n<\/ul>\n<p>\u4f7f\u7528\u6587\u672c\u7de8\u8f2f\u5668\u6253\u958b\u914d\u7f6e\u6587\u4ef6\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre><code>sudo nano \/etc\/apache2\/apache2.conf  # Ubuntu\nsudo nano \/etc\/httpd\/conf\/httpd.conf    # CentOS\n<\/code><\/pre>\n<p>\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u60a8\u53ef\u4ee5\u8a2d\u7f6e\u4ee5\u4e0b\u5e7e\u500b\u91cd\u8981\u53c3\u6578\uff1a<\/p>\n<ul>\n<li><strong>ServerName<\/strong>: \u8a2d\u7f6e\u4f3a\u670d\u5668\u540d\u7a31\uff0c\u4f8b\u5982\uff1a<\/li>\n<pre><code>ServerName localhost<\/code><\/pre>\n<li><strong>DocumentRoot<\/strong>: \u8a2d\u7f6e\u7db2\u7ad9\u6839\u76ee\u9304\uff0c\u4f8b\u5982\uff1a<\/li>\n<pre><code>DocumentRoot \/var\/www\/html<\/code><\/pre>\n<\/ul>\n<h3 id=\"%e8%a8%ad%e7%bd%ae%e8%99%9b%e6%93%ac%e4%b8%bb%e6%a9%9f-qCwjUcgvGt\">\u8a2d\u7f6e\u865b\u64ec\u4e3b\u6a5f<\/h3>\n<p>\u5982\u679c\u60a8\u5e0c\u671b\u5728\u540c\u4e00\u53f0\u4f3a\u670d\u5668\u4e0a\u904b\u884c\u591a\u500b\u7db2\u7ad9\uff0c\u53ef\u4ee5\u4f7f\u7528\u865b\u64ec\u4e3b\u6a5f\u3002\u4ee5\u4e0b\u662f\u8a2d\u7f6e\u865b\u64ec\u4e3b\u6a5f\u7684\u6b65\u9a5f\uff1a<\/p>\n<pre><code>&lt;VirtualHost *:80&gt;\n    ServerAdmin webmaster@localhost\n    DocumentRoot \/var\/www\/html\/example\n    ErrorLog ${APACHE_LOG_DIR}\/error.log\n    CustomLog ${APACHE_LOG_DIR}\/access.log combined\n&lt;\/VirtualHost&gt;\n<\/code><\/pre>\n<p>\u5c07\u4e0a\u8ff0\u4ee3\u78bc\u6dfb\u52a0\u5230\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u4e26\u78ba\u4fdd\u5c07DocumentRoot\u6307\u5411\u6b63\u78ba\u7684\u7db2\u7ad9\u76ee\u9304\u3002<\/p>\n<h2 id=\"%e9%98%b2%e7%81%ab%e7%89%86%e8%a8%ad%e7%bd%ae-qCwjUcgvGt\">\u9632\u706b\u7246\u8a2d\u7f6e<\/h2>\n<p>\u5728\u5167\u7db2\u4e2d\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u914d\u7f6e\u9632\u706b\u7246\u4ee5\u5141\u8a31HTTP\u548cHTTPS\u6d41\u91cf\u3002\u4ee5\u4e0b\u662f\u5e38\u898b\u7684\u9632\u706b\u7246\u8a2d\u7f6e\u547d\u4ee4\uff1a<\/p>\n<h3 id=\"%e5%9c%a8ubuntu%e4%b8%8a-qCwjUcgvGt\">\u5728Ubuntu\u4e0a<\/h3>\n<pre><code>sudo ufw allow 'Apache Full'<\/code><\/pre>\n<h3 id=\"%e5%9c%a8centos%e4%b8%8a-qCwjUcgvGt\">\u5728CentOS\u4e0a<\/h3>\n<pre><code>sudo firewall-cmd --permanent --add-service=http\nsudo firewall-cmd --permanent --add-service=https\nsudo firewall-cmd --reload\n<\/code><\/pre>\n<h2 id=\"%e6%b8%ac%e8%a9%a6apache%e9%85%8d%e7%bd%ae-qCwjUcgvGt\">\u6e2c\u8a66Apache\u914d\u7f6e<\/h2>\n<p>\u5b8c\u6210\u6240\u6709\u914d\u7f6e\u5f8c\uff0c\u60a8\u53ef\u4ee5\u901a\u904e\u5728\u700f\u89bd\u5668\u4e2d\u8f38\u5165\u4f3a\u670d\u5668\u7684IP\u5730\u5740\u4f86\u6e2c\u8a66Apache\u662f\u5426\u6b63\u5e38\u904b\u884c\u3002\u5982\u679c\u4e00\u5207\u6b63\u5e38\uff0c\u60a8\u61c9\u8a72\u80fd\u770b\u5230Apache\u7684\u9810\u8a2d\u9801\u9762\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-qCwjUcgvGt\">\u7e3d\u7d50<\/h2>\n<p>\u672c\u6587\u4ecb\u7d39\u4e86\u5982\u4f55\u5728\u5167\u7db2\u4e2d\u914d\u7f6eApache\uff0c\u5305\u62ec\u5b89\u88dd\u3001\u57fa\u672c\u914d\u7f6e\u3001\u865b\u64ec\u4e3b\u6a5f\u8a2d\u7f6e\u53ca\u9632\u706b\u7246\u914d\u7f6e\u3002\u900f\u904e\u9019\u4e9b\u6b65\u9a5f\uff0c\u60a8\u53ef\u4ee5\u8f15\u9b06\u5730\u5728\u672c\u5730\u7db2\u8def\u4e0a\u642d\u5efa\u7db2\u7ad9\u3002\u5982\u679c\u60a8\u9700\u8981\u66f4\u9ad8\u6548\u7684\u4f3a\u670d\u5668\u89e3\u6c7a\u65b9\u6848\uff0c\u53ef\u4ee5\u8003\u616e\u4f7f\u7528<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a>\u6216<a href=\"https:\/\/server.hk\">\u9999\u6e2f\u4f3a\u670d\u5668<\/a>\uff0c\u4ee5\u6eff\u8db3\u60a8\u7684\u9700\u6c42\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b78\u7fd2\u5982\u4f55\u70ba\u5167\u7db2\u914d\u7f6eApache\u4f3a\u670d\u5668\uff0c\u5f9e\u5b89\u88dd\u5230\u57fa\u672c\u8a2d\u7f6e\uff0c\u9069\u5408\u65b0\u624b\u7684\u8a73\u7d30\u6b65\u9a5f\u8207\u5be6\u7528\u6280\u5de7\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-41840","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/41840","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=41840"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/41840\/revisions"}],"predecessor-version":[{"id":41841,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/41840\/revisions\/41841"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=41840"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=41840"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=41840"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}