最近,将网站运行的硬件进行了升级到了云服务器,同时用上最新的宝塔面板(基于centos7的7.4.7版本),php主要是用7.3版本,网上资料说,wordpress完美支持php7.0及以上版本,那么现阶段选择php7.3是可以承前启后的。
附为什么要选择php7,因为快;为什么选择php7.3,因为其稳定。
一通wordpress搬家操作。域名解析更换且成功后,浏览网站,出现这么一大串:
Warning: Use of undefined constant ‘WP\_DEBUG’ - assumed '‘WP\_DEBUG’' (this will throw an Error in a future version of PHP) in C:\\wwwroot\\[www.meiguogoufang.com](www.meiguogoufang.com)\\wp-config.php on line 67
Warning: is\_readable(): open\_basedir restriction in effect. File(C:\\wwwroot\\[www.meiguogoufang.com/wp-content/plugins/C](www.meiguogoufang.com/wp-content/plugins/C):\\wwwroot\\[www.meiguogoufang.com](www.meiguogoufang.com)\\wp-content\\plugins\\ultimate-elementor/languages/uael-zh\_CN.mo) is not within the allowed path(s): (C:/wwwroot/[www.meiguogoufang.com/;C:/Windows/Temp/;C:/Temp/;C:/BtSoft/temp/session/](www.meiguogoufang.com/;C:/Windows/Temp/;C:/Temp/;C:/BtSoft/temp/session/)) in C:\\wwwroot\\[www.meiguogoufang.com](www.meiguogoufang.com)\\wp-includes\\l10n.php on line 741
Warning: exec(): Unable to fork \[minify C:\\wwwroot\\[www.meiguogoufang.com/wp-content/plugins/all-in-one-seo-pack/dist/Lite/assets/css/aioseo-admin-bar.css](www.meiguogoufang.com/wp-content/plugins/all-in-one-seo-pack/dist/Lite/assets/css/aioseo-admin-bar.css) --output=C:\\wwwroot\\[www.meiguogoufang.com/wp-content/plugins/all-in-one-seo-pack/dist/Lite/assets/css/aioseo-admin-bar.min.css](www.meiguogoufang.com/wp-content/plugins/all-in-one-seo-pack/dist/Lite/assets/css/aioseo-admin-bar.min.css)\] in C:\\wwwroot\\[www.meiguogoufang.com](www.meiguogoufang.com)\\wp-content\\plugins\\sg-cachepress\\core\\Minifier\\Minifier.php on line 226
Warning: is\_file(): open\_basedir restriction in effect. File(C:\\wwwroot\\[www.meiguogoufang.com/wp-content/uploads/elementor/css/post-13.css?ver=1609991022](www.meiguogoufang.com/wp-content/uploads/elementor/css/post-13.css?ver=1609991022)) is not within the allowed path(s): (C:/wwwroot/[www.meiguogoufang.com/;C:/Windows/Temp/;C:/Temp/;C:/BtSoft/temp/session/](www.meiguogoufang.com/;C:/Windows/Temp/;C:/Temp/;C:/BtSoft/temp/session/)) in C:\\wwwroot\\[www.meiguogoufang.com](www.meiguogoufang.com)\\wp-content\\plugins\\sg-cachepress\\core\\Minifier\\Minifier.php on line 198
Warning: is\_file(): open\_basedir restriction in effect. File(C:\\wwwroot\\[www.meiguogoufang.com/wp-content/uploads/elementor/css/post-91.css?ver=1609991665](www.meiguogoufang.com/wp-content/uploads/elementor/css/post-91.css?ver=1609991665)) is not within the allowed path(s): (C:/wwwroot/[www.meiguogoufang.com/;C:/Windows/Temp/;C:/Temp/;C:/BtSoft/temp/session/](www.meiguogoufang.com/;C:/Windows/Temp/;C:/Temp/;C:/BtSoft/temp/session/)) in C:\\wwwroot\\[www.meiguogoufang.com](www.meiguogoufang.com)\\wp-content\\plugins\\sg-cachepress\\core\\Minifier\\Minifier.php on line 198
Warning: is\_file(): open\_basedir restriction in effect. File(C:\\wwwroot\\[www.meiguogoufang.com/wp-content/uploads/elementor/css/post-43.css?ver=1609991023](www.meiguogoufang.com/wp-content/uploads/elementor/css/post-43.css?ver=1609991023)) is not within the allowed path(s): (C:/wwwroot/[www.meiguogoufang.com/;C:/Windows/Temp/;C:/Temp/;C:/BtSoft/temp/session/](www.meiguogoufang.com/;C:/Windows/Temp/;C:/Temp/;C:/BtSoft/temp/session/)) in C:\\wwwroot\\[www.meiguogoufang.com](www.meiguogoufang.com)\\wp-content\\plugins\\sg-cachepress\\core\\Minifier\\Minifier.php on line 198
Warning: is\_file(): open\_basedir restriction in effect. File(C:\\wwwroot\\[www.meiguogoufang.com/wp-content/uploads/elementor/css/post-283.css?ver=1609995418](www.meiguogoufang.com/wp-content/uploads/elementor/css/post-283.css?ver=1609995418)) is not within the allowed path(s): (C:/wwwroot/[www.meiguogoufang.com/;C:/Windows/Temp/;C:/Temp/;C:/BtSoft/temp/session/](www.meiguogoufang.com/;C:/Windows/Temp/;C:/Temp/;C:/BtSoft/temp/session/)) in C:\\wwwroot\\[www.meiguogoufang.com](www.meiguogoufang.com)\\wp-content\\plugins\\sg-cachepress\\core\\Minifier\\Minifier.php on line 198
……好多好多,不忍描述。然后下面是网站正常的样子。
以上这些错误大概意思是“使用了未定义的常量gallerytag、videotag、taotag、filtersa、filtersb,这将在未来的PHP版本中引发错误“;
我去,不是说wordpress完美支持php7么?怎么会这样,细一思考,这其实不怪wordpress,而是用的是“知更鸟”主题,这个主题有很多字段模型,如上面的gallerytag、videotag等,这都是主题附带的。
那解决方法有两种:
一、升级主题,这个不太现实。
二、只是报了”Warning警告“,我能不能不让这些错误信息显示?
看来只需要关闭”PHP错误提示“就行了。宝塔面板中操作如下:
进入php管理,点“配置修改”,设置display_errors为关闭,然后保存,重启一下服务。
就这么简单。
如果不是在宝塔面板,那就要深入腹地,修改php.ini文件。
1、打开 php.ini
2、设置 error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
3、设置 display_errors = Off
其实两个方法,只是方式不同,改的都是同一个东西。