WordPress in Windows And Uncaught Error: Call to undefined function mysql_connect()

摘要:
https://www.nginx.com/resources/wiki/start/topics/examples/phpfastcgionwindows/下载MySQL和PHPMySQL https:配置Nginx目录添加文件start-php-fcgi.bat@ECHOOFFECHOStartingPHPFastCGI...setPATH=小时:

下载 WordPress 

https://cn.wordpress.org/download/#download-install 

直接解压出来

WordPress in Windows And Uncaught Error: Call to undefined function mysql_connect()第1张

 打开 readme.html 有简单指引。

 浏览器打开 wp-admin/install.php ,指的是通过 web 服务器 打开。浏览器直接打开是源代码。

web 浏览器本身也不支持 .php ,本次使用 Nginx 配合调用 php 程序 解析。

https://www.nginx.com/resources/wiki/start/topics/examples/phpfastcgionwindows/

下载 MySQL、PHP

MySQL https://dev.mysql.com/downloads/windows/installer/

选择 custom 自定义安装,安装 server 和 workbench(可以连接查看、操作数据库),只安装 server 也可

WordPress in Windows And Uncaught Error: Call to undefined function mysql_connect()第2张

默认用户 root ,设置一下密码就好。完成登录一次,记住密码。 

如果有其他考虑,最好为 WordPress 专门创建一个用户。WordPress  配置的时候需要填写数据库账号密码。

安装好后可通过 管理器重新配置

MySQL Installer - Community

WordPress in Windows And Uncaught Error: Call to undefined function mysql_connect()第3张

 WordPress in Windows And Uncaught Error: Call to undefined function mysql_connect()第4张

 

PHP https://windows.php.net/download/

WordPress in Windows And Uncaught Error: Call to undefined function mysql_connect()第5张

 

 本次下载8.0 NTS, .zip ,解压出来既是免安装文件,*.exe 可直接配置使用。

下载 RunHiddenConsole

https://redmine.lighttpd.net/attachments/660/RunHiddenConsole.zip

直接下载解压到想放置的目录。功能:隐藏命令行窗口,后台运行服务。

配置

Nginx 目录添加文件

start-php-fcgi.bat

@ECHO OFF
ECHO Starting PHP FastCGI...
set PATH=h:PHP;%PATH%
h:RunHiddenConsoleRunHiddenConsole.exe h:PHPphp-cgi.exe -b 127.0.0.1:9123

Nginx 参数

nginx.conf ,添加内容:访问***.php 时,通过端口 9123 去处理

location ~ .php$ {
    fastcgi_pass   127.0.0.1:9123;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME      
    $document_root$fastcgi_script_name;
    include        fastcgi_params;
}

静态文件安置

将wordpress中的所有文件复制到 Nginx 配置的根文件夹内

WordPress in Windows And Uncaught Error: Call to undefined function mysql_connect()第6张WordPress in Windows And Uncaught Error: Call to undefined function mysql_connect()第7张

 

双击运行 start-php-fcgi.bat (看情况添加为开机启动),即可通过 网页访问、开始配置 WordPress

WordPress in Windows And Uncaught Error: Call to undefined function mysql_connect()第8张

 

输入 账号密码尝试时报错

WordPress in Windows And Uncaught Error: Call to undefined function mysql_connect()第9张

 直接 修改 wp-config.php 文件填写账号密码,报同样的错误

再次 wp-config.php 修改添加错误报告(解决问题过后再改回去)

// define( 'WP_DEBUG', false );
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true);
// 显示errors and warnings
define( 'WP_DEBUG_DISPLAY', true);
@ini_set( 'display_errors', 'On');

错误路径 wp-content/debug.log

