最近把这个没人访问的小站从Typecho转回了Wordpress,没啥特别的原因,只是换了主机想折腾折腾。Typecho很优秀,但一直没更新,给人感觉没人在维护了(刚发现好像马上要出新版了)。
自己所学所做和IT行业半毛钱关系没有,属纯外行。为了整个过程顺利省心,直接从腾讯云后台一键安装了Wordpress。整个过程很顺利,但也出现了一些小问题,下面做个记录以备下次折腾。
- 安装主题后,发现有些文章前会莫明其妙的出现有PHP错误代码。从网上找到了万能解决方法:在 functions.php (或 fun.php) 中<?php后面加入以下代码,完美解决:
error_reporting(0);
-
**原因:**各大主机服务商出于避免垃圾邮件的考虑,不支持发送邮件的 mail () 函数,只能启用 SMTP 方式发送邮件。
-
**解决办法:**安装WP Mail SMTP插件,用163邮箱的SMTP设置成功
- 因为腾讯云需要备案,备案期间域名无法访问。在此期间,直接用公网ip登录Wordpress后台做各种转移和装修工作。腾讯云后台设置好HTTPS后,出现了这个后台登录无反应问题的问题。解决办法详见:wordpress、帝国 cms 网站配置 https(SSL) 无法登录后台
1)、打开网站根目录文件 \ wp-includes\functions.php,找到代码 require(ABSPATH . WPINC . ‘/option.php’); 大概在第 8 行。
在下方添加以下代码:
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="" cid="n19" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; caret-color: rgb(51, 51, 51); color: rgb(51, 51, 51); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none; background-position: inherit inherit; background-repeat: inherit inherit;">add_filter('script_loader_src', 'agnostic_script_loader_src', 20,2); function agnostic_script_loader_src($src, $handle) { return preg_replace('/^(http|https):/', '', $src); } add_filter('style_loader_src', 'agnostic_style_loader_src', 20,2); function agnostic_style_loader_src($src, $handle) { return preg_replace('/^(http|https):/', '', $src); } </pre>
2)、打开网站根目录 \ wp-config.php 文件找到代码
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="" cid="n21" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; caret-color: rgb(51, 51, 51); color: rgb(51, 51, 51); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none; background-position: inherit inherit; background-repeat: inherit inherit;">* * @package WordPress */</pre>
在下方添加如下代码:
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="" cid="n23" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; caret-color: rgb(51, 51, 51); color: rgb(51, 51, 51); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none; background-position: inherit inherit; background-repeat: inherit inherit;">$_SERVER['HTTPS'] = 'on'; define('FORCE_SSL_LOGIN', true); define('FORCE_SSL_ADMIN', true);</pre>
完成以上两步操作后,可以正常访问 wordpress https 开头网站后台了,登录 wordpress 后台,点击设置 – 常规 – 常规选项,将 WordPress 地址 (URL)、站点地址(URL) 改为 https:// 开头的链接地址(如 https://xqrp.com), 后点击“保存更改”。
- 安装完cdn后,WordPress网站全站CDN缓存.。发布或更新文章、提交评论或评论被审核通过时,服务器并不能自动刷新CDN缓存。这样会造成网站内容不能及时更新,别人看到的网页可能还是CDN服务器提供的老的网页。要解决这个问题,可以在腾讯云后对手动刷新CDN缓存。但更简单的办法是安装CDN缓存插件,比如tencentcloud-cdn或者zhanzhangb-tcdn。
原文链接:https://blog.csdn.net/u012364545/article/details/120990786?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522165918471416781667857879%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=165918471416781667857879&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-19-120990786-null-null.nonecase&utm_term=%E5%85%8D%E5%A4%87%E6%A1%88cdn
原创文章,作者:优速盾-小U,如若转载,请注明出处:https://www.cdnb.net/bbs/archives/1281