php - Uncaught Error : Call to undefined function mysql_connect() - WordPress Setup

标签 php wordpress nginx

我正在尝试在 Windows 10 上的 nginx 上安装 WordPress,无法完成设置,我在输入数据库连接信息后看到此信息:

There has been a critical error on your website.

php 日志文件中的错误

Stack trace: #0 C:\nginx\html\wp\wp-admin\setup-config.php(310): wpdb->db_connect() #1 {main} thrown in C:\nginx\html\wp\wp-includes\wp-db.php on line 1670 [30-Aug-2020 12:55:09 UTC] PHP Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in C:\nginx\html\wp\wp-includes\wp-db.php:1670

在wp-db.php中用mysqli_connect()替换mysql_connect()并没有解决我的问题

服务器信息:

  • Windows 10 家庭版 x64 位
  • nginx 1.17.10
  • php 7.4.9.0 >> VC15 x64 非线程安全(2020 年 8 月 4 日 15:17:37)
  • mysql 5.7.23.0

nginx 配置:

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.php index.html index.htm;
        }
        
        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
           root           html;
           fastcgi_pass   127.0.0.1:9000;
           fastcgi_index  index.php;
           fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
           include        fastcgi_params;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

在启动 nginx 之前,php-cgi 始终在 127.0.0.1:9000 上运行

最佳答案

我找到了解决方案,您所要做的就是取消 php.ini 中这些行的注释

extension=mysqli
extension=pdo_mysql

关于php - Uncaught Error : Call to undefined function mysql_connect() - WordPress Setup,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63657968/

相关文章:

php - 忽略 preg_match_all 输出中的字符

php - KNP Doctrine 行为与 Atlantic18 Doctrine 扩展

php - 如何将 WordPress 主题分成两列?

wordpress - 如何在 NAV 元素上 float DIV?

tomcat - 能否指示浏览器缓存具有可变查询字符串的资源?

php - 无法连接到数据库 (000webhost)

php - 在子域之间分配和传递 session 变量

wordpress - 如何为 WooCommerce 添加电子邮件验证功能

caching - 使用 Docker 运行 Nginx 时如何禁用 Nginx 缓存

docker - Nginx https发布docker-compose