<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>WordPress外贸站403 &#8211; 外贸服务器代维护工作室</title>
	<atom:link href="https://www.fuwuqi120.com/tag/wordpress%e5%a4%96%e8%b4%b8%e7%ab%99403/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.fuwuqi120.com</link>
	<description>｜外贸网站服务器代维：阿里云 ECS、AWS EC2、Linux、宝塔面板、WordPress 独立站托管与排障。</description>
	<lastBuildDate>Wed, 25 Nov 2026 18:02:38 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>nginx 403 forbidden 原因与外贸站排查</title>
		<link>https://www.fuwuqi120.com/nginx-403-forbidden-%e5%8e%9f%e5%9b%a0%e4%b8%8e%e5%a4%96%e8%b4%b8%e7%ab%99%e6%8e%92%e6%9f%a5/</link>
					<comments>https://www.fuwuqi120.com/nginx-403-forbidden-%e5%8e%9f%e5%9b%a0%e4%b8%8e%e5%a4%96%e8%b4%b8%e7%ab%99%e6%8e%92%e6%9f%a5/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Wed, 25 Nov 2026 18:02:38 +0000</pubDate>
				<category><![CDATA[linux服务器代维]]></category>
		<category><![CDATA[AWS EC2 nginx]]></category>
		<category><![CDATA[nginx 403 forbidden 原因]]></category>
		<category><![CDATA[WordPress外贸站403]]></category>
		<category><![CDATA[宝塔面板403]]></category>
		<category><![CDATA[阿里云ECS权限]]></category>
		<guid isPermaLink="false">https://www.fuwuqi120.com/nginx-403-forbidden-%e5%8e%9f%e5%9b%a0%e4%b8%8e%e5%a4%96%e8%b4%b8%e7%ab%99%e6%8e%92%e6%9f%a5/</guid>

					<description><![CDATA[nginx 403 forbidden 多数是目录权限、index 文件缺失、SELinux/AppArmor、deny 规则或伪静态拦截；先看错误日志，再改权限和站点配置，海外客户才能正常打开产品页。]]></description>
										<content:encoded><![CDATA[<div class="fuwuqi120-answer">
<p><strong>一句话答案：</strong>nginx 403 forbidden 多数是目录权限、index 文件缺失、SELinux/AppArmor、deny 规则或伪静态拦截；先看错误日志，再改权限和站点配置，海外客户才能正常打开产品页。</p>
</div>
<div class="fuwuqi120-toc">
<p><strong>本文目录</strong></p>
<ol>
<li><a href="#fuwuqi120-h2-1">先给结论：403 不是宕机，是 Nginx 拒绝读文件</a></li>
<li><a href="#fuwuqi120-h2-2">它解决什么问题：分清「客户打不开」和「被防火墙挡了」</a></li>
<li><a href="#fuwuqi120-h2-3">第一类实操：属主、权限、index 一次修到位</a></li>
<li><a href="#fuwuqi120-h2-4">第二类实操：deny、伪静态、SELinux 三类拦截</a></li>
<li><a href="#fuwuqi120-h2-5">迁移和备份回滚时最容易复发的几个点</a></li>
<li><a href="#fuwuqi120-h2-6">注意什么：别用 777 收尾，也别把 403 当被黑</a></li>
</ol>
</div>
<h2 id="fuwuqi120-h2-1">先给结论：403 不是宕机，是 Nginx 拒绝读文件</h2>
<p><strong>403 不是宕机，是 Nginx 拒绝读文件。</strong>端口通、TLS 多半也通，请求已经到了 worker 进程，卡在文件系统或规则层。</p>
<p>页面原文一般是「403 Forbidden」加一行「nginx/1.24.0」，版本号随环境变，1.20.1、1.22.1 我都见过。外贸站的表现很固定：首页能开，<code>/wp-admin/</code>、<code>/product/</code>、<code>/wp-content/uploads/</code> 里某一个或几个打不开。欧美客户刷产品页报 403，你本地用 IP 直连又正常，这种差异常常是解析落到了旧节点，或者那台机器上的目录属主没跟上迁移。</p>
<p>我接过的迁移单里，大概 6 成是打包解包后属主变成 <code>root:root</code>，Nginx worker 跑的是 <code>www-data</code>（Debian/Ubuntu）或 <code>www</code>（宝塔 CentOS 环境），读不到就直接拒。另外 2 成是站点根目录少了 <code>index.php</code> / <code>index.html</code>，目录又没开 autoindex，Nginx 只能回 403。剩下的才轮到 SELinux、AppArmor、<code>deny</code> 规则和伪静态拦截。</p>
<p>先做 30 秒判断，别猜。在出问题的那台 ECS / EC2 上，用 root 或 sudo 执行下面两条，看错误日志最后一行落在哪一类：</p>
<pre><code># 目标服务器：出问题的 ECS / EC2，root 或 sudo 身份
tail -n 30 /var/log/nginx/error.log
curl -I https://你的域名/product/ --resolve 你的域名:443:服务器公网IP</code></pre>
<p><code>--resolve</code> 是绕开本地 DNS 直接压到指定公网 IP，迁移后 DNS 还没全量生效时特别管用。日志关键词对照如下：</p>
<table>
<tr>
<th>日志最后一行</th>
<th>实际卡点</th>
<th>外贸站常见触发场景</th>
</tr>
<tr>
<td><code>permission denied</code></td>
<td>属主 / 权限</td>
<td>tar 解包后 <code>root:root</code>，产品图 <code>/wp-content/uploads/</code> 全挂</td>
</tr>
<tr>
<td><code>directory index of "..." is forbidden</code></td>
<td>缺 index 文件</td>
<td>只传了 <code>wp-content</code>，漏了 <code>index.php</code></td>
</tr>
<tr>
<td><code>access forbidden by rule</code></td>
<td>deny / 伪静态</td>
<td>防刷规则把 <code>/wp-admin/</code> 或支付回调路径一起拦了</td>
</tr>
</table>
<p>别先重启 Nginx。重启改不了属主，也改不了 <code>deny</code> 规则，我见过有人连重启 4 次，把 PayPal 回调窗口错过去，订单状态卡在待确认一整晚。真要动，先按日志定类，再改权限或站点配置。</p>
<ul>
<li>属主类：目录 <code>755</code>、文件 <code>644</code>，属主对齐 worker 用户，宝塔机通常是 <code>www:www</code>，别整站 <code>777</code>。</li>
<li>index 类：确认 <code>root</code> 指到的是含 <code>index.php</code> 的那一层，多站点迁移最容易指错一级目录。</li>
<li>规则类：先看 <code>location</code> 里的 <code>deny all;</code> 和伪静态 <code>try_files</code>，海外 CDN 回源 IP 段被误拦也归这一类。</li>
</ul>
<p>SELinux 那类在 RHEL / AlmaLinux 上会额外报 <code>avc: denied</code>，日志不在 nginx 的 error.log 里，得翻 <code>/var/log/audit/audit.log</code>。AppArmor 同理看 <code>dmesg</code>。这两项我放到后面第 4 节展开，这里先把日志最后一行认出来就够了。</p>
<h2 id="fuwuqi120-h2-2">它解决什么问题：分清「客户打不开」和「被防火墙挡了」</h2>
<p>先分清回绝和连不上，403 只算前者。</p>
<p>欧美客户丢过来一句「打不开」，东南亚客户说转圈半天，这两种我接到的工单里，至少一半最后不是 Nginx 的问题。403 是源站已经收到请求、读到了配置，然后明确回了一句「不给看」。安全组没放行、CDN 回源握手失败、节点到源站丢包，客户端拿不到这个状态码，看到的是连接超时、<strong>502</strong> 或者 <strong>524</strong>。这个区别决定了你半夜该去翻 error_log，还是去查安全组和 CDN 回源配置。</p>
<table>
<tr>
<th>客户看到的现象</th>
<th>大概率位置</th>
<th>先动哪里</th>
</tr>
<tr>
<td>nginx 403 forbidden 白底黑字</td>
<td>源站目录权限 / index / deny / 伪静态</td>
<td>Nginx error_log、站点目录</td>
</tr>
<tr>
<td>524、连接超时、一直转圈</td>
<td>CDN 回源、安全组、线路</td>
<td>回源 IP 白名单、443 放行</td>
</tr>
<tr>
<td>502 / 504</td>
<td>回源到 PHP-FPM 或上游断掉</td>
<td>php-fpm 状态、upstream 日志</td>
</tr>
</table>
<p>阿里云 ECS 新加坡节点跑东南亚，<a href="https://www.fuwuqi120.com/tag/aws-ec2/">AWS EC2</a> us-east-1 跑欧美，我手上这类站延迟大概差 80–180ms，但<strong>线路只改快慢，不改 403 的判定</strong>。CDN 套了一层之后更容易误判，边缘节点缓存了旧的 403 也会骗人。本地电脑或跳板机用普通用户执行，<code>--resolve</code> 把域名直接绑到源站公网 IP，绕开 CDN 看真实响应：</p>
<pre><code># 本地电脑或跳板机，普通用户执行；把 1.2.3.4 换成源站公网 IP
curl -I --resolve '你的域名:443:1.2.3.4' https://你的域名/wp-json/ --max-time 10
curl -I -A 'Mozilla/5.0' https://你的域名/wp-json/
curl -I https://你的域名/wp-content/uploads/2025/06/main.jpg</code></pre>
<p>第一条直连源站还是 403，就别再折腾 CDN 了。第二条和第三条走正常域名，用来对照边缘节点有没有缓存旧响应。静态图 <code>main.jpg</code> 也 403，基本锁定 <code>wp-content/uploads/</code> 目录权限或 SELinux 上下文，我一般先按 755 目录、644 文件恢复，不会一上来改伪静态。</p>
<ul>
<li>静态图 403、首页也 403：查目录权限、index.php 是否存在、deny 规则。</li>
<li>只有 <code>?wc-ajax=</code>、<code>/wp-json/</code> 这类带参数的 URL 403：往伪静态、WAF 规则、Nginx 1.24 里的 location 匹配查。</li>
<li>直连源站 200、走 CDN 403：清缓存 + 查回源 Host，别动服务器文件。</li>
</ul>
<p>WordPress 独立站里最怕的不是首页 403，是结账页和支付回调。Stripe / PayPal 的 webhook 撞上 403，重试窗口很短，订单会卡在「待付款」，客户那边信用卡已经扣了。这类单我一般 <strong>15 分钟内先恢复读权限</strong>，把订单状态补回来，再慢慢查是哪条规则误杀。代维按月 800–2500 元的区间里，大半价值就在这个响应速度上，不是装个面板。</p>
<h2 id="fuwuqi120-h2-3">第一类实操：属主、权限、index 一次修到位</h2>
<p>先按运行用户改属主，再统一 755/644，最后确认 index 和 root。</p>
<p>这一步能修掉我经手的外贸站 403 里大概七成。剩下的多是 SELinux 或配置拦截，后面单独讲。别一上来就 <strong>chmod 777</strong>，欧美客户能打开首页了，支付回调目录也跟着裸了，我 2019 年在一个 Magento 站上踩过，后来被塞了 3 个 webshell。</p>
<p>30 秒判断：在目标服务器用 root 看一眼进程用户和日志尾巴。日志出现 <code>directory index of "/var/www/yourshop.com/" is forbidden</code>，就是首页文件没了；出现 <code>permission denied</code> 或者 <code>13: Permission denied</code>，先动属主。</p>
<table>
<tr>
<th>环境</th>
<th>Nginx / PHP 运行用户</th>
<th>常见站点根</th>
</tr>
<tr>
<td><a href="https://www.fuwuqi120.com/tag/%e5%ae%9d%e5%a1%94%e9%9d%a2%e6%9d%bf/">宝塔面板</a> CentOS 7 / Ubuntu 22.04</td>
<td><strong>www</strong></td>
<td>/www/wwwroot/yourshop.com</td>
</tr>
<tr>
<td>Nginx 官方包 Debian 12 / Ubuntu 22.04</td>
<td><strong>www-data</strong></td>
<td>/var/www/yourshop.com</td>
</tr>
<tr>
<td>AWS Amazon Linux 2023 EC2</td>
<td><strong>nginx</strong></td>
<td>/var/www/yourshop.com 或 /usr/share/nginx/html</td>
</tr>
</table>
<p>用户认错，权限改得再整齐也等于没改。AWS 那台我见过有人照宝塔教程 chown 成 www，结果首页 403、wp-admin 却偶尔能进，查了 40 分钟才发现是 AL2023 自带包跑 nginx 用户。</p>
<p>目录 <strong>755</strong>、文件 <strong>644</strong> 是底线。<code>wp-config.php</code> 收到 600 没问题，数据库账号不该被同机其他站点读到。但别把整个 <code>wp-content/uploads</code> 设成 700，海外客户拉产品图会批量 403，Google 抓图也全掉，独立站最怕这个。</p>
<ul>
<li>迁移站优先核对 <code>root</code>。我一般会顺手 grep 一遍，还写着 <code>/home/old_site</code> 的话，属主再对也是 403，旧目录早空了。</li>
<li>缺 index.php 就补文件，不要加 <code>autoindex on</code>。开了目录列表，产品原图路径、未发布的 SKU 目录会被爬虫整批收走。</li>
<li>reload 前必须 <code>nginx -t</code>。跨洋连着 SSH 改配置，语法错一下直接全站断，比 403 更难跟客户解释。</li>
</ul>
<p>下面这组在<strong>目标服务器、root 身份</strong>执行。路径按实际站点根替换，宝塔机把第二条之后的 <code>/var/www/yourshop.com</code> 换成 <code>/www/wwwroot/yourshop.com</code>；AL2023 把属主改成 <code>nginx:nginx</code>。</p>
<pre><code>ps -eo user,comm | grep -E 'nginx|php-fpm' | head
chown -R www:www /www/wwwroot/yourshop.com 2&gt;/dev/null || chown -R www-data:www-data /var/www/yourshop.com
find /var/www/yourshop.com -type d -exec chmod 755 {} ;
find /var/www/yourshop.com -type f -exec chmod 644 {} ;
ls -l /var/www/yourshop.com/index.php
nginx -t &amp;&amp; systemctl reload nginx</code></pre>
<p>顺手补一条查旧 root 的命令，同样 root 身份：</p>
<pre><code>grep -rnE '^s*roots+' /etc/nginx/conf.d/ /etc/nginx/sites-enabled/ /www/server/panel/vhost/nginx/ 2&gt;/dev/null | grep -i yourshop</code></pre>
<p>改完别只在本机 curl。用欧美节点和新加坡节点各打一次首页加一张 uploads 里的图，返回 200 再收工。东南亚线路偶尔会命中另一台回源机，那台没同步属主的话，照样 403。这个不同步我遇到过两次，都是迁移完只改了主节点。</p>
<h2 id="fuwuqi120-h2-4">第二类实操：deny、伪静态、SELinux 三类拦截</h2>
<p>配置拦截先看 deny、伪静态、SELinux，三类都常让外贸站报 403。</p>
<p>权限改完还是 403，我一般不会继续动 chmod。先翻站点 vhost。宝塔面板开过「防跨站攻击」，或者之前为了锁后台加过 <strong>allow 127.0.0.1; deny all;</strong>，海外办公 IP 一换，运营自己就进不去 /wp-admin，欧美客户访问产品页也可能直接吃 403。这类规则不挑文件属主，匹配到就拒。</p>
<p>30 秒判断：只开首页正常，点 <strong>/product/sku-1024</strong> 变 403，八成是伪静态。WordPress 固定链接靠 try_files 回落到 index.php，少了 <code>$uri/</code>，或者末尾没写 <code>/index.php?$args</code>，Nginx 会去当目录读，目录又没 index，直接拒绝。我处理过的迁移站里，从旧主机搬配置漏这一行的比例不低。</p>
<p>目标服务器、root 身份执行，一次把线索捞出来：</p>
<pre><code>grep -RniE 'deny|allow|autoindex|try_files|root ' /etc/nginx/conf.d/ /etc/nginx/sites-enabled/ /www/server/panel/vhost/nginx/ 2&gt;/dev/null
getenforce 2&gt;/dev/null || echo 'no SELinux'
ausearch -m avc -ts recent 2&gt;/dev/null | tail -n 10
sed -i 's/^SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config 2&gt;/dev/null
setenforce 0 2&gt;/dev/null
nginx -t &amp;&amp; systemctl reload nginx</code></pre>
<p>那条 sed 只改了重启后的策略，<code>setenforce 0</code> 才是当场生效。验证完别就这么交差，长期关掉我不建议，补回标签更稳：</p>
<pre><code>chcon -R -t httpd_sys_rw_content_t /www/wwwroot/yourdomain.com/wp-content/uploads/
setenforce 1
getenforce</code></pre>
<table>
<tr>
<th>系统 / 场景</th>
<th>403 线索在哪</th>
<th>处理方式</th>
</tr>
<tr>
<td>CentOS 7 / AlmaLinux 8</td>
<td>nginx error.log 可能空白，看 /var/log/audit/audit.log 的 avc denied</td>
<td>临时 setenforce 0 验证，再 chcon uploads，最后设回 1</td>
</tr>
<tr>
<td>Ubuntu 22.04</td>
<td>aa-status | grep nginx，日志常落 /var/log/syslog 或 journalctl</td>
<td>改 profile 或放行站点目录，别直接删 profile</td>
</tr>
<tr>
<td>宝塔 + WordPress</td>
<td>/www/server/panel/vhost/nginx/ 下的防跨站、try_files</td>
<td>删掉误加的 deny all，补 $uri/ 与 /index.php?$args</td>
</tr>
</table>
<p>Ubuntu 那条命令单独跑，目标服务器 root：</p>
<pre><code>aa-status | grep nginx
journalctl -k --since '10 min ago' | grep -i apparmor | tail -n 10</code></pre>
<p>这个坑我在一台 AWS EC2 上踩过。Ubuntu 22.04，站点目录 755、文件 644、属主 www-data 全对，error.log 干净，新加坡客户还是 403。最后在 AppArmor 的 DENIED 里找到路径，站点从 /home 迁到 /var/www 后 profile 没跟着改。海外节点排查时别只盯跨境线路，本机 LSM 一样会拦。</p>
<ul>
<li>改配置前先 <code>cp 站点.conf 站点.conf.bak.$(date +%F)</code>，回滚只要 10 秒。</li>
<li>每次只动一类：<strong>deny 规则 → reload → 测固定链接 → 再查 SELinux/AppArmor</strong>，混着改就分不清是谁拦的。</li>
<li>用境外机器复测，别只在国内 curl：<code>curl -I -A 'Mozilla/5.0' https://你的域名/product/sku-1024</code>，返回 200 再收工。</li>
</ul>
<h2 id="fuwuqi120-h2-5">迁移和备份回滚时最容易复发的几个点</h2>
<p>迁移回滚后复发 403，多半是旧 uid 残留或 CDN 缓存了旧响应。</p>
<p>我接外贸站迁移，十次里有三四次栽在打包参数上。旧 ECS 上用 <strong>tar &#8211;numeric-owner</strong> 留了数字属主，解到新机不会自动映射名字。旧机站点用户是 uid 1002，新机 Debian/Ubuntu 的 www-data 是 uid 33，Nginx worker 拿 33 去读 1002 的 uploads 目录，直接拒。产品图、PDF 规格书全 403，首页却正常，海外客户半夜发截图过来就是这种样子。</p>
<p>解包完别急着 reload，先 stat 看一眼数字。只要不是 33:33，重跑一次 chown 再收尾，比翻配置快得多。</p>
<table>
<tr>
<th>现象</th>
<th>真实位置</th>
<th>30 秒判断</th>
</tr>
<tr>
<td>首页 200、产品图 403</td>
<td>新机文件属主</td>
<td><code>stat -c '%u:%g %n'</code> 看是不是 1002</td>
</tr>
<tr>
<td>源站 curl 200、浏览器仍 403</td>
<td>CDN / 对象存储回源缓存</td>
<td>带 <code>?v=202506</code> 再请求一次</td>
</tr>
<tr>
<td>支付页先弹证书告警</td>
<td>证书 SAN 不含支付子域</td>
<td>看浏览器证书详情，不是 Nginx 拒绝</td>
</tr>
</table>
<p>缓存这个坑我踩过。源站权限早修好了，浏览器还吐 403，我差点把 nginx.conf 又改一遍。对象存储回源那次更隐蔽，回源文件本身是旧机带 403 头存进去的，CDN 边缘节点按 TTL 300 秒到 1 天继续发。加个版本参数或清一次缓存就完，别动服务器。</p>
<p>还有两件顺手做的事：</p>
<ul>
<li>改站点配置前留底，<code>cp</code> 一份带日期到 /root，回滚比现场猜快。我一般保留最近 3 份，代维单里 200–500 元/次的回滚活基本都靠它。</li>
<li>备案只管国内 80/443 接入，不产生 403。外贸站放新加坡、法兰克福节点不用备案；但 checkout 子域要写进证书 SAN，不然欧美客户先撞证书告警，运营会报成「403 打不开」。</li>
</ul>
<p>目标服务器，root 身份，迁移收尾直接跑：</p>
<pre><code>tar --numeric-owner -xzf site_backup_20250612.tgz -C /var/www/
stat -c '%u:%g %n' /var/www/yourshop.com/wp-content/uploads | head
chown -R www-data:www-data /var/www/yourshop.com
find /var/www/yourshop.com/wp-content/uploads -type d -exec chmod 755 {} ;
curl -I -H 'Cache-Control: no-cache' https://你的域名/?v=202506
cp /etc/nginx/sites-enabled/yourshop.conf /root/yourshop.conf.bak.$(date +%F)</code></pre>
<p>最后那条 curl 要返回 200 才算收工。返回 403 就回 <code>/var/log/nginx/yourshop.error.log</code> 看当秒那行，别凭记忆改。CentOS 系换成 <code>nginx:nginx</code>，uid 不是 33，这点不确定就先 <code>id nginx</code> 查，别照抄。</p>
<h2 id="fuwuqi120-h2-6">注意什么：别用 777 收尾，也别把 403 当被黑</h2>
<p>别用 777 收尾，也别把 403 直接当成被黑，先按权限和配置查。</p>
<p>chmod -R 777 确实能让产品页立刻开。代价也直接：<strong>wp-config.php、uploads 目录全敞开</strong>，PHP 进程、同机其他站点、甚至一个上传漏洞都能写进去。我处理过的外贸站挂马单，不少就是前一天有人为了消 403 加了 777，第二天 Google 那边已经标了「此网站可能会损害您的计算机」，欧美客户连询盘页都不进。权限该是 755 / 644、属主 www-data 或 nginx，别图那一分钟。</p>
<p>被黑的样子通常不是 403。更常见的是首页跳到博彩站、<code>.user.ini</code> 里塞了 <code>auto_prepend_file</code>、wp-content 下多出 <code>cache.php</code> 这类陌生文件。单纯一个 403，先回错误日志看是 <code>permission denied</code> 还是 <code>directory index forbidden</code>。真怀疑有马，另跑近 48 小时改动，别和权限修复混在一起做。</p>
<ul>
<li>403 + 日志 <code>13: Permission denied</code>：属主 / SELinux，按前面第 3 节改。</li>
<li>403 + 日志 <code>directory index of "..." is forbidden</code>：缺 index.php 或 index 指令写漏。</li>
<li>首页 200、跳转、多出 .php：才按挂马走，<code>find /var/www -mtime -2 -name '*.php'</code>。</li>
<li>只有海外客户报 403、国内正常：先怀疑节点上的 deny 规则和 CDN 回源配置，不是马。</li>
</ul>
<p>收尾核查我一般在目标服务器、root 身份下一次性跑完，路径换成你自己的站：</p>
<pre><code># 目标服务器 / root 身份 / 收尾核查，把 yourshop.com 换成实际站点目录
find /var/www/yourshop.com -type d -perm 777 -print
find /var/www/yourshop.com -type f -perm 666 -print
grep -Rni 'auto_prepend_file' /var/www/yourshop.com/.user.ini /etc/php*/fpm/conf.d/ 2&gt;/dev/null
tail -n 5 /var/log/nginx/access.log

# 真要查近 48 小时新增/改动的 PHP，单独跑这一条
find /var/www -mtime -2 -name '*.php' -print</code></pre>
<p>前两条有输出就说明 777 / 666 还没清干净，回第 3 节按 755、644 重设。第三条命中 <code>auto_prepend_file</code>，先别删站，把文件时间和内容存一份再处理，迁移过来的老站经常是前一家代维留的。第四条看最后 5 条状态码，确认已经从 403 变 200。</p>
<p>费用这块给个实在区间，别被报懵：</p>
<table>
<tr>
<th>方式</th>
<th>常见区间</th>
<th>什么情况往上走</th>
</tr>
<tr>
<td>按次排 403 / 权限修复</td>
<td>300-800 元</td>
<td>要顺带查马、回滚备份、夜间开工</td>
</tr>
<tr>
<td>包年代维含这类故障响应</td>
<td>3000-9000 元/台</td>
<td>海外节点、多台 ECS、带 WAF、要求 2 小时内响应</td>
</tr>
</table>
<p>带不带 WAF、要不要夜间响应，差别挺大，不确定就别先报死数。我一般先问清是单台阿里云 ECS 还是 AWS 欧美 + 新加坡两台，再给价。</p>
<p>改完别在自己电脑上刷新一下就收工。<strong>隔 10 分钟，从欧美和新加坡各测一次</strong>，产品页、询盘页、支付回调页各点一遍。国内打开正常不代表客户那边正常，我之前碰过新加坡节点单独留了旧 deny 规则，国内和法兰克福都 200，只有东南亚 403，拖了两天才从访问日志里看出来。PHP 8.1 / 8.2 的站顺手确认下 fpm 属主和 Nginx 是同一个用户，跨版本迁移后这里最容易漏。</p>
<h2 id="fuwuqi120-faq">常见问题</h2>
<h3>WordPress 外贸站首页正常，产品详情页 nginx 403 forbidden 是什么原因</h3>
<p>多半是固定链接伪静态 try_files 没交给 index.php，或 root 指到旧目录。查 error.log 的 directory index 那行。</p>
<h3>宝塔面板迁移站点后 wp-content/uploads 图片全部 403 怎么修</h3>
<p>解包保留了旧 uid。chown -R www:www 站点目录，目录 755、文件 644，再 reload nginx，别开 autoindex。</p>
<h3>阿里云 ECS 权限都改成 755 了还是 403 forbidden 是不是安全组问题</h3>
<p>不是。安全组不通会超时。查 SELinux：getenforce 和 audit.log，或站点 conf 里的 deny all。</p>
<h3>AWS EC2 Ubuntu 22.04 nginx 1.24 只有 wp-admin 报 403 海外 IP 被拦了吗</h3>
<p>大概率是 vhost 里 allow/deny 白名单或 WAF 规则。grep -Rni &#039;deny&#039; 配置，用 &#8211;resolve 直连源站复测。</p>
<h3>nginx 403 forbidden 临时改 777 能先恢复 PayPal 回调吗</h3>
<p>能，但别留过夜。先改回 644/755 并补属主，回调窗口通常只有几分钟到几十分钟，恢复后查订单状态。</p>
<div class="fuwuqi120-cta">
<p>服务器又出问题了？外贸站的宕机、被黑、迁移和访问慢，我们按次或按月代维，先免费看机器再报价。</p>
<p><a class="fuwuqi120-cta-btn" href="/service/">看看代维服务</a></p>
</div>
<div class="fuwuqi120-grid">
<p class="fuwuqi120-grid-title"><strong>0</strong></p>
<div class="fuwuqi120-grid-inner"><a class="fuwuqi120-card" href="https://www.fuwuqi120.com/%e5%ae%9d%e5%a1%94%e9%9d%a2%e6%9d%bf%e5%91%bd%e4%bb%a4%ef%bc%9a%e5%a4%96%e8%b4%b8%e7%ab%99%e6%8e%92%e9%9a%9c%e5%ae%9e%e6%93%8d/"><span class="fuwuqi120-card-thumb" style="background-image:url(https://www.fuwuqi120.com/wp-content/uploads/2026/11/e5ae9de5a194e99da2e69dbfe591bde4bba4efbc9ae5a496e8b4b8e7ab99e68e92e99a9ce5ae9ee6938d-ckrnSw-768x430.webp)" aria-hidden="true"></span><span class="fuwuqi120-card-body"><span class="fuwuqi120-card-cat">linux服务器代维</span><span class="fuwuqi120-card-title">宝塔面板命令：外贸站排障实操</span><span class="fuwuqi120-card-date">2026-11-25</span></span></a><a class="fuwuqi120-card" href="https://www.fuwuqi120.com/2-504%e9%94%99%e8%af%af%e6%8e%92%e6%9f%a5%ef%bc%9a%e5%a4%96%e8%b4%b8%e7%ab%99%e7%bd%91%e5%85%b3%e8%b6%85%e6%97%b6%e6%80%8e%e4%b9%88%e4%bf%ae/"><span class="fuwuqi120-card-thumb" style="background-image:url(https://www.fuwuqi120.com/wp-content/uploads/2026/11/2-504e99499e8afafe68e92e69fa5efbc9ae5a496e8b4b8e7ab99e7bd91e585b3e8b685e697b6e6808ee4b988e4bfae-3kT1Ok-768x430.webp)" aria-hidden="true"></span><span class="fuwuqi120-card-body"><span class="fuwuqi120-card-cat">linux服务器代维</span><span class="fuwuqi120-card-title">2 504错误排查：外贸站网关超时怎么修</span><span class="fuwuqi120-card-date">2026-11-22</span></span></a><a class="fuwuqi120-card" href="https://www.fuwuqi120.com/nginx%e5%8f%8d%e5%90%91%e4%bb%a3%e7%90%86%e5%a4%b1%e8%b4%a5%ef%bc%9a%e5%a4%96%e8%b4%b8%e7%ab%99%e6%8e%92%e9%9a%9c%e5%ae%9e%e5%bd%95/"><span class="fuwuqi120-card-thumb" style="background-image:url(https://www.fuwuqi120.com/wp-content/uploads/2026/11/nginxe58f8de59091e4bba3e79086e5a4b1e8b4a5efbc9ae5a496e8b4b8e7ab99e68e92e99a9ce5ae9ee5bd95-Ou1YoF-768x430.webp)" aria-hidden="true"></span><span class="fuwuqi120-card-body"><span class="fuwuqi120-card-cat">linux服务器代维</span><span class="fuwuqi120-card-title">Nginx反向代理失败：外贸站排障实录</span><span class="fuwuqi120-card-date">2026-11-21</span></span></a><a class="fuwuqi120-card" href="https://www.fuwuqi120.com/1-nginx%e4%bc%98%e5%8c%96%e9%85%8d%e7%bd%ae%e7%a4%ba%e4%be%8b%ef%bc%9a%e5%a4%96%e8%b4%b8%e7%ab%99%e5%8f%af%e7%9b%b4%e6%8e%a5%e5%a5%97%e7%94%a8/"><span class="fuwuqi120-card-thumb" style="background-image:url(https://www.fuwuqi120.com/wp-content/uploads/2026/11/1-nginxe4bc98e58c96e9858de7bdaee7a4bae4be8befbc9ae5a496e8b4b8e7ab99e58fafe79bb4e68ea5e5a597e794a8-kaL4Ls-768x430.webp)" aria-hidden="true"></span><span class="fuwuqi120-card-body"><span class="fuwuqi120-card-cat">linux服务器代维</span><span class="fuwuqi120-card-title">1 Nginx优化配置示例：外贸站可直接套用</span><span class="fuwuqi120-card-date">2026-11-19</span></span></a><a class="fuwuqi120-card" href="https://www.fuwuqi120.com/nginx-%e5%b8%b8%e8%a7%81%e9%94%99%e8%af%af%e6%8e%92%e6%9f%a5%e6%8c%87%e5%8d%97%ef%bc%9a%e5%a4%96%e8%b4%b8%e7%ab%99%e5%ae%9e%e6%88%98/"><span class="fuwuqi120-card-thumb" style="background-image:url(https://www.fuwuqi120.com/wp-content/uploads/2026/11/nginx-e5b8b8e8a781e99499e8afafe68e92e69fa5e68c87e58d97efbc9ae5a496e8b4b8e7ab99e5ae9ee68898-NVasxb-768x430.webp)" aria-hidden="true"></span><span class="fuwuqi120-card-body"><span class="fuwuqi120-card-cat">linux服务器代维</span><span class="fuwuqi120-card-title">Nginx 常见错误排查指南：外贸站实战</span><span class="fuwuqi120-card-date">2026-11-18</span></span></a><a class="fuwuqi120-card" href="https://www.fuwuqi120.com/nginx-%e7%bd%91%e5%85%b3%e9%94%99%e8%af%af%e6%8e%92%e6%9f%a5%ef%bc%9a%e5%a4%96%e8%b4%b8%e7%ab%99-502-504-%e5%ae%9e%e5%bd%95/"><span class="fuwuqi120-card-thumb" style="background-image:url(https://www.fuwuqi120.com/wp-content/uploads/2026/11/nginx-e7bd91e585b3e99499e8afafe68e92e69fa5efbc9ae5a496e8b4b8e7ab99-502-504-e5ae9ee5bd95-zZIlPd-768x430.webp)" aria-hidden="true"></span><span class="fuwuqi120-card-body"><span class="fuwuqi120-card-cat">linux服务器代维</span><span class="fuwuqi120-card-title">Nginx 网关错误排查：外贸站 502/504 实录</span><span class="fuwuqi120-card-date">2026-11-18</span></span></a><a class="fuwuqi120-card" href="https://www.fuwuqi120.com/%e5%a4%96%e8%b4%b8%e7%ab%99%e5%ae%9d%e5%a1%94%e9%9d%a2%e6%9d%bf%e5%ae%89%e8%a3%85%e5%91%bd%e4%bb%a4%ef%bc%9a%e5%85%88%e9%80%89%e7%b3%bb%e7%bb%9f%e5%86%8d%e8%a3%85/"><span class="fuwuqi120-card-thumb" style="background-image:url(https://www.fuwuqi120.com/wp-content/uploads/2026/11/e5a496e8b4b8e7ab99e5ae9de5a194e99da2e69dbfe5ae89e8a385e591bde4bba4efbc9ae58588e98089e7b3bbe7bb9fe5868de8a385-vU0FgY-768x430.webp)" aria-hidden="true"></span><span class="fuwuqi120-card-body"><span class="fuwuqi120-card-cat">linux服务器代维</span><span class="fuwuqi120-card-title">外贸站宝塔面板安装命令：先选系统再装</span><span class="fuwuqi120-card-date">2026-11-15</span></span></a><a class="fuwuqi120-card" href="https://www.fuwuqi120.com/wordpress-%e5%a4%96%e8%b4%b8%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%85%a8%e9%9d%a2%e7%bb%b4%e6%8a%a4%e6%9c%8d%e5%8a%a1%ef%bc%88%e6%94%af%e6%8c%81%e4%b8%ad%e8%8b%b1%e6%96%87%ef%bc%89/"><span class="fuwuqi120-card-thumb" style="background-image:url(https://www.fuwuqi120.com/wp-content/uploads/2026/11/wordpress-e5a496e8b4b8e69c8de58aa1e599a8e585a8e99da2e7bbb4e68aa4e69c8de58aa1efbc88e694afe68c81e4b8ade88bb1e69687efbc89-L09wI0-768x430.webp)" aria-hidden="true"></span><span class="fuwuqi120-card-body"><span class="fuwuqi120-card-cat">aliyun服务器代维</span><span class="fuwuqi120-card-title">WordPress 外贸服务器全面维护服务（支持中英文）</span><span class="fuwuqi120-card-date">2020-02-28</span></span></a><a class="fuwuqi120-card" href="https://www.fuwuqi120.com/%e4%bc%81%e4%b8%9a%e6%9c%8d%e5%8a%a1%e5%99%a8%e6%89%98%e7%ae%a1%e8%bf%90%e7%bb%b4/"><span class="fuwuqi120-card-thumb" style="background-image:url(https://www.fuwuqi120.com/wp-content/uploads/2026/11/e4bc81e4b89ae69c8de58aa1e599a8e68998e7aea1e8bf90e7bbb4-E1vdzG-768x430.webp)" aria-hidden="true"></span><span class="fuwuqi120-card-body"><span class="fuwuqi120-card-cat">linux代维</span><span class="fuwuqi120-card-title">企业服务器托管运维</span><span class="fuwuqi120-card-date">2020-02-28</span></span></a></div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.fuwuqi120.com/nginx-403-forbidden-%e5%8e%9f%e5%9b%a0%e4%b8%8e%e5%a4%96%e8%b4%b8%e7%ab%99%e6%8e%92%e6%9f%a5/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
