{"id":4583,"date":"2025-07-15T01:07:34","date_gmt":"2025-07-14T16:07:34","guid":{"rendered":"https:\/\/eternalsphere.net\/echoes\/?p=4583"},"modified":"2026-06-06T09:13:55","modified_gmt":"2026-06-06T00:13:55","slug":"qz8gav3p0bmr00t","status":"publish","type":"post","link":"https:\/\/eternalsphere.net\/echoes\/index.php\/2025\/07\/15\/qz8gav3p0bmr00t\/","title":{"rendered":"\u6062\u590d\u9ed8\u8ba4 Apache + PHP \u73af\u5883\u5e76\u6392\u67e5 WordPress \u6062\u590d\u5f02\u5e38\u5b8c\u6574\u6307\u5357"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u5728\u670d\u52a1\u5668\u8fc1\u79fb\u6216\u7f51\u7ad9\u6062\u590d\u8fc7\u7a0b\u4e2d\uff0c\u5e38\u89c1\u60c5\u51b5\u662f\u540c\u4e00\u5957 WordPress \u5907\u4efd\u5728\u5176\u4ed6\u73af\u5883\u4e2d\u53ef\u6b63\u5e38\u8fd0\u884c\uff0c\u4f46\u5728\u67d0\u4e00\u53f0\u7279\u5b9a\u670d\u52a1\u5668\u4e2d\u51fa\u73b0\u9875\u9762\u5f02\u5e38\u3002\u6b64\u95ee\u9898\u901a\u5e38\u5e76\u975e WordPress \u6587\u4ef6\u6216\u6570\u636e\u5e93\u672c\u8eab\u51fa\u9519\uff0c\u800c\u662f\u8be5\u670d\u52a1\u5668\u4e0a\u7684\u8f6f\u4ef6\u73af\u5883\u6216\u914d\u7f6e\u95ee\u9898\u6240\u5bfc\u81f4\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u672c\u6587\u603b\u7ed3\u5982\u4f55\u6062\u590d\u9ed8\u8ba4 Apache + PHP \u73af\u5883\uff0c\u5e76\u7cfb\u7edf\u6392\u67e5\u53ef\u80fd\u5f15\u53d1 WordPress \u9875\u9762\u5f02\u5e38\u7684\u5e38\u89c1\u539f\u56e0\uff0c\u4f9b\u53c2\u8003\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udfe2 \u6062\u590d\u9ed8\u8ba4 Apache + PHP \u73af\u5883<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u5378\u8f7d Apache \u4e0e PHP<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u9996\u5148\uff0c\u5f7b\u5e95\u5378\u8f7d Apache \u4e0e PHP \u6240\u6709\u76f8\u5173\u8f6f\u4ef6\u5305\u53ca\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt remove --purge apache2* php* libapache2-mod-php* -y<br>apt autoremove -y<br>rm -rf \/etc\/apache2<br>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\">\u91cd\u65b0\u5b89\u88c5 Apache<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt update<br>apt install apache2 -y<br><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6b64\u65f6\u4f1a\u6062\u590d\u9ed8\u8ba4\u865a\u62df\u4e3b\u673a\uff0cDocumentRoot \u8def\u5f84\u4e3a <code>\/var\/www\/html<\/code>\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">\u91cd\u65b0\u5b89\u88c5 PHP \u53ca\u5e38\u7528\u6269\u5c55<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">WordPress \u4f9d\u8d56\u591a\u4e2a\u5e38\u7528 PHP \u6269\u5c55\uff0c\u5efa\u8bae\u4e00\u6b21\u6027\u5b89\u88c5\u4ee5\u4e0b\u5e38\u89c1\u7ec4\u4ef6\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt install php libapache2-mod-php php-mysql php-xml php-gd php-curl php-mbstring php-zip php-fpm php-intl php-bcmath unzip wget -y<br><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u542f\u7528\u5fc5\u8981\u6a21\u5757\u5e76\u91cd\u542f Apache\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>a2enmod rewrite<br>a2enmod php<br>systemctl restart apache2<br><\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udfe2 WordPress \u6062\u590d\u540e\u5f02\u5e38\u6392\u67e5\u6e05\u5355<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f53 WordPress \u5728\u5176\u4ed6\u4e3b\u673a\u6b63\u5e38\uff0c\u552f\u72ec\u5728\u67d0\u53f0\u4e3b\u673a\u5f02\u5e38\uff0c\u901a\u5e38\u662f\u73af\u5883\u914d\u7f6e\u6216\u6587\u4ef6\u6743\u9650\u95ee\u9898\uff0c\u53ef\u53c2\u8003\u4ee5\u4e0b\u6392\u67e5\u6d41\u7a0b\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">1\ufe0f\u20e3 \u68c0\u67e5 PHP \u7248\u672c\u4e0e\u6269\u5c55<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b PHP \u7248\u672c\u4e0e\u5df2\u542f\u7528\u6269\u5c55\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>php -v<br>php -m<br><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u786e\u4fdd\u7248\u672c\u6ee1\u8db3 WordPress \u8981\u6c42\uff08\u5efa\u8bae 7.4 \u4ee5\u4e0a\uff09\uff0c\u5e76\u5305\u542b\u4ee5\u4e0b\u5fc5\u8981\u6269\u5c55\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>mysqli<\/li>\n\n\n\n<li>gd<\/li>\n\n\n\n<li>mbstring<\/li>\n\n\n\n<li>curl<\/li>\n\n\n\n<li>zip<\/li>\n\n\n\n<li>intl<\/li>\n\n\n\n<li>bcmath<\/li>\n\n\n\n<li>xml<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">2\ufe0f\u20e3 \u68c0\u67e5 Apache \u6a21\u5757<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u67e5\u770b Apache \u5df2\u542f\u7528\u7684\u6a21\u5757\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apache2ctl -M<br><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u786e\u4fdd <code>rewrite_module<\/code> \u6a21\u5757\u5df2\u542f\u7528\uff0c\u5426\u5219\u4f1a\u5f71\u54cd WordPress \u6c38\u4e45\u94fe\u63a5\uff08\u6f02\u4eae URL\uff09\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">3\ufe0f\u20e3 \u68c0\u67e5\u6587\u4ef6\u6743\u9650<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u67e5\u770b WordPress \u6587\u4ef6\u5939\u6743\u9650\u4e0e\u6240\u5c5e\u7528\u6237\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ls -l \/var\/www\/html<br><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u82e5\u6743\u9650\u4e0d\u6b63\u786e\uff0c\u53ef\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4fee\u6b63\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>chown -R www-data:www-data \/var\/www\/html<br>find \/var\/www\/html -type d -exec chmod 755 {} \\;<br>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\">4\ufe0f\u20e3 \u68c0\u67e5 .htaccess \u6587\u4ef6<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u786e\u8ba4\u6839\u76ee\u5f55\u4e0b\u662f\u5426\u5b58\u5728 <code>.htaccess<\/code> \u6587\u4ef6\uff0c\u5e76\u5305\u542b\u4ee5\u4e0b WordPress \u9ed8\u8ba4 rewrite \u89c4\u5219\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code># BEGIN WordPress<br>&lt;IfModule mod_rewrite.c&gt;<br>RewriteEngine On<br>RewriteBase \/<br>RewriteRule ^index\\.php$ - [L]<br>RewriteCond %{REQUEST_FILENAME} !-f<br>RewriteCond %{REQUEST_FILENAME} !-d<br>RewriteRule . \/index.php [L]<br>&lt;\/IfModule&gt;<br># END WordPress<br><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u6709\u7f3a\u5931\uff0c\u53ef\u65b0\u5efa\u6216\u8865\u5145\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">5\ufe0f\u20e3 \u68c0\u67e5\u6570\u636e\u5e93\u914d\u7f6e<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u786e\u8ba4 <code>wp-config.php<\/code> \u4e2d\u6570\u636e\u5e93\u4fe1\u606f\uff08DB_HOST\u3001DB_NAME\u3001DB_USER\u3001DB_PASSWORD\uff09\u4e0e\u8be5\u4e3b\u673a\u6570\u636e\u5e93\u4e00\u81f4\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">6\ufe0f\u20e3 \u67e5\u770b\u6d4f\u89c8\u5668\u63a7\u5236\u53f0\u9519\u8bef<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u901a\u8fc7\u6d4f\u89c8\u5668\u5f00\u53d1\u8005\u5de5\u5177\uff08F12\uff09\u67e5\u770b Console \u548c Network\uff0c\u6392\u67e5\u662f\u5426\u5b58\u5728 404\u3001403\u3001500 \u7b49\u9519\u8bef\u8bf7\u6c42\uff0c\u6216\u9759\u6001\u8d44\u6e90\u52a0\u8f7d\u5931\u8d25\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">7\ufe0f\u20e3 \u67e5\u770b\u9519\u8bef\u65e5\u5fd7<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u67e5\u770b Apache \u6216 PHP \u9519\u8bef\u65e5\u5fd7\uff0c\u53ef\u5feb\u901f\u5b9a\u4f4d\u5185\u90e8\u9519\u8bef\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>tail -f \/var\/log\/apache2\/error.log<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6216<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>tail -f \/var\/log\/php*\/error.log<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udfe2 Apache \u662f\u5426\u9700\u8981 php-fpm<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728 Apache \u73af\u5883\u4e2d\uff0c\u53ef\u901a\u8fc7\u4e24\u79cd\u65b9\u5f0f\u8fd0\u884c PHP\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>mod_php\uff08libapache2-mod-php\uff09<\/strong><br>\u901a\u8fc7 Apache \u5185\u5efa\u6a21\u5757\u76f4\u63a5\u5904\u7406 PHP\uff0c\u7b80\u5355\u3001\u5e38\u7528\u3001\u65e0\u9700 php-fpm\u3002<\/li>\n\n\n\n<li><strong>php-fpm\uff08FastCGI Process Manager\uff09<\/strong><br>\u901a\u8fc7\u72ec\u7acb\u8fdb\u7a0b\u8fd0\u884c PHP\uff0cApache \u901a\u8fc7 <code>proxy_fcgi<\/code> \u6a21\u5757\u8f6c\u53d1\u8bf7\u6c42\uff0c\u9002\u5408\u591a\u7ad9\u70b9\u3001\u591a\u7248\u672c\u6216\u9700\u8981\u66f4\u7ec6\u7c92\u5ea6\u8d44\u6e90\u63a7\u5236\u7684\u573a\u666f\u3002<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u5bf9\u4e8e\u591a\u6570\u5355\u7ad9\u6216\u4e00\u822c\u573a\u666f\uff0c\u4ec5\u4f7f\u7528 mod_php \u5373\u53ef\uff0c\u65e0\u9700 php-fpm\uff0c\u4e14\u4e0e WordPress 100% \u517c\u5bb9\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udfe2 \u603b\u7ed3<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u7279\u5b9a\u4e3b\u673a\u4e2d\uff0cWordPress \u8fd8\u539f\u540e\u9875\u9762\u5f02\u5e38\u901a\u5e38\u662f\u7cfb\u7edf\u73af\u5883\u95ee\u9898\uff0c\u5305\u62ec PHP \u6269\u5c55\u7f3a\u5931\u3001\u6a21\u5757\u672a\u542f\u7528\u3001\u6587\u4ef6\u6743\u9650\u9519\u8bef\u3001\u914d\u7f6e\u4e0d\u4e00\u81f4\u7b49\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u901a\u8fc7\u7cfb\u7edf\u6392\u67e5\u8f6f\u4ef6\u5305\u3001Apache \u6a21\u5757\u3001PHP \u6269\u5c55\u3001\u6743\u9650\u4e0e\u914d\u7f6e\u6587\u4ef6\uff0c\u53ef\u5feb\u901f\u5b9a\u4f4d\u5e76\u89e3\u51b3\u95ee\u9898\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u670d\u52a1\u5668\u8fc1\u79fb\u6216\u7f51\u7ad9\u6062\u590d\u8fc7\u7a0b\u4e2d\uff0c\u5e38\u89c1\u60c5\u51b5\u662f\u540c\u4e00\u5957 WordPress \u5907\u4efd\u5728\u5176\u4ed6\u73af\u5883\u4e2d\u53ef\u6b63\u5e38\u8fd0\u884c\uff0c\u4f46\u5728\u67d0\u4e00\u53f0\u7279\u5b9a\u670d\u52a1\u5668\u4e2d\u51fa\u73b0\u9875\u9762\u5f02\u5e38\u3002\u6b64\u95ee\u9898\u901a\u5e38\u5e76\u975e WordPress \u6587\u4ef6\u6216\u6570\u636e\u5e93\u672c\u8eab\u51fa\u9519\uff0c\u800c\u662f\u8be5\u670d\u52a1\u5668\u4e0a\u7684\u8f6f\u4ef6\u73af\u5883\u6216\u914d\u7f6e\u95ee\u9898\u6240\u5bfc\u81f4\u3002 \u672c\u6587\u603b\u7ed3\u5982\u4f55\u6062\u590d\u9ed8\u8ba4 Apache + PHP \u73af\u5883\uff0c\u5e76\u7cfb\u7edf\u6392\u67e5\u53ef\u80fd\u5f15\u53d1 WordPress \u9875\u9762\u5f02\u5e38\u7684\u5e38\u89c1\u539f\u56e0\uff0c\u4f9b\u53c2\u8003\u3002 \ud83d\udfe2 \u6062\u590d\u9ed8\u8ba4 Apache + PHP \u73af\u5883 \u5378\u8f7d Apache \u4e0e PHP \u9996\u5148\uff0c\u5f7b\u5e95\u5378\u8f7d Apache \u4e0e PHP \u6240\u6709\u76f8\u5173\u8f6f\u4ef6\u5305\u53ca\u914d\u7f6e\u6587\u4ef6\uff1a apt remove &#8211;purge apache2* php* libapache2-mod-php* -yapt autoremove -yrm -rf \/etc\/apache2rm -rf \/etc\/php \u91cd\u65b0\u5b89\u88c5 Apache apt updateapt install apache2 -y \u6b64\u65f6\u4f1a\u6062\u590d\u9ed8\u8ba4\u865a\u62df\u4e3b\u673a\uff0cDocumentRoot \u8def\u5f84\u4e3a \/var\/www\/html\u3002 &hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[58],"tags":[],"class_list":["post-4583","post","type-post","status-publish","format-standard","hentry","category-b7fum8vqsuspg2y"],"_links":{"self":[{"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/posts\/4583","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=4583"}],"version-history":[{"count":1,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/posts\/4583\/revisions"}],"predecessor-version":[{"id":4584,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/posts\/4583\/revisions\/4584"}],"wp:attachment":[{"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/media?parent=4583"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/categories?post=4583"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/tags?post=4583"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}