{"id":4546,"date":"2025-07-11T13:42:07","date_gmt":"2025-07-11T04:42:07","guid":{"rendered":"https:\/\/eternalsphere.net\/echoes\/?p=4546"},"modified":"2026-06-06T10:31:02","modified_gmt":"2026-06-06T01:31:02","slug":"jkwjbszoxfu1rgp","status":"publish","type":"post","link":"https:\/\/eternalsphere.net\/echoes\/index.php\/2025\/07\/11\/jkwjbszoxfu1rgp\/","title":{"rendered":"Apache &amp; PHP \u91cd\u7f6e\u5b8c\u6574\u6559\u7a0b\uff08\u901a\u7528\u6b65\u9aa4\uff09"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u5728\u957f\u671f\u7ef4\u62a4 Linux \u670d\u52a1\u5668\uff08\u5982 Debian \u6216 Ubuntu\uff09\u73af\u5883\u65f6\uff0cApache \u548c PHP \u7ecf\u8fc7\u591a\u6b21\u914d\u7f6e\u3001\u5207\u6362\u6a21\u5757\u3001\u5b89\u88c5\u6269\u5c55\u540e\uff0c\u5f80\u5f80\u4f1a\u51fa\u73b0\u914d\u7f6e\u6df7\u4e71\u3001\u51b2\u7a81\u3001\u6216\u65e0\u6cd5\u6b63\u5e38\u89e3\u6790 PHP \u6587\u4ef6\u7684\u95ee\u9898\u3002\u4e3a\u4e86\u5feb\u901f\u6062\u590d\u4e00\u4e2a\u5e72\u51c0\u3001\u53ef\u63a7\u7684\u73af\u5883\uff0c\u53ef\u91c7\u7528\u300c\u5378\u8f7d\u91cd\u88c5\u300d\u65b9\u5f0f\u5f7b\u5e95\u91cd\u7f6e Apache \u548c PHP\uff0c\u4ec5\u4fdd\u7559\u5fc5\u8981\u7684\u6587\u4ef6\u548c\u6570\u636e\u5e93\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ee5\u4e0b\u4e3a\u901a\u7528\u91cd\u7f6e\u6b65\u9aa4\uff0c\u9002\u7528\u4e8e\u9700\u8981\u6e05\u7406\u5386\u53f2\u914d\u7f6e\u3001\u89e3\u51b3\u89e3\u6790\u6df7\u4e71\u3001\u91cd\u65b0\u90e8\u7f72\u5e94\u7528\u573a\u666f\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2705 \u6ce8\u610f\u4e8b\u9879<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6b64\u6d41\u7a0b\u53ea\u4f1a\u6e05\u7406 Apache \u548c PHP\uff0c<strong>\u4e0d\u4f1a\u5220\u9664\u6570\u636e\u5e93<\/strong>\uff08\u5982 MariaDB\u3001MySQL\uff09\uff0c\u4e5f\u4e0d\u4f1a\u5220\u9664 <code>\/var\/www\/html\/<\/code> \u4e0b\u7684\u6587\u4ef6\u3002<\/li>\n\n\n\n<li>\u82e5\u670d\u52a1\u5668\u4e2d\u6709\u91cd\u8981\u7f51\u7ad9\u6570\u636e\uff08\u5982 WordPress\u3001Nextcloud\uff09\uff0c\u5efa\u8bae\u63d0\u524d\u5907\u4efd\u6570\u636e\u5e93\u4e0e\u6587\u4ef6\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udd25 \u91cd\u7f6e\u6b65\u9aa4<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udfe2 1. \u5378\u8f7d Apache<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo apt remove --purge apache2 apache2-utils apache2-bin apache2.2-common -y<br><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6e05\u7406 Apache \u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo rm -rf \/etc\/apache2<br><\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udfe2 2. \u5378\u8f7d PHP \u53ca\u6240\u6709\u6a21\u5757<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo apt remove --purge php* -y<br><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6e05\u7406 PHP \u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo rm -rf \/etc\/php<br><\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udfe2 3. \u6e05\u7406\u65e0\u7528\u4f9d\u8d56<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo apt autoremove --purge -y<br>sudo apt autoclean<br><\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udfe2 4. \u91cd\u65b0\u5b89\u88c5 Apache<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo apt update<br>sudo apt install apache2 -y<br><\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udfe2 5. \u91cd\u65b0\u5b89\u88c5 PHP \u53ca\u5e38\u7528\u6269\u5c55<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo apt install php libapache2-mod-php php-mysql php-xml php-mbstring php-curl php-zip php-gd php-intl -y<br><\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udfe2 6. \u786e\u8ba4 PHP \u5df2\u88ab Apache \u52a0\u8f7d<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apache2ctl -M | grep php<br><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u82e5\u8f93\u51fa\u5305\u542b <code>php_module (shared)<\/code>\uff0c\u8868\u793a\u5df2\u6b63\u786e\u542f\u7528 mod_php\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udfe2 7. \u914d\u7f6e Apache \u9ed8\u8ba4\u7ad9\u70b9<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6 <code>\/etc\/apache2\/sites-available\/000-default.conf<\/code>\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo nano \/etc\/apache2\/sites-available\/000-default.conf<br><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5199\u5165\u4ee5\u4e0b\u5185\u5bb9\uff08\u793a\u4f8b\uff09\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>&lt;VirtualHost *:80&gt;<br>    ServerAdmin webmaster@localhost<br>    DocumentRoot \/var\/www\/html<br><br>    &lt;Directory \/var\/www\/html\/&gt;<br>        AllowOverride All<br>        Require all granted<br>    &lt;\/Directory&gt;<br><br>    ErrorLog ${APACHE_LOG_DIR}\/error.log<br>    CustomLog ${APACHE_LOG_DIR}\/access.log combined<br>&lt;\/VirtualHost&gt;<br><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4fdd\u5b58\u540e\u9000\u51fa\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udfe2 8. \u542f\u7528\u7ad9\u70b9\u914d\u7f6e\u53ca\u5fc5\u8981\u6a21\u5757<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo a2ensite 000-default.conf<br>sudo a2enmod rewrite headers env dir mime setenvif<br>sudo systemctl restart apache2<br><\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udfe2 9. \u786e\u4fdd\u6743\u9650\u6b63\u786e<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo chown -R www-data:www-data \/var\/www\/html<br>sudo find \/var\/www\/html -type d -exec chmod 755 {} \\;<br>sudo find \/var\/www\/html -type f -exec chmod 644 {} \\;<br><\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udfe2 10. \u9a8c\u8bc1\u8bbf\u95ee<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u6d4f\u89c8\u5668\u8bbf\u95ee\u670d\u52a1\u5668 IP \u6216\u57df\u540d\uff0c\u82e5\u663e\u793a Apache \u9ed8\u8ba4\u9875\u9762\uff08&#8221;It works!&#8221;\uff09\uff0c\u8bf4\u660e Apache &amp; PHP \u5df2\u91cd\u7f6e\u5b8c\u6210\uff0c\u53ef\u7ee7\u7eed\u90e8\u7f72\u6216\u6062\u590d\u7f51\u7ad9\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2705 \u603b\u7ed3<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u53ef\u5feb\u901f\u6062\u590d\u4e00\u4e2a\u5e72\u51c0\u3001\u7a33\u5b9a\u7684 Apache + PHP \u73af\u5883\uff0c\u4fdd\u7559\u6570\u636e\u5e93\u53ca\u7f51\u7ad9\u6587\u4ef6\uff0c\u9002\u5408\u7528\u4e8e\u4fee\u590d\u73af\u5883\u6df7\u4e71\u3001\u91cd\u590d\u914d\u7f6e\u9519\u8bef\u7b49\u60c5\u51b5\u3002\u540e\u7eed\u53ef\u91cd\u65b0\u90e8\u7f72\u5982 WordPress\u3001Nextcloud \u7b49\u5e94\u7528\uff0c\u6216\u8005\u6267\u884c\u5176\u4ed6\u7f51\u7ad9\u6062\u590d\u64cd\u4f5c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u957f\u671f\u7ef4\u62a4 Linux \u670d\u52a1\u5668\uff08\u5982 Debian \u6216 Ubuntu\uff09\u73af\u5883\u65f6\uff0cApache \u548c PHP \u7ecf\u8fc7\u591a\u6b21\u914d\u7f6e\u3001\u5207\u6362\u6a21\u5757\u3001\u5b89\u88c5\u6269\u5c55\u540e\uff0c\u5f80\u5f80\u4f1a\u51fa\u73b0\u914d\u7f6e\u6df7\u4e71\u3001\u51b2\u7a81\u3001\u6216\u65e0\u6cd5\u6b63\u5e38\u89e3\u6790 PHP \u6587\u4ef6\u7684\u95ee\u9898\u3002\u4e3a\u4e86\u5feb\u901f\u6062\u590d\u4e00\u4e2a\u5e72\u51c0\u3001\u53ef\u63a7\u7684\u73af\u5883\uff0c\u53ef\u91c7\u7528\u300c\u5378\u8f7d\u91cd\u88c5\u300d\u65b9\u5f0f\u5f7b\u5e95\u91cd\u7f6e Apache \u548c PHP\uff0c\u4ec5\u4fdd\u7559\u5fc5\u8981\u7684\u6587\u4ef6\u548c\u6570\u636e\u5e93\u3002 \u4ee5\u4e0b\u4e3a\u901a\u7528\u91cd\u7f6e\u6b65\u9aa4\uff0c\u9002\u7528\u4e8e\u9700\u8981\u6e05\u7406\u5386\u53f2\u914d\u7f6e\u3001\u89e3\u51b3\u89e3\u6790\u6df7\u4e71\u3001\u91cd\u65b0\u90e8\u7f72\u5e94\u7528\u573a\u666f\u3002 \u2705 \u6ce8\u610f\u4e8b\u9879 \ud83d\udd25 \u91cd\u7f6e\u6b65\u9aa4 \ud83d\udfe2 1. \u5378\u8f7d Apache sudo apt remove &#8211;purge apache2 apache2-utils apache2-bin apache2.2-common -y \u6e05\u7406 Apache \u914d\u7f6e\u6587\u4ef6\uff1a sudo rm -rf \/etc\/apache2 \ud83d\udfe2 2. \u5378\u8f7d PHP \u53ca\u6240\u6709\u6a21\u5757 sudo apt remove &#8211;purge php* -y &hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-4546","post","type-post","status-publish","format-standard","hentry","category-b4xus3fcwtqxdfj"],"_links":{"self":[{"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/posts\/4546","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/comments?post=4546"}],"version-history":[{"count":1,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/posts\/4546\/revisions"}],"predecessor-version":[{"id":4547,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/posts\/4546\/revisions\/4547"}],"wp:attachment":[{"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/media?parent=4546"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/categories?post=4546"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/tags?post=4546"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}