[08-Nov-2021 05:28:45 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function mysql_connect() in H:Nginxhtmlwp-includeswp-db.php:1685
Stack trace:
#0 H:Nginxhtmlwp-includeswp-db.php(632): wpdb->db_connect()
#1 H:Nginxhtmlwp-includesload.php(558): wpdb->__construct('root', 'Mwfynms5418.', 'wordpress', 'localhost')
#2 H:Nginxhtmlwp-settings.php(124): require_wp_db()
#3 H:Nginxhtmlwp-config.php(99): require_once('H:\Nginx\html\w...')
#4 H:Nginxhtmlwp-load.php(50): require_once('H:\Nginx\html\w...')
#5 H:Nginxhtmlwp-admininstall.php(36): require_once('H:\Nginx\html\w...')
#6 {main}
  thrown in H:Nginxhtmlwp-includeswp-db.php on line 1685

查询,原因是 mysql_connect() 过期弃用了,应该调用 mysqli_connect()。

本次下载的最新的 WordPress 和 PHP ,按道理不应该出问题。

搜索配置了一下 PHP

复制一份 php.ini-development 为 php.ini

设置添加 PHP 扩展

extension=php_mysqli.dll
WordPress in Windows And Uncaught Error: Call to undefined function mysql_connect()第10张

WordPress in Windows And Uncaught Error: Call to undefined function mysql_connect()第11张

刷新页面,还是不成,折腾了一会儿, 

报错文件源代码查看

WordPress in Windows And Uncaught Error: Call to undefined function mysql_connect()第12张

看意思应该是如果存在就会用  mysqli_connect()

搜索查询扩展命令:php . est.php

<pre>
// test.php
<?php print_r(get_loaded_extensions()); ?>
</pre>

WordPress in Windows And Uncaught Error: Call to undefined function mysql_connect()第13张

 扩展是有的,折腾好一会儿,重启了一下 php-cgi ,问题解决。

WordPress in Windows And Uncaught Error: Call to undefined function mysql_connect()第14张

 PS:看来可以把 php-cgi 启动脚本和 Nginx 绑到一起。或者修改PHP相关,记着重启一下。

 设置安装 、登录,报错403

WordPress in Windows And Uncaught Error: Call to undefined function mysql_connect()第15张

 看里面有个 index.php ,默认应该访问 index.php ,但没有

修改 Nginx 配置 index 添加 index.php

WordPress in Windows And Uncaught Error: Call to undefined function mysql_connect()第16张

 

nginx -s reload  重新登陆,OK。(正常部署,应该删掉 html ,不然主页会访问到index.html)
更新插件 error: No working transports found
查询又是扩展问题
extension=php_openssl.dll
extension=php_curl.dll
直接把 php.in 里面的全给打开了,重启 php-cgi ,发现有几个扩展没有,又给注释掉,再重启,OK。(.dll 扩展,没有的,需要自己找到源码编译出来)
WordPress in Windows And Uncaught Error: Call to undefined function mysql_connect()第17张

 

添加浏览器标签栏 favicon 小图标

制作 favicon.ico  https://tool.lu/favicon/ 

主题目录:*wp-content hemes

找到启用的主题,添加图标位置

编辑主题文件header.php,在<head>和</head>之间添加以下代码:

<link rel="shortcut icon" href="https://***/favicon.ico" type="image/x-icon" />

<link rel="Bookmark" href="https://***/favicon.ico" />

保存更新文件文件,清除浏览器缓存即可看到效果。

可以添加动态 favicon 图标:

先挑一张喜欢的gif动态图片,调整成16×16大小,重新命名为favicon.gif。

在<head>和</head>之间添加以下代码:

<link rel="icon" href="https://***/favicon.gif" type="image/gif" >

保存更新文件文件,清除浏览器缓存即可看到效果。

php-cgi 进程守护

发现每天 php-cgi 进程老是会自己挂掉,导致页面打不开 502 Bad Gateway

windows下的进程守护 xxfpmW   https://github.com/jying000/xxfpmW

linux 下有个老版本 xxfpm  https://github.com/78/xxfpm

固定链接格式

改了过后 404 

修改 nginx 配置 并重启 nginx

location / {
            root html;
            index index.php;
            if (-f $request_filename/index.html) {
                rewrite (.*) $1/index.html break;
            }
            if (-f $request_filename/index.php) {
                rewrite (.*) $1/index.php;
            }
            if (!-f $request_filename) {
                rewrite (.*) /index.php;
            }

        }

免责声明:文章转载自《WordPress in Windows And Uncaught Error: Call to undefined function mysql_connect()》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇java中子类继承父类程序执行顺序问题jenkins对测试脚本的构建步骤下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

Android应用内展示office文件--腾讯浏览服务(TBS)

什么是TBS  依托 X5 内核强大的能力,致力于提供优化移动端浏览体验的整套解决方案(官网介绍)。我们可利用其做文件浏览功能,支持多种文件格式,完全可以满足需求。更多介绍请看官网:http://x5.tencent.com/ 接入TBS TBS只能浏览本地文件,对于远程文件需要先进行下载,我们先看浏览本地文件如何实现。 1. 下载SDK:http://x...

php函数substr_replace中文乱码的替代解决方法

$str = "中华人民共和国"; $len = mb_strlen($str,'utf-8'); if($len>=6){ $str1 = mb_substr($str,0,2,'utf-8'); $str2 = mb_substr($str,$...

Linux的PHP开发环境快速搭建

搭建的环境是LNMP: 1、安装MySQL 这个非常简单我用的是Ubuntu那么就用apt源,下载deb文件然后按照全新安装文档按顺序:a.加入apt库  b.更新apt库 c.安装 d.运行MySQL 下载: https://dev.mysql.com/downloads/repo/apt/ 文档: https://dev.mysql.com/doc/m...

npm 进阶命令知多少(一)

前言 作为前端模块化扎展现形式的npm包,已经在前端开发中不可或缺,熟练掌握npm相关内容,也是前端开发者的一门必修课,那么除了npm publish这类常见内容之外,还有哪些内容需要我们关注呢,下面就一起深入看看。 npm publish 发布npm包 该命令简单粗暴,执行之后,就会将相关文件上传到远端,并为对应包新增一个对应版本号。那么这里的相关文件和...

Spring Integration sftp 专栏详解

Spring Integration Sftp 文件传送 目前在国内项目开发中,使用Spring Integration技术的比较少,尤其是中文的参考文献和项目案例,更是罕有。鉴于此,本文详细介绍spring integration sftp模块在Sftp服务器和本地服务器之间文件的传送。SFTP(Secure File Transfer Protocol...

vscode 对于 C 源文件,IntelliSenseMode 已根据编译器参数和探测 compilerPath 从“clang-x64”更改为“gcc-x64”

vscode 不知道从什么时候开始出现 对于 C 源文件,IntelliSenseMode 已根据编译器参数和探测 compilerPath 从“clang-x64”更改为“gcc-x64” 的信息 解决方案 .vscode 文件夹 -> c_cpp_properties.json 文件 -> 将 "intelliSenseMode": "cl